Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions

XMLHandler Class Reference

Base class for XML handlers. More...

#include <OpenMS/FORMAT/HANDLERS/XMLHandler.h>

Inheritance diagram for XMLHandler:
DefaultHandler ConsensusXMLFile CVMappingFile FeatureXMLFile IdXMLFile MascotXMLHandler MzDataHandler< MapType > MzIdentMLHandler MzMLHandler< MapType > MzQuantMLHandler MzXMLHandler< MapType > ParamXMLHandler PTMXMLHandler SemanticValidator TraMLHandler UnimodXMLHandler XTandemInfileXMLHandler OMSSAXMLFile PepXMLFile PepXMLFileMascot ProtXMLFile QcMLFile TransformationXMLFile XTandemXMLFile

List of all members.

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

These methods forward the error message to our own error handlers below.

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< Stringopen_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)

Detailed Description

Base class for XML handlers.


Member Enumeration Documentation

enum ActionMode

Action to set the current mode (for error messages).

Enumerator:
LOAD 

Loading a file.

STORE 

Storing a file.


Constructor & Destructor Documentation

XMLHandler ( const String filename,
const String version 
)

Default constructor.

virtual ~XMLHandler (  )  [virtual]

Destructor.

XMLHandler (  )  [private]

Not implemented.


Member Function Documentation

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.

DateTime asDateTime_ ( String  date_string  )  [inline, protected]
double asDouble_ ( const String in  )  [inline, protected]
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.

Int asInt_ ( const String in  )  [inline, protected]

Conversion of a String to an integer value.

References String::toInt().

Referenced by MzDataHandler< MapType >::cvParam_().

UInt asUInt_ ( const String in  )  [inline, protected]

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]
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]
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]
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]
bool equal_ ( const XMLCh *  a,
const XMLCh *  b 
) [inline, protected]
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]
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  ) 
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.

Returns:
if the attribute was 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.

Returns:
if the attribute was 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.

Returns:
if the attribute was 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.

Returns:
if the attribute was 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.

Returns:
if the attribute was 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.

Returns:
if the attribute was 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.

Returns:
if the attribute was 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.

Returns:
if the attribute was 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.

Returns:
if the attribute was 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.

Returns:
if the attribute was 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]
void warning ( ActionMode  mode,
const String msg,
UInt  line = 0,
UInt  column = 0 
) const

Warning handler.

virtual void writeTo ( std::ostream &   )  [inline, virtual]
void writeUserParam_ ( const String tag_name,
std::ostream &  os,
const MetaInfoInterface meta,
UInt  indent 
) const [protected]

Writes the content of MetaInfoInterface to the file.


Member Data Documentation

std::vector<std::vector<String> > cv_terms_ [protected]

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.

String file_ [protected]

File name.


OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:43:00 using doxygen 1.7.1