Open PaperOpt
IO::XMLParser Class Reference

#include <XMLParser.h>

List of all members.

Public Member Functions

 XMLParser ()
 ~XMLParser ()
void init (string xmlFile)
bool readNextTag ()
string getNextText (void)
string getElementName ()
void pushEndTag (string s)
void popEndTag ()
string getAttribute (string s)
float getAttributeAsFloat (string s)
int getAttributeAsInt (string s)
bool isCurElement (char *elm)
Array2D< float > * parseFloatArray ()
Array2D< float > * parseHeightMap (float &sizeX, float &sizeY)
Array2D< V2< float > > * parseV2FloatArray ()
Array2D< V3< float > > * parseV3FloatArray ()
int parseFloatList (vector< float > &list)
float parseFloat ()
int parseInt ()
bool parseBool ()
string parseString ()
DistributionparseDistribution ()
DistributionTableparseTableDistribution ()
DistributionEllipticparseEllipticDistribution ()
DistributionConstantparseConstantDistribution ()
DistributionComponentsparseComponentsDistribution ()
ScatteringParametersparseScatteringProperties (vector< float > &rLambda)
FluorescenceparseFluorescence (vector< float > &rLambda)
reflectanceParametersparseReflectance (vector< float > &rLambda)
XMLParser::BinaryFile * parseBinaryFile ()
XMLParser::TextFile * parseTextFile ()

Detailed Description

This class implements an XML pull parser. It is built on top of irrXML. Functions are provided to get the next element (skipping end tags, comments etc) and for parsing some of the basic types defined in the XML Schema.

A stack mechanism is used to prevent functions from reading beyond an endtag. Before a function handling an element is called, the tag name is pushed onto the stack. when the function returns the tag name is popped.

Author:
Mikael Lindquister
Version:
2009-01-21

Constructor & Destructor Documentation

XMLParser::XMLParser ( )

Constructor

XMLParser::~XMLParser ( )

Destructor


Member Function Documentation

string XMLParser::getAttribute ( string  s)

Gets an attribute of the current element. Note that any namespace declarations in the attribute are not considered a part of the attribute name.

I.e. getAttribute("type") will return the correct value even if the attribute is really called "xsi:type" or "asd:type" etc.

Parameters:
sname of the attribute to be returned.
Returns:
the value of the attribute.
float XMLParser::getAttributeAsFloat ( string  s)

Gets an attribute of the current element as a float.

Parameters:
sname of the attribute to be returned.
Returns:
the value of the attribute.
Exceptions:
anexception if the attribute does not exist or if it could not be read.

Here is the caller graph for this function:

int XMLParser::getAttributeAsInt ( string  s)

Gets an attribute of the current element.

Parameters:
sname of the attribute to be returned.
Returns:
the value of the attribute. Returns 0 if the attribute does not exist.
string XMLParser::getElementName ( )

This method will return the name of the current tag.

Returns:
the name of the current tag.
string XMLParser::getNextText ( void  )

This method is used to parse the text between a start tag and an end tag. This method should only be called if it is known that there is a text node after the tag the parses is currently at.

Returns:
the text or NULL if the next node was not a text node.
void XMLParser::init ( string  xmlFile)

This method initiates the XMLParser and should be called before using it.

Parameters:
xmlFilename of the XML file.
bool XMLParser::isCurElement ( char *  elm)

Used to check which element the parser is at.

Parameters:
elmthe name of the element to be checked against current.
Returns:
true if the current element is elm false if not.
BinaryFile * XMLParser::parseBinaryFile ( )

Parses a binaryFile element.

Returns:
pointer to a new BinaryFile object.
bool XMLParser::parseBool ( )

Parses a bool element.

Returns:
the value of the "value" attribute.
DistributionComponents * XMLParser::parseComponentsDistribution ( )

Parses an componentsDistribution element.

Returns:
a pointer to a newly created DistributionComponents object.

Here is the call graph for this function:

DistributionConstant * XMLParser::parseConstantDistribution ( )

Parses a constantDistribution element.

Returns:
a pointer to an DistributionConstant object.
Distribution * XMLParser::parseDistribution ( )

Parses a tableDistribution,ellipticDistribution, constantDistribution

Returns:
a pointer to an instance of a subclass of Distribution.
DistributionElliptic * XMLParser::parseEllipticDistribution ( )

Parses an ellipticDistribution element.

Returns:
a pointer to an DistributionElliptic object.
float XMLParser::parseFloat ( )

Parses a float element.

Returns:
the value of the "value" attribute.
Array2D< float > * XMLParser::parseFloatArray ( )

Parses an floatArray element.

Returns:
pointer to an Array2D<float> object that contains the array data.

Here is the call graph for this function:

int XMLParser::parseFloatList ( vector< float > &  list)

Parses a floatList element.

Parameters:
listreference to the vector<float> where the values will be put.
Fluorescence * XMLParser::parseFluorescence ( vector< float > &  rLambda)

Parses a fluorescence element.

Parameters:
rLambdathe simulation wavelengths.
Returns:
pointer to a new Fluorescence object.

Here is the call graph for this function:

Array2D< float > * XMLParser::parseHeightMap ( float &  sizeX,
float &  sizeY 
)

Parses a heightMap element.

Parameters:
sizeXpointer to a float that will be set to the size of the surface in X dir.
sizeYpointer to a float that will be set to the size of the surface in Y dir.
Returns:
pointer to an Array2D<float> object that contains the topograpghy.
int XMLParser::parseInt ( )

Parses an int element.

Returns:
the value of the "value" attribute.
reflectanceParameters * XMLParser::parseReflectance ( vector< float > &  rLambda)

Parses a reflectance element.

Parameters:
rLambdathe simulation wavelengths.
Returns:
pointer to a new reflectance object.
ScatteringParameters * XMLParser::parseScatteringProperties ( vector< float > &  rLambda)

Parses a scatteringProperties element.

Returns:
a pointer to ScatteringParameters object.
string XMLParser::parseString ( )

Parses a string element.

Returns:
the value of the "value" attribute of the string element.
DistributionTable * XMLParser::parseTableDistribution ( )

Parses a tableDistribution element.

Returns:
a pointer to an DistributionTable object.

Here is the call graph for this function:

TextFile * XMLParser::parseTextFile ( )

Parses a textFile element.

Returns:
pointer to a new TextFile object.
Array2D< V2< float > > * XMLParser::parseV2FloatArray ( )

Parses a V2FloatArray element.

Returns:
pointer to an Array2D<V2<float>> object.

Here is the call graph for this function:

Array2D< V3< float > > * XMLParser::parseV3FloatArray ( )

Parses a V3FloatArray element.

Returns:
pointer to an Array2D<V3<float>> object.

Here is the call graph for this function:

void IO::XMLParser::popEndTag ( ) [inline]

Pops the tag that is on top of the stack.

Here is the caller graph for this function:

void IO::XMLParser::pushEndTag ( string  s) [inline]

Pushes a new end tag on the stack.

Parameters:
sname of the tag that will be pushed on the stack.

Here is the caller graph for this function:

bool XMLParser::readNextTag ( )

Advances the parser to the next start tag, skipping comments and end tags. Will return false if it has reached the current endTag or if end of file has been reached.

Returns:
true if there was another tag or false if there was not.

Here is the caller graph for this function:


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