OpenMS
Loading...
Searching...
No Matches
ParamXMLFile Class Reference

The file pendant of the Param class used to load and store the param datastructure as paramXML (i.e. INI files). More...

#include <OpenMS/FORMAT/ParamXMLFile.h>

Inheritance diagram for ParamXMLFile:
[legend]
Collaboration diagram for ParamXMLFile:
[legend]

Public Member Functions

 ParamXMLFile ()
 Constructor.
 
void store (const std::string &filename, const Param &param) const
 Write XML file.
 
void writeXMLToStream (std::ostream *os_ptr, const Param &param) const
 Write XML to output stream.
 
void load (const std::string &filename, Param &param)
 Read XML file.
 
- Public Member Functions inherited from XMLFile
 XMLFile ()
 Construct an XMLFile without schema info; schema_location_ remains unset, so isValid cannot be used until derived-class logic initializes schema_location_ before calling isValid.
 
 XMLFile (const std::string &schema_location, const std::string &version)
 Construct with a schema location for later isValid calls.
 
virtual ~XMLFile ()
 Virtual destructor — defaulted; allows safe deletion through a base-class pointer.
 
bool isValid (const std::string &filename, std::ostream &os)
 Check if filename validates against the bound XML schema.
 
const std::string & getVersion () const
 Return the schema version string passed to the parameterised constructor; empty for default-constructed instances.
 

Additional Inherited Members

- Protected Member Functions inherited from XMLFile
void parse_ (const std::string &filename, XMLHandler *handler)
 Parse the XML file at filename through handler.
 
void parseBuffer_ (const std::string &buffer, XMLHandler *handler)
 Parse an in-memory XML buffer through handler.
 
void save_ (const std::string &filename, XMLHandler *handler) const
 Stores the contents of the XML handler given by handler in the file given by filename.
 
void enforceEncoding_ (const std::string &encoding)
 Set or clear the XML-encoding override applied to subsequent parse_ / parseBuffer_ calls.
 
- Protected Attributes inherited from XMLFile
std::string schema_location_
 Path of the XML schema for validation; empty when the default constructor was used (isValid then throws NotImplemented).
 
std::string schema_version_
 Schema version string returned by getVersion.
 
std::string enforced_encoding_
 Optional XML encoding override applied to the InputSource in parse_ and parseBuffer_; empty disables the override. Used as a workaround for XTandem output XML which carries an encoding the parser otherwise stumbles on.
 

Detailed Description

The file pendant of the Param class used to load and store the param datastructure as paramXML (i.e. INI files).

A documented schema for this format can be found at https://github.com/OpenMS/OpenMS/tree/develop/share/OpenMS/SCHEMAS

Constructor & Destructor Documentation

◆ ParamXMLFile()

Constructor.

Member Function Documentation

◆ load()

void load ( const std::string &  filename,
Param param 
)

Read XML file.

Parameters
[out]filenameThe file from where to read the Param object.
[out]paramThe param object where the read data should be stored.
Exceptions
Exception::FileNotFoundis thrown if the file could not be found
Exception::ParseErroris thrown if an error occurs during parsing

Referenced by TOPPASBase::loadPreferences(), TOPPViewBase::loadPreferences(), main(), and INIFileEditorWindow::openFile().

◆ store()

void store ( const std::string &  filename,
const Param param 
) const

Write XML file.

Parameters
[in]filenameThe filename where the param data structure should be stored.
[out]paramThe Param class that should be stored in the file.
Exceptions
Exception::UnableToCreateFileis thrown if the file could not be created

Referenced by INIFileEditorWindow::saveFile(), INIFileEditorWindow::saveFileAs(), TOPPASBase::savePreferences(), and TOPPViewBase::savePreferences().

◆ writeXMLToStream()

void writeXMLToStream ( std::ostream *  os_ptr,
const Param param 
) const

Write XML to output stream.

Parameters
[out]os_ptrThe stream where the param class should be written to.
[out]paramThe Param class that should be written to the stream.