XmlReader Class Reference
[Application XML system]

This class reads and parses XML. More...

#include <xmlreader.h>

Inheritance diagram for XmlReader:

Inheritance graph

List of all members.

Public Member Functions

 XmlReader (MessageLog *pLog=NULL, bool bValidate=true)
 ~XmlReader ()
XERCES_CPP_NAMESPACE_QUALIFIER
DOMDocument * 
parse (const Filename *pFn, std::string endTag="")
XERCES_CPP_NAMESPACE_QUALIFIER
DOMDocument * 
parse (std::string fn, std::string endTag="")
XERCES_CPP_NAMESPACE_QUALIFIER
DOMDocument * 
parseString (const std::string &str)
XERCES_CPP_NAMESPACE_QUALIFIER
DOMXPathResult * 
query (const std::string &expression, XERCES_CPP_NAMESPACE_QUALIFIER DOMXPathResult::ResultType type, bool reuse=true)

Static Public Member Functions

template<typename T, class B>
static void * StrToVector (const XMLCh *pStr)
template<typename T, class B>
static void StrToVector (typename std::vector< T > &vec, const XMLCh *pStr)
static bool StrToLocation (const XMLCh *pStr, LocationType &loc)
static void StrToQuadCoord (const XMLCh *pStr, double &a, double &b, double &c, double &d)

Classes

class  DomParseException
 An exception class representing an error or warning while parsing the DOM. More...
class  ParseStringAssigner
 Convert a const char * to another type. More...
class  StringAssigner
 Convert a const char * to another type. More...
class  StringStreamAssigner
 Convert a string to another type. More...
class  StringStreamAssigner< std::string >
 Convert a null-terminated char array to a std::string. More...
class  XmlReaderException
 An exception class representing an error or warning while reading and parsing. More...


Detailed Description

This class reads and parses XML.

requirements
Apache Xerces-C++ version 3.1.1

Definition at line 36 of file xmlreader.h.


Constructor & Destructor Documentation

XmlReader::XmlReader ( MessageLog pLog = NULL,
bool  bValidate = true 
)

Create an XmlReader.

Parameters:
pLog Optional MessageLog to be passed to XmlBase.
bValidate Should the XmlReader perform validation? It is strongly suggested that you always perform validation except when this is not possible. (such as during development, before XSD entries are made)

XmlReader::~XmlReader (  ) 

Destroy and cleanup the XmlReader object.


Member Function Documentation

XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* XmlReader::parse ( const Filename pFn,
std::string  endTag = "" 
)

Parse a file.

Parameters:
pFn The file to parse, as a Filename. Should not be NULL.
endTag If not empty, the parse will halt when this end tag is reached.
Returns:
The root element. Returns NULL for failure.

XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* XmlReader::parse ( std::string  fn,
std::string  endTag = "" 
)

Parse a file.

Parameters:
fn The file to parse, as a string.
endTag If not empty, the parse will halt when this end tag is reached.
Returns:
The root element. Returns NULL for failure.

XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* XmlReader::parseString ( const std::string &  str  ) 

Parse a string.

This method should not be used if validation has been enabled for this XmlReader.

Parameters:
str The string to parse.
Returns:
The root element. Returns NULL for failure.

XERCES_CPP_NAMESPACE_QUALIFIER DOMXPathResult* XmlReader::query ( const std::string &  expression,
XERCES_CPP_NAMESPACE_QUALIFIER DOMXPathResult::ResultType  type,
bool  reuse = true 
)

Perform an XPath query on the parsed document.

Parameters:
expression A valid XPath 2.0 expression.
type The type of result requested. Allowed values: DOMXPathResult::FIRST_RESULT_TYPE, DOMXPathResult::ITERATOR_RESULT_TYPE, or DOMXPathResult::SNAPSHOT_RESULT_TYPE.
reuse If this is true, the DOMXPathResult will be reused for each query. If this is false, a new result will be generated. If true, the XmlReader retains ownership of the result. If false, the caller takes ownership of the result.
Returns:
The result of the XPath query. NULL if the query failed or no document is loaded.

template<typename T, class B>
static void* XmlReader::StrToVector ( const XMLCh *  pStr  )  [static]

Convert a Unicode string to a vector of objects.

The Unicode string is tokenized using XML list tokenization and passed into a vector. The individual values are converted from the tokenized strings to T using the functor B.

Example:

    vector<int> *pIntVec(NULL);
    pIntVec = reinterpret_cast<vector<int>* >(StrToVector<int, StringStreamAssigner<int> >(X("1 2 3 4")));

Parameters:
pStr The Unicode string to parse.
Returns:
A pointer to a vector<T> which has been created with new. The caller takes ownership of this vector.

Definition at line 223 of file xmlreader.h.

template<typename T, class B>
static void XmlReader::StrToVector ( typename std::vector< T > &  vec,
const XMLCh *  pStr 
) [static]

Convert a Unicode string to a vector of objects.

The Unicode string is tokenized using XML list tokenization and passed into a vector. The individual values are converted from the tokenized strings to T using the functor B.

Example:

    vector<int> intVec;
    StrToVector<int,StringStreamAssigner<int> >(intVec, X("1 2 3 4")));

Parameters:
vec The vector to place the values in.
pStr The Unicode string to parse.

Definition at line 256 of file xmlreader.h.

static bool XmlReader::StrToLocation ( const XMLCh *  pStr,
LocationType loc 
) [static]

Convert a Unicode string to a LocationType.

The Unicode string is tokenized using XML list tokenization.

Parameters:
pStr The Unicode string to parse.
loc Output argument. The LocationType in which to store the result.

Definition at line 277 of file xmlreader.h.

static void XmlReader::StrToQuadCoord ( const XMLCh *  pStr,
double &  a,
double &  b,
double &  c,
double &  d 
) [static]

Convert a Unicode string to a quad coordinate.

The Unicode string is tokenized using XML list tokenization. The coordinate is represented by the four arguments a, b, c, and d. If fewer than four tokens are available, the remaining coordinate values are set to 0.0. This means, it is possible to parse 1, 2, 3 or 4, coordinate lists with the function.

Example:

     // Parse a quad coord
     {
       double a,b,c,d;
       StrToQuadCoord(X("1.2 3.4 5.6 7.8"), a, b, c, d);
     }

     // Now parse a tri coord
     {
       double r, g, b, dummy;
       StrToQuadCoord(X("12.4 44.0 16.85"), r, g, b, dummy);
     }

     // Finally, an example of parsing a double coord
     {
       double x, y, dummy;
       StrToQuadCoord(X("42.43 15.0"), x, y, dummy, dummy);
     }

Parameters:
pStr The Unicode string to parse.
a Output argument. The first part of the quad-coord.
b Output argument. The second part of the quad-coord.
c Output argument. The third part of the quad-coord.
d Output argument. The fourth part of the quad-coord.

Definition at line 336 of file xmlreader.h.


Software Development Kit - Opticks 4.9.0 Build 16218