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... | |
Public Member Functions | |
| XMLHandler (const String &filename, const String &version) | |
| Default constructor. | |
| virtual | ~XMLHandler () |
| Destructor. | |
| void | reset () |
| Release internal memory used for parsing (call. | |
| void | fatalError (ActionMode mode, const String &msg, UInt line=0, UInt column=0) const |
| Fatal error handler. Throws a ParseError exception. | |
| void | error (ActionMode mode, const String &msg, UInt line=0, UInt column=0) const |
| Error handler for recoverable errors. | |
| void | warning (ActionMode mode, const String &msg, UInt line=0, UInt column=0) const |
| Warning handler. | |
| virtual void | characters (const XMLCh *const chars, const XMLSize_t length) |
| Parsing method for character data. | |
| virtual void | startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const xercesc::Attributes &attrs) |
| Parsing method for opening tags. | |
| virtual void | endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname) |
| Parsing method for closing tags. | |
| virtual void | writeTo (std::ostream &) |
| Writes the contents to a stream. | |
| String | errorString () |
| Returns the last error description. | |
Reimplemented XERCES-C error handlers | |
| void | fatalError (const xercesc::SAXParseException &exception) |
| void | error (const xercesc::SAXParseException &exception) |
| void | warning (const xercesc::SAXParseException &exception) |
Protected Member Functions | |
| bool | equal_ (const XMLCh *a, const XMLCh *b) |
| Returns if two xerces strings are equal. | |
General MetaInfo handling (for idXML, featureXML, consensusXML) | |
| void | writeUserParam_ (const String &tag_name, std::ostream &os, const MetaInfoInterface &meta, UInt indent) const |
| Writes the content of MetaInfoInterface to the file. | |
String conversion | |
| Int | asInt_ (const String &in) |
| Conversion of a String to an integer value. | |
| Int | asInt_ (const XMLCh *in) |
| Conversion of a Xerces string to an integer value. | |
| UInt | asUInt_ (const String &in) |
| Conversion of a String to an unsigned integer value. | |
| double | asDouble_ (const String &in) |
| Conversion of a String to a double value. | |
| float | asFloat_ (const String &in) |
| Conversion of a String to a float value. | |
| bool | asBool_ (const String &in) |
| Conversion of a string to a boolean value. | |
| DateTime | asDateTime_ (String date_string) |
| Conversion of a xs:datetime string to a DataTime value. | |
Accessing attributes | |
| char * | attributeAsString_ (const xercesc::Attributes &a, const char *name) const |
| Converts an attribute to a String. | |
| Int | attributeAsInt_ (const xercesc::Attributes &a, const char *name) const |
| Converts an attribute to a Int. | |
| DoubleReal | attributeAsDouble_ (const xercesc::Attributes &a, const char *name) const |
| Converts an attribute to a DoubleReal. | |
| DoubleList | attributeAsDoubleList_ (const xercesc::Attributes &a, const char *name) const |
| Converts an attribute to a DoubleList. | |
| IntList | attributeAsIntList_ (const xercesc::Attributes &a, const char *name) const |
| Converts an attribute to an IntList. | |
| StringList | attributeAsStringList_ (const xercesc::Attributes &a, const char *name) const |
| Converts an attribute to an StringList. | |
| bool | optionalAttributeAsString_ (String &value, const xercesc::Attributes &a, const char *name) const |
| Assigns the attribute content to the String value if the attribute is present. | |
| bool | optionalAttributeAsInt_ (Int &value, const xercesc::Attributes &a, const char *name) const |
| Assigns the attribute content to the Int value if the attribute is present. | |
| bool | optionalAttributeAsUInt_ (UInt &value, const xercesc::Attributes &a, const char *name) const |
| Assigns the attribute content to the UInt value if the attribute is present. | |
| bool | optionalAttributeAsDouble_ (DoubleReal &value, const xercesc::Attributes &a, const char *name) const |
| Assigns the attribute content to the DoubleReal value if the attribute is present. | |
| bool | optionalAttributeAsDoubleList_ (DoubleList &value, const xercesc::Attributes &a, const char *name) const |
| Assigns the attribute content to the DoubleList value if the attribute is present. | |
| bool | optionalAttributeAsStringList_ (StringList &value, const xercesc::Attributes &a, const char *name) const |
| Assigns the attribute content to the StringList value if the attribute is present. | |
| bool | optionalAttributeAsIntList_ (IntList &value, const xercesc::Attributes &a, const char *name) const |
| Assigns the attribute content to the IntList value if the attribute is present. | |
| char * | attributeAsString_ (const xercesc::Attributes &a, const XMLCh *name) const |
| Converts an attribute to a String. | |
| Int | attributeAsInt_ (const xercesc::Attributes &a, const XMLCh *name) const |
| Converts an attribute to a Int. | |
| DoubleReal | attributeAsDouble_ (const xercesc::Attributes &a, const XMLCh *name) const |
| Converts an attribute to a DoubleReal. | |
| DoubleList | attributeAsDoubleList_ (const xercesc::Attributes &a, const XMLCh *name) const |
| Converts an attribute to a DoubleList. | |
| IntList | attributeAsIntList_ (const xercesc::Attributes &a, const XMLCh *name) const |
| Converts an attribute to a IntList. | |
| StringList | attributeAsStringList_ (const xercesc::Attributes &a, const XMLCh *name) const |
| Converts an attribute to a StringList. | |
| bool | optionalAttributeAsString_ (String &value, const xercesc::Attributes &a, const XMLCh *name) const |
| Assigns the attribute content to the String value if the attribute is present. | |
| bool | optionalAttributeAsInt_ (Int &value, const xercesc::Attributes &a, const XMLCh *name) const |
| Assigns the attribute content to the Int value if the attribute is present. | |
| bool | optionalAttributeAsUInt_ (UInt &value, const xercesc::Attributes &a, const XMLCh *name) const |
| Assigns the attribute content to the UInt value if the attribute is present. | |
| bool | optionalAttributeAsDouble_ (DoubleReal &value, const xercesc::Attributes &a, const XMLCh *name) const |
| Assigns the attribute content to the DoubleReal value if the attribute is present. | |
| bool | optionalAttributeAsDoubleList_ (DoubleList &value, const xercesc::Attributes &a, const XMLCh *name) const |
| Assigns the attribute content to the DoubleList value if the attribute is present. | |
| bool | optionalAttributeAsIntList_ (IntList &value, const xercesc::Attributes &a, const XMLCh *name) const |
| Assigns the attribute content to the IntList value if the attribute is present. | |
| bool | optionalAttributeAsStringList_ (StringList &value, const xercesc::Attributes &a, const XMLCh *name) const |
| Assigns the attribute content to the StringList value if the attribute is present. | |
Protected Attributes | |
| String | error_message_ |
| Error message of the last error. | |
| String | file_ |
| File name. | |
| String | version_ |
| Schema version. | |
| StringManager | sm_ |
| Helper class for string conversion. | |
| std::vector< String > | open_tags_ |
| Stack of open XML tags. | |
Private Member Functions | |
| XMLHandler () | |
| Not implemented. | |
| String | expectList_ (const char *str) const |
controlled vocabulary handling methods | |
|
| |
| std::vector< std::vector < String > > | cv_terms_ |
| Array of CV term lists (one sublist denotes one term and it's children). | |
| SignedSize | cvStringToEnum_ (const Size section, const String &term, const char *message, const SignedSize result_on_error=0) |
Base class for XML handlers.
| enum ActionMode |
| XMLHandler | ( | const String & | filename, | |
| const String & | version | |||
| ) |
Default constructor.
| virtual ~XMLHandler | ( | ) | [virtual] |
Destructor.
| XMLHandler | ( | ) | [private] |
Not implemented.
| bool asBool_ | ( | const String & | in | ) | [inline, protected] |
Conversion of a string to a boolean value.
'true', 'false', '1' and '0' are accpeted.
For all other values a parse error is produced.
Conversion of a xs:datetime string to a DataTime value.
References DateTime::set(), String::substr(), and String::trim().
Referenced by MzMLHandler< MapType >::handleCVParam_(), MzXMLHandler< MapType >::startElement(), MzMLHandler< MapType >::startElement(), and MzDataHandler< MapType >::startElement().
Conversion of a String to a double value.
References String::toDouble().
Referenced by MzXMLHandler< MapType >::characters(), MzDataHandler< MapType >::cvParam_(), and MzXMLHandler< MapType >::startElement().
| float asFloat_ | ( | const String & | in | ) | [inline, protected] |
Conversion of a String to a float value.
References String::toFloat().
| Int asInt_ | ( | const XMLCh * | in | ) | [inline, protected] |
Conversion of a Xerces string to an integer value.
Conversion of a String to an integer value.
References String::toInt().
Referenced by MzDataHandler< MapType >::cvParam_().
Conversion of a String to an unsigned integer value.
References String::toInt().
| DoubleReal attributeAsDouble_ | ( | const xercesc::Attributes & | a, | |
| const XMLCh * | name | |||
| ) | const [inline, protected] |
Converts an attribute to a DoubleReal.
| DoubleReal attributeAsDouble_ | ( | const xercesc::Attributes & | a, | |
| const char * | name | |||
| ) | const [inline, protected] |
Converts an attribute to a DoubleReal.
Referenced by MzXMLHandler< MapType >::startElement().
| DoubleList attributeAsDoubleList_ | ( | const xercesc::Attributes & | a, | |
| const XMLCh * | name | |||
| ) | const [inline, protected] |
Converts an attribute to a DoubleList.
References DoubleList::create(), and String::substr().
| DoubleList attributeAsDoubleList_ | ( | const xercesc::Attributes & | a, | |
| const char * | name | |||
| ) | const [inline, protected] |
Converts an attribute to a DoubleList.
References DoubleList::create(), and String::substr().
| Int attributeAsInt_ | ( | const xercesc::Attributes & | a, | |
| const XMLCh * | name | |||
| ) | const [inline, protected] |
Converts an attribute to a Int.
| Int attributeAsInt_ | ( | const xercesc::Attributes & | a, | |
| const char * | name | |||
| ) | const [inline, protected] |
Converts an attribute to a Int.
Referenced by MzXMLHandler< MapType >::startElement(), MzMLHandler< MapType >::startElement(), and MzDataHandler< MapType >::startElement().
| IntList attributeAsIntList_ | ( | const xercesc::Attributes & | a, | |
| const XMLCh * | name | |||
| ) | const [inline, protected] |
Converts an attribute to a IntList.
References IntList::create(), and String::substr().
| IntList attributeAsIntList_ | ( | const xercesc::Attributes & | a, | |
| const char * | name | |||
| ) | const [inline, protected] |
Converts an attribute to an IntList.
References IntList::create(), and String::substr().
| char* attributeAsString_ | ( | const xercesc::Attributes & | a, | |
| const XMLCh * | name | |||
| ) | const [inline, protected] |
Converts an attribute to a String.
| char* attributeAsString_ | ( | const xercesc::Attributes & | a, | |
| const char * | name | |||
| ) | const [inline, protected] |
Converts an attribute to a String.
Referenced by MzXMLHandler< MapType >::startElement(), MzMLHandler< MapType >::startElement(), and MzDataHandler< MapType >::startElement().
| StringList attributeAsStringList_ | ( | const xercesc::Attributes & | a, | |
| const XMLCh * | name | |||
| ) | const [inline, protected] |
Converts an attribute to a StringList.
References StringList::create(), and String::substr().
| StringList attributeAsStringList_ | ( | const xercesc::Attributes & | a, | |
| const char * | name | |||
| ) | const [inline, protected] |
Converts an attribute to an StringList.
References StringList::create(), and String::substr().
| virtual void characters | ( | const XMLCh *const | chars, | |
| const XMLSize_t | length | |||
| ) | [virtual] |
Parsing method for character data.
Reimplemented in MascotXMLHandler, MzDataHandler< MapType >, MzIdentMLHandler, MzMLHandler< MapType >, MzQuantMLHandler, MzXMLHandler< MapType >, PTMXMLHandler, ToolDescriptionHandler, TraMLHandler, UnimodXMLHandler, and XTandemInfileXMLHandler.
| SignedSize cvStringToEnum_ | ( | const Size | section, | |
| const String & | term, | |||
| const char * | message, | |||
| const SignedSize | result_on_error = 0 | |||
| ) | [inline, 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)
References OPENMS_PRECONDITION.
Referenced by MzDataHandler< MapType >::cvParam_(), and MzXMLHandler< MapType >::startElement().
| virtual void endElement | ( | const XMLCh *const | uri, | |
| const XMLCh *const | localname, | |||
| const XMLCh *const | qname | |||
| ) | [virtual] |
Parsing method for closing tags.
Reimplemented in MascotXMLHandler, MzDataHandler< MapType >, MzIdentMLHandler, MzMLHandler< MapType >, MzQuantMLHandler, MzXMLHandler< MapType >, ParamXMLHandler, PTMXMLHandler, ToolDescriptionHandler, TraMLHandler, UnimodXMLHandler, and XTandemInfileXMLHandler.
| bool equal_ | ( | const XMLCh * | a, | |
| const XMLCh * | b | |||
| ) | [inline, protected] |
Returns if two xerces strings are equal.
Referenced by MzXMLHandler< MapType >::endElement(), MzMLHandler< MapType >::endElement(), and MzDataHandler< MapType >::endElement().
| void error | ( | const xercesc::SAXParseException & | exception | ) |
| void error | ( | ActionMode | mode, | |
| const String & | msg, | |||
| UInt | line = 0, |
|||
| UInt | column = 0 | |||
| ) | const |
Error handler for recoverable errors.
| String errorString | ( | ) |
Returns the last error description.
| String expectList_ | ( | const char * | str | ) | const [inline, private] |
References String::hasPrefix(), and String::hasSuffix().
| void fatalError | ( | ActionMode | mode, | |
| const String & | msg, | |||
| UInt | line = 0, |
|||
| UInt | column = 0 | |||
| ) | const |
Fatal error handler. Throws a ParseError exception.
| void fatalError | ( | const xercesc::SAXParseException & | exception | ) |
Referenced by MzMLHandler< MapType >::fillData_(), and MzMLHandler< MapType >::startElement().
| bool optionalAttributeAsDouble_ | ( | DoubleReal & | value, | |
| const xercesc::Attributes & | a, | |||
| const char * | name | |||
| ) | const [inline, protected] |
Assigns the attribute content to the DoubleReal value if the attribute is present.
Referenced by MzXMLHandler< MapType >::startElement(), and MzDataHandler< MapType >::startElement().
| bool optionalAttributeAsDouble_ | ( | DoubleReal & | value, | |
| const xercesc::Attributes & | a, | |||
| const XMLCh * | name | |||
| ) | const [inline, protected] |
Assigns the attribute content to the DoubleReal value if the attribute is present.
| bool optionalAttributeAsDoubleList_ | ( | DoubleList & | value, | |
| const xercesc::Attributes & | a, | |||
| const char * | name | |||
| ) | const [inline, protected] |
Assigns the attribute content to the DoubleList value if the attribute is present.
| bool optionalAttributeAsDoubleList_ | ( | DoubleList & | value, | |
| const xercesc::Attributes & | a, | |||
| const XMLCh * | name | |||
| ) | const [inline, protected] |
Assigns the attribute content to the DoubleList value if the attribute is present.
| bool optionalAttributeAsInt_ | ( | Int & | value, | |
| const xercesc::Attributes & | a, | |||
| const XMLCh * | name | |||
| ) | const [inline, protected] |
Assigns the attribute content to the Int value if the attribute is present.
| bool optionalAttributeAsInt_ | ( | Int & | value, | |
| const xercesc::Attributes & | a, | |||
| const char * | name | |||
| ) | const [inline, protected] |
Assigns the attribute content to the Int value if the attribute is present.
Referenced by MzXMLHandler< MapType >::startElement(), and MzMLHandler< MapType >::startElement().
| bool optionalAttributeAsIntList_ | ( | IntList & | value, | |
| const xercesc::Attributes & | a, | |||
| const XMLCh * | name | |||
| ) | const [inline, protected] |
Assigns the attribute content to the IntList value if the attribute is present.
| bool optionalAttributeAsIntList_ | ( | IntList & | value, | |
| const xercesc::Attributes & | a, | |||
| const char * | name | |||
| ) | const [inline, protected] |
Assigns the attribute content to the IntList value if the attribute is present.
| bool optionalAttributeAsString_ | ( | String & | value, | |
| const xercesc::Attributes & | a, | |||
| const XMLCh * | name | |||
| ) | const [inline, protected] |
Assigns the attribute content to the String value if the attribute is present.
| bool optionalAttributeAsString_ | ( | String & | value, | |
| const xercesc::Attributes & | a, | |||
| const char * | name | |||
| ) | const [inline, protected] |
Assigns the attribute content to the String value if the attribute is present.
Referenced by MzXMLHandler< MapType >::startElement(), MzMLHandler< MapType >::startElement(), and MzDataHandler< MapType >::startElement().
| bool optionalAttributeAsStringList_ | ( | StringList & | value, | |
| const xercesc::Attributes & | a, | |||
| const char * | name | |||
| ) | const [inline, protected] |
Assigns the attribute content to the StringList value if the attribute is present.
| bool optionalAttributeAsStringList_ | ( | StringList & | value, | |
| const xercesc::Attributes & | a, | |||
| const XMLCh * | name | |||
| ) | const [inline, protected] |
Assigns the attribute content to the StringList value if the attribute is present.
| bool optionalAttributeAsUInt_ | ( | UInt & | value, | |
| const xercesc::Attributes & | a, | |||
| const char * | name | |||
| ) | const [inline, protected] |
Assigns the attribute content to the UInt value if the attribute is present.
| bool optionalAttributeAsUInt_ | ( | UInt & | value, | |
| const xercesc::Attributes & | a, | |||
| const XMLCh * | name | |||
| ) | const [inline, protected] |
Assigns the attribute content to the UInt value if the attribute is present.
| void reset | ( | ) |
Release internal memory used for parsing (call.
| virtual void startElement | ( | const XMLCh *const | uri, | |
| const XMLCh *const | localname, | |||
| const XMLCh *const | qname, | |||
| const xercesc::Attributes & | attrs | |||
| ) | [virtual] |
Parsing method for opening tags.
Reimplemented in MascotXMLHandler, MzDataHandler< MapType >, MzIdentMLHandler, MzMLHandler< MapType >, MzQuantMLHandler, MzXMLHandler< MapType >, ParamXMLHandler, PTMXMLHandler, ToolDescriptionHandler, TraMLHandler, UnimodXMLHandler, and XTandemInfileXMLHandler.
| void warning | ( | const xercesc::SAXParseException & | exception | ) |
Referenced by MzXMLHandler< MapType >::characters(), MzMLHandler< MapType >::characters(), MzDataHandler< MapType >::characters(), MzDataHandler< MapType >::cvParam_(), MzMLHandler< MapType >::fillChromatogramData_(), MzMLHandler< MapType >::fillData_(), MzMLHandler< MapType >::handleCVParam_(), MzMLHandler< MapType >::handleUserParam_(), MzXMLHandler< MapType >::startElement(), MzMLHandler< MapType >::startElement(), MzDataHandler< MapType >::startElement(), MzDataHandler< MapType >::writeCVS_(), MzXMLHandler< MapType >::writeTo(), MzMLHandler< MapType >::writeTo(), and MzDataHandler< MapType >::writeTo().
| void warning | ( | ActionMode | mode, | |
| const String & | msg, | |||
| UInt | line = 0, |
|||
| UInt | column = 0 | |||
| ) | const |
Warning handler.
| virtual void writeTo | ( | std::ostream & | ) | [inline, virtual] |
Writes the contents to a stream.
Reimplemented in MzDataHandler< MapType >, MzIdentMLHandler, MzMLHandler< MapType >, MzQuantMLHandler, MzXMLHandler< MapType >, PTMXMLHandler, ToolDescriptionHandler, and TraMLHandler.
| void writeUserParam_ | ( | const String & | tag_name, | |
| std::ostream & | os, | |||
| const MetaInfoInterface & | meta, | |||
| UInt | indent | |||
| ) | const [protected] |
Writes the content of MetaInfoInterface to the file.
Array of CV term lists (one sublist denotes one term and it's children).
Referenced by MzXMLHandler< MapType >::init_(), MzDataHandler< MapType >::init_(), MzDataHandler< MapType >::writeCVS_(), and MzXMLHandler< MapType >::writeTo().
String error_message_ [mutable, protected] |
Error message of the last error.
std::vector<String> open_tags_ [protected] |
Stack of open XML tags.
This member is used only in those XML parsers that need this information.
Referenced by MzXMLHandler< MapType >::characters(), MzMLHandler< MapType >::characters(), MzDataHandler< MapType >::characters(), MzDataHandler< MapType >::cvParam_(), MzXMLHandler< MapType >::endElement(), MzMLHandler< MapType >::endElement(), MzDataHandler< MapType >::endElement(), MzXMLHandler< MapType >::startElement(), MzMLHandler< MapType >::startElement(), and MzDataHandler< MapType >::startElement().
StringManager sm_ [protected] |
Helper class for string conversion.
Referenced by MzXMLHandler< MapType >::characters(), MzMLHandler< MapType >::characters(), MzDataHandler< MapType >::characters(), MzXMLHandler< MapType >::endElement(), MzMLHandler< MapType >::endElement(), MzDataHandler< MapType >::endElement(), MzXMLHandler< MapType >::startElement(), MzMLHandler< MapType >::startElement(), and MzDataHandler< MapType >::startElement().
Schema version.
Referenced by MzMLHandler< MapType >::startElement(), and MzMLHandler< MapType >::writeTo().
| OpenMS / TOPP release 1.10.0 | Documentation generated on Thu Mar 7 2013 09:43:00 using doxygen 1.7.1 |