![]() |
OpenMS
|
Base class for XML handlers. More...
#include <OpenMS/FORMAT/HANDLERS/XMLHandler.h>
Classes | |
| class | EndParsingSoftly |
| Exception that is thrown if the parsing is ended by some event (e.g. if only a prefix of the XML file is needed). More... | |
Public Types | |
| enum | ActionMode { LOAD , STORE } |
| Action to set the current mode (for error messages) More... | |
| enum | LOADDETAIL { LD_ALLDATA , LD_RAWCOUNTS , LD_COUNTS_WITHOPTIONS } |
Public Member Functions | |
| XMLHandler (const std::string &filename, const std::string &version) | |
| Default constructor. | |
| virtual | ~XMLHandler () |
| Destructor. | |
| void | reset () |
| Release internal memory used for parsing (call. | |
| void | fatalError (ActionMode mode, const std::string &msg, UInt line=0, UInt column=0) const |
| Fatal error handler. Throws a ParseError exception. | |
| void | error (ActionMode mode, const std::string &msg, UInt line=0, UInt column=0) const |
| Error handler for recoverable errors. | |
| void | warning (ActionMode mode, const std::string &msg, UInt line=0, UInt column=0) const |
| Warning handler. | |
Protected Member Functions | |
General MetaInfo handling (for idXML, featureXML, consensusXML) | |
| void | writeUserParam_ (const std::string &tag_name, std::ostream &os, const MetaInfoInterface &meta, UInt indent) const |
| Writes the content of MetaInfoInterface to the file. | |
std::string conversion | |
| Int | asInt_ (const std::string &in) const |
| Conversion of a std::string to an integer value. | |
| Int | asInt_ (const char16_t *in) const |
| Conversion of a Xerces string to an integer value. | |
| UInt | asUInt_ (const std::string &in) const |
| Conversion of a std::string to an unsigned integer value. | |
| double | asDouble_ (const std::string &in) const |
| Conversion of a std::string to a double value. | |
| float | asFloat_ (const std::string &in) const |
| Conversion of a std::string to a float value. | |
| bool | asBool_ (const std::string &in) const |
| Conversion of a string to a boolean value. | |
| DateTime | asDateTime_ (std::string date_string) const |
| Conversion of a xs:datetime string to a DateTime value. | |
Native (Xerces-free) SAX callbacks | |
Subclasses override these. | |
| std::string | file_ |
| File name. | |
| std::string | version_ |
| Schema version. | |
| StringManager | sm_ |
| Helper class for string conversion. | |
| std::vector< std::string > | open_tags_ |
| Stack of open XML tags. | |
| LOADDETAIL | load_detail_ |
| parse only until total number of scans and chroms have been determined from attributes | |
| virtual void | onStartElement (const char16_t *qname, const XMLAttributes &attributes) |
| Parsing method for opening tags. | |
| virtual void | onEndElement (const char16_t *qname) |
| Parsing method for closing tags. | |
| virtual void | onCharacters (const char16_t *chars, Size length) |
| Parsing method for character data. | |
| virtual void | writeTo (std::ostream &) |
| Writes the contents to a stream. | |
| virtual LOADDETAIL | getLoadDetail () const |
| handler which support partial loading, implement this method | |
| virtual void | setLoadDetail (const LOADDETAIL d) |
| handler which support partial loading, implement this method | |
| DataValue | cvParamToValue (const ControlledVocabulary &cv, const std::string &parent_tag, const std::string &accession, const std::string &name, const std::string &value, const std::string &unit_accession) const |
| Convert the value of a <cvParam value=.> (as commonly found in PSI schemata) to the DataValue with the correct type (e.g. int) according to the type stored in the CV (usually PSI-MS CV), as well as set its unit. | |
| DataValue | cvParamToValue (const ControlledVocabulary &cv, const CVTerm &raw_term) const |
| Convert the value of a <cvParam value=.> (as commonly found in PSI schemata) to the DataValue with the correct type (e.g. int) according to the type stored in the CV (usually PSI-MS CV), as well as set its unit. | |
| void | checkUniqueIdentifiers_ (const std::vector< ProteinIdentification > &prot_ids) const |
| static std::string | writeXMLEscape (const std::string &to_escape) |
| Escapes a string and returns the escaped string. | |
| static DataValue | fromXSDString (const std::string &type, const std::string &value) |
| Convert an XSD type (e.g. 'xsd:double') to a DataValue. | |
| bool | equal_ (const char16_t *a, const char16_t *b) const |
| Returns if two Xerces strings are equal. | |
controlled vocabulary handling methods | |
| std::vector< std::vector< std::string > > | cv_terms_ |
| Array of CV term lists (one sublist denotes one term and it's children) | |
| SignedSize | cvStringToEnum_ (const Size section, const std::string &term, const char *message, const SignedSize result_on_error=0) |
Accessing attributes | |
| std::string | attributeAsString_ (const XMLAttributes &a, const char *name) const |
| Converts an attribute to a String. | |
| Int | attributeAsInt_ (const XMLAttributes &a, const char *name) const |
| Converts an attribute to a Int. | |
| double | attributeAsDouble_ (const XMLAttributes &a, const char *name) const |
| Converts an attribute to a double. | |
| DoubleList | attributeAsDoubleList_ (const XMLAttributes &a, const char *name) const |
| Converts an attribute to a DoubleList. | |
| IntList | attributeAsIntList_ (const XMLAttributes &a, const char *name) const |
| Converts an attribute to an IntList. | |
| StringList | attributeAsStringList_ (const XMLAttributes &a, const char *name) const |
| Converts an attribute to an StringList. | |
| bool | optionalAttributeAsString_ (std::string &value, const XMLAttributes &a, const char *name) const |
| Assigns the attribute content to the String value if the attribute is present. | |
| bool | optionalAttributeAsInt_ (Int &value, const XMLAttributes &a, const char *name) const |
| Assigns the attribute content to the Int value if the attribute is present. | |
| bool | optionalAttributeAsUInt_ (UInt &value, const XMLAttributes &a, const char *name) const |
| Assigns the attribute content to the UInt value if the attribute is present. | |
| bool | optionalAttributeAsDouble_ (double &value, const XMLAttributes &a, const char *name) const |
| Assigns the attribute content to the double value if the attribute is present. | |
| bool | optionalAttributeAsDoubleList_ (DoubleList &value, const XMLAttributes &a, const char *name) const |
| Assigns the attribute content to the DoubleList value if the attribute is present. | |
| bool | optionalAttributeAsStringList_ (StringList &value, const XMLAttributes &a, const char *name) const |
| Assigns the attribute content to the StringList value if the attribute is present. | |
| bool | optionalAttributeAsIntList_ (IntList &value, const XMLAttributes &a, const char *name) const |
| Assigns the attribute content to the IntList value if the attribute is present. | |
| std::string | attributeAsString_ (const XMLAttributes &a, const char16_t *name) const |
| Converts an attribute to a String. | |
| Int | attributeAsInt_ (const XMLAttributes &a, const char16_t *name) const |
| Converts an attribute to a Int. | |
| double | attributeAsDouble_ (const XMLAttributes &a, const char16_t *name) const |
| Converts an attribute to a double. | |
| DoubleList | attributeAsDoubleList_ (const XMLAttributes &a, const char16_t *name) const |
| Converts an attribute to a DoubleList. | |
| IntList | attributeAsIntList_ (const XMLAttributes &a, const char16_t *name) const |
| Converts an attribute to a IntList. | |
| StringList | attributeAsStringList_ (const XMLAttributes &a, const char16_t *name) const |
| Converts an attribute to a StringList. | |
| bool | optionalAttributeAsString_ (std::string &value, const XMLAttributes &a, const char16_t *name) const |
| Assigns the attribute content to the String value if the attribute is present. | |
| bool | optionalAttributeAsInt_ (Int &value, const XMLAttributes &a, const char16_t *name) const |
| Assigns the attribute content to the Int value if the attribute is present. | |
| bool | optionalAttributeAsUInt_ (UInt &value, const XMLAttributes &a, const char16_t *name) const |
| Assigns the attribute content to the UInt value if the attribute is present. | |
| bool | optionalAttributeAsDouble_ (double &value, const XMLAttributes &a, const char16_t *name) const |
| Assigns the attribute content to the double value if the attribute is present. | |
| bool | optionalAttributeAsDoubleList_ (DoubleList &value, const XMLAttributes &a, const char16_t *name) const |
| Assigns the attribute content to the DoubleList value if the attribute is present. | |
| bool | optionalAttributeAsIntList_ (IntList &value, const XMLAttributes &a, const char16_t *name) const |
| Assigns the attribute content to the IntList value if the attribute is present. | |
| bool | optionalAttributeAsStringList_ (StringList &value, const XMLAttributes &a, const char16_t *name) const |
| Assigns the attribute content to the StringList value if the attribute is present. | |
| XMLHandler () | |
| Not implemented. | |
| const std::string & | expectList_ (const std::string &str) const |
Base class for XML handlers.
| enum ActionMode |
| enum LOADDETAIL |
| XMLHandler | ( | const std::string & | filename, |
| const std::string & | version | ||
| ) |
Default constructor.
|
virtual |
Destructor.
|
private |
Not implemented.
|
inlineprotected |
Conversion of a string to a boolean value.
'true', 'false', '1' and '0' are accepted.
For all other values a parse error is produced.
|
inlineprotected |
Conversion of a xs:datetime string to a DateTime value.
References DateTime::set().
|
inlineprotected |
Conversion of a std::string to a double value.
|
inlineprotected |
Conversion of a std::string to a float value.
|
inlineprotected |
Conversion of a Xerces string to an integer value.
References StringManager::parseInt().
|
inlineprotected |
Conversion of a std::string to an integer value.
|
inlineprotected |
Conversion of a std::string to an unsigned integer value.
|
inlineprotected |
Converts an attribute to a double.
References StringManager::convert(), and XMLAttributes::value().
|
inlineprotected |
Converts an attribute to a double.
References StringManager::convert(), and XMLAttributes::value().
|
protected |
Converts an attribute to a DoubleList.
|
protected |
Converts an attribute to a DoubleList.
|
inlineprotected |
Converts an attribute to a Int.
References StringManager::parseInt(), and XMLAttributes::value().
|
inlineprotected |
Converts an attribute to a Int.
References StringManager::convert(), StringManager::parseInt(), and XMLAttributes::value().
|
protected |
Converts an attribute to an IntList.
|
protected |
Converts an attribute to a IntList.
|
inlineprotected |
Converts an attribute to a String.
References StringManager::convert(), and XMLAttributes::value().
|
inlineprotected |
Converts an attribute to a String.
References StringManager::convert(), and XMLAttributes::value().
|
protected |
Converts an attribute to an StringList.
|
protected |
Converts an attribute to a StringList.
| void checkUniqueIdentifiers_ | ( | const std::vector< ProteinIdentification > & | prot_ids | ) | const |
throws a ParseError if protIDs are not unique, i.e. PeptideIDs will be randomly assigned (bad!) Should be called before writing any ProtIDs to file
| DataValue cvParamToValue | ( | const ControlledVocabulary & | cv, |
| const CVTerm & | raw_term | ||
| ) | const |
Convert the value of a <cvParam value=.> (as commonly found in PSI schemata) to the DataValue with the correct type (e.g. int) according to the type stored in the CV (usually PSI-MS CV), as well as set its unit.
| [in] | cv | A CV, usually the PSI-MS CV, see ControlledVocabulary::getPSIMSCV() |
| [in] | raw_term | Represenation of the raw data (i.e. all strings) from a <cvParam ...> without the conversion to a specific value type |
value could not be converted to an integer for an accession which requires an integer) or the DataValue upon success | DataValue cvParamToValue | ( | const ControlledVocabulary & | cv, |
| const std::string & | parent_tag, | ||
| const std::string & | accession, | ||
| const std::string & | name, | ||
| const std::string & | value, | ||
| const std::string & | unit_accession | ||
| ) | const |
Convert the value of a <cvParam value=.> (as commonly found in PSI schemata) to the DataValue with the correct type (e.g. int) according to the type stored in the CV (usually PSI-MS CV), as well as set its unit.
| [in] | cv | A CV, usually the PSI-MS CV, see ControlledVocabulary::getPSIMSCV() |
| [in] | parent_tag | The tag which encloses the <cvParam> |
| [in] | accession | The accession from the 'accession' attribute of the <cvParam> |
| [in] | name | The name from the 'name' attribute of the <cvParam> |
| [in] | value | The value from the 'value' attribute of the <cvParam> |
| [in] | unit_accession | The unit_accession from the 'unitAccession' attribute of the <cvParam> |
value could not be converted to an integer for an accession which requires an integer) or the DataValue upon success
|
protected |
Converts term to the index of the term in the cv_terms_ entry section If the term is not found, result_on_error is returned (0 by default)
|
inlineprotected |
Returns if two Xerces strings are equal.
| void error | ( | ActionMode | mode, |
| const std::string & | msg, | ||
| UInt | line = 0, |
||
| UInt | column = 0 |
||
| ) | const |
Error handler for recoverable errors.
Referenced by SAX2HandlerAdapter::error().
|
inlineprivate |
| void fatalError | ( | ActionMode | mode, |
| const std::string & | msg, | ||
| UInt | line = 0, |
||
| UInt | column = 0 |
||
| ) | const |
Fatal error handler. Throws a ParseError exception.
Referenced by SAX2HandlerAdapter::fatalError().
|
inlinestatic |
Convert an XSD type (e.g. 'xsd:double') to a DataValue.
Not all conversions are supported yet, due to DataValue using an Int64 as the largest possible integer. Thus, if the value contains a large UInt64, conversion will fail. Value ranges are currently also not checked, only for XSD types which happen to match the internal representation.
| [out] | type | An XSD type. If the type is not supported, the returned type will be a string |
| [in] | value | The value in sting format, e.g. "123.34" |
| Exception::ConversionError | if the value does not fit into the internal representation or (for few types) exceeds the XSD specs. |
|
virtual |
handler which support partial loading, implement this method
Reimplemented in MzMLHandler, and MzXMLHandler.
|
virtual |
Parsing method for character data.
Reimplemented in ConsensusXMLHandler, FeatureXMLHandler, MzDataHandler, MzIdentMLHandler, MzMLHandler, MzXMLHandler, ToolDescriptionHandler, TraMLHandler, UniProtXMLHandler, QcMLFile, CVMappingFile, MascotXMLHandler, PTMXMLHandler, UnimodXMLHandler, OMSSAXMLFile, SemanticValidator, and XTandemXMLFile.
Referenced by SAX2HandlerAdapter::characters().
|
virtual |
Parsing method for closing tags.
Reimplemented in CVMappingFile, ConsensusXMLHandler, FeatureXMLHandler, ImzMLHandler, MascotXMLHandler, MzDataHandler, MzIdentMLHandler, MzMLHandler, MzXMLHandler, ParamXMLHandler, PTMXMLHandler, ToolDescriptionHandler, TraMLHandler, UnimodXMLHandler, UniProtXMLHandler, XQuestResultXMLHandler, IdXMLFile, OMSSAXMLFile, PepXMLFile, PepXMLFileMascot, ProtXMLFile, QcMLFile, SemanticValidator, and XTandemXMLFile.
Referenced by SAX2HandlerAdapter::endElement().
|
virtual |
Parsing method for opening tags.
Reimplemented in CVMappingFile, IdXMLFile, OMSSAXMLFile, PepXMLFile, PepXMLFileMascot, ProtXMLFile, QcMLFile, TransformationXMLFile, XTandemXMLFile, ConsensusXMLHandler, FeatureXMLHandler, MascotXMLHandler, MzDataHandler, MzIdentMLHandler, MzMLHandler, MzXMLHandler, ParamXMLHandler, PTMXMLHandler, ToolDescriptionHandler, TraMLHandler, UnimodXMLHandler, XQuestResultXMLHandler, MzMLValidator, SemanticValidator, ImzMLHandler, and UniProtXMLHandler.
Referenced by SAX2HandlerAdapter::startElement().
|
inlineprotected |
Assigns the attribute content to the double value if the attribute is present.
References StringManager::convert(), and XMLAttributes::value().
|
inlineprotected |
Assigns the attribute content to the double value if the attribute is present.
References StringManager::convert(), and XMLAttributes::value().
|
inlineprotected |
Assigns the attribute content to the DoubleList value if the attribute is present.
References XMLAttributes::value().
|
inlineprotected |
Assigns the attribute content to the DoubleList value if the attribute is present.
References XMLAttributes::value().
|
inlineprotected |
Assigns the attribute content to the Int value if the attribute is present.
References StringManager::parseInt(), and XMLAttributes::value().
|
inlineprotected |
Assigns the attribute content to the Int value if the attribute is present.
References StringManager::parseInt(), and XMLAttributes::value().
|
inlineprotected |
Assigns the attribute content to the IntList value if the attribute is present.
References XMLAttributes::value().
|
inlineprotected |
Assigns the attribute content to the IntList value if the attribute is present.
References XMLAttributes::value().
|
inlineprotected |
Assigns the attribute content to the String value if the attribute is present.
References StringManager::convert(), and XMLAttributes::value().
|
inlineprotected |
Assigns the attribute content to the String value if the attribute is present.
References StringManager::convert(), and XMLAttributes::value().
|
inlineprotected |
Assigns the attribute content to the StringList value if the attribute is present.
References XMLAttributes::value().
|
inlineprotected |
Assigns the attribute content to the StringList value if the attribute is present.
References XMLAttributes::value().
|
inlineprotected |
Assigns the attribute content to the UInt value if the attribute is present.
References StringManager::parseInt(), and XMLAttributes::value().
|
inlineprotected |
Assigns the attribute content to the UInt value if the attribute is present.
References StringManager::parseInt(), and XMLAttributes::value().
| void reset | ( | ) |
Release internal memory used for parsing (call.
|
virtual |
handler which support partial loading, implement this method
Reimplemented in MzMLHandler, and MzXMLHandler.
| void warning | ( | ActionMode | mode, |
| const std::string & | msg, | ||
| UInt | line = 0, |
||
| UInt | column = 0 |
||
| ) | const |
Warning handler.
Referenced by SAX2HandlerAdapter::warning().
|
virtual |
Writes the contents to a stream.
Reimplemented in ConsensusXMLHandler, FeatureXMLHandler, MzDataHandler, MzIdentMLHandler, MzMLHandler, MzXMLHandler, PTMXMLHandler, ToolDescriptionHandler, TraMLHandler, and XQuestResultXMLHandler.
|
protected |
Writes the content of MetaInfoInterface to the file.
|
inlinestatic |
Escapes a string and returns the escaped string.
Some characters must be escaped which are allowed in user params. E.g. > and & are not in XML and need to be escaped. Parsing those escaped strings from file again is automatically done by Xerces. Escaped characters are: & < > " '
|
protected |
Array of CV term lists (one sublist denotes one term and it's children)
|
protected |
File name.
|
protected |
parse only until total number of scans and chroms have been determined from attributes
|
protected |
Stack of open XML tags.
This member is used only in those XML parsers that need this information.
|
protected |
Helper class for string conversion.
|
protected |
Schema version.