Fluid Dynamics Library
Public Member Functions | Protected Attributes
fdl::XmlParser Class Reference

Lightweight XML parser class. More...

#include <xmlparser.h>

List of all members.

Public Member Functions

 XmlParser (const char *filename) throw (std::invalid_argument)
 XmlParser (TiXmlNode *root)
 operator TiXmlElement * ()
 The class itself can be treated as an XML node.
 operator const TiXmlElement * () const
 The class itself can be treated as an XML node.
std::string getRootName ()
 Returns the tag name of the "root" node.
bool hasChild (const char *tag)
 Test whether child element exists.
TiXmlElement * getChild (const char *tag) throw (std::invalid_argument)
 Get child element with given tag; thow an exception if not present.
bool getField (const char *childTag, std::string &value)
 Extract the text field of an XML element; returns true on success.
bool getField (const char *childTag, int &value)
 Extract the integer value of an XML element field.
bool getField (const char *childTag, float &value)
 Extract the float value of an XML element field.
bool getField (const char *childTag, double &value)
 Extract the double value of an XML element field.
bool getAttrib (const char *childTag, const char *attribName, int &value)
 Extract value of an integer attribute; returns true if it exists.
bool getAttrib (const char *childTag, const char *attribName, float &value)
 Extract value of a float attribute; returns true if it exists.
bool getAttrib (const char *childTag, const char *attribName, double &value)
 Extract value of a double attribute; returns true if it exists.
bool getAttrib (const char *childTag, const char *attribName, std::string &value)
 Extract value of a "text" attribute; returns true if it exists.
bool getAttribArray (const char *childTag, unsigned dim, const char **attribNames, int *values)
 Extract an array of integer values; returns true on success.
bool getAttribArray (const char *childTag, unsigned dim, const char **attribNames, float *values)
 Extract an array of float values; returns true on success.
bool getAttribArray (const char *childTag, unsigned dim, const char **attribNames, double *values)
 Extract an array of double values; returns true on success.

Protected Attributes

std::stringstream errBffr_
TiXmlElement * root_
TiXmlDocument doc_

Detailed Description

Lightweight XML parser class.

The class provides a simplified interface for the TinyXML library focused on specific needs in scientific computing. It assumes that the XML data has a tree structure like:

 <Root>
   <Child>
      <SubChild>Text</SubChild>
      <SubChild attrib1="3.0" attrib2="0.14">
      ...
   </Child>
 ...
 </Root>
 

Member functions provided focus on the following specific tasks:

Definition at line 52 of file xmlparser.h.


The documentation for this class was generated from the following files: