Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
Teuchos::XMLParser Class Reference

XMLParser consumes characters from an XMLInputStream object, parsing the XML and using a TreeBuildingXMLHandler to construct an XMLObject. More...

#include <Teuchos_XMLParser.hpp>

Public Member Functions

 XMLParser (RCP< XMLInputStream > is)
 Constructor. More...
 
 ~XMLParser ()
 Destructor. More...
 
XMLObject parse ()
 Consume the XMLInputStream to build an XMLObject. More...
 

Private Member Functions

void getETag (std::string &tag)
 Consume a ETag production according to the XML specification. getETag throws an std::exception if the input does not match the production rule. More...
 
void getSTag (unsigned char lookahead, std::string &tag, Teuchos::map< std::string, string > &attrs, bool &emptytag)
 Consume a STag production according to the XML specification. getSTag throws an std::exception if the input does not match the production rule. More...
 
void getComment (long startLine)
 Consume a Comment production according to the XML specification. getComment throws an std::exception if the input does not match the production rule. More...
 
int getSpace (unsigned char &lookahead)
 Consumes a Space (block of whitepace) production according to the XML specification. More...
 
void getReference (std::string &refstr)
 Consumes a Reference production according to the XML specification. More...
 
void ignoreXMLDeclaration ()
 Ignore the rest of an XML declaration tag. More...
 
int assertChar (unsigned char cexp)
 Determines if the next character on the stream. More...
 

Static Private Member Functions

static bool isLetter (unsigned char c)
 Determine whether c matches the Letter production according to the XML specification. More...
 
static bool isNameChar (unsigned char c)
 Determine whether c matches the NameChar production according to the XML specification. More...
 
static bool isChar (unsigned char c)
 Determine whether c matches the Char production according to the XML specification. More...
 
static bool isSpace (unsigned char c)
 Determine whether c matches the Space production according to the XML specification. More...
 

Private Attributes

RCP< XMLInputStream_is
 
Teuchos::map< std::string, string > _entities
 
long _lineNo
 

Detailed Description

XMLParser consumes characters from an XMLInputStream object, parsing the XML and using a TreeBuildingXMLHandler to construct an XMLObject.

Note: per the XML standard, certain characters must be represented with escape codes within fields:

     character            description             code
         <                 less-than              &lt;
         &                 ampersand              &amp;

Definition at line 38 of file Teuchos_XMLParser.hpp.

Constructor & Destructor Documentation

Teuchos::XMLParser::XMLParser ( RCP< XMLInputStream is)
inline

Constructor.

Definition at line 43 of file Teuchos_XMLParser.hpp.

Teuchos::XMLParser::~XMLParser ( )
inline

Destructor.

Definition at line 46 of file Teuchos_XMLParser.hpp.

Member Function Documentation

XMLObject XMLParser::parse ( )

Consume the XMLInputStream to build an XMLObject.

Definition at line 105 of file Teuchos_XMLParser.cpp.

bool XMLParser::isLetter ( unsigned char  c)
inlinestaticprivate

Determine whether c matches the Letter production according to the XML specification.

Definition at line 524 of file Teuchos_XMLParser.cpp.

bool XMLParser::isNameChar ( unsigned char  c)
inlinestaticprivate

Determine whether c matches the NameChar production according to the XML specification.

Definition at line 535 of file Teuchos_XMLParser.cpp.

bool XMLParser::isChar ( unsigned char  c)
inlinestaticprivate

Determine whether c matches the Char production according to the XML specification.

Definition at line 554 of file Teuchos_XMLParser.cpp.

bool XMLParser::isSpace ( unsigned char  c)
inlinestaticprivate

Determine whether c matches the Space production according to the XML specification.

Definition at line 545 of file Teuchos_XMLParser.cpp.

void XMLParser::getETag ( std::string &  tag)
private

Consume a ETag production according to the XML specification. getETag throws an std::exception if the input does not match the production rule.

Parameters
tag[out] On output, will be set to the tag name of the closing tag.

Definition at line 228 of file Teuchos_XMLParser.cpp.

void XMLParser::getSTag ( unsigned char  lookahead,
std::string &  tag,
Teuchos::map< std::string, string > &  attrs,
bool &  emptytag 
)
private

Consume a STag production according to the XML specification. getSTag throws an std::exception if the input does not match the production rule.

Parameters
lookahead[in] Contains the first character of the tag name.
tag[out] On output, will be set to the tag name of the opening tag.
attrs[out] On output, contains the attributes of the tag.
emptytag[out] On output, specifies if this was an empty element tag.

Definition at line 268 of file Teuchos_XMLParser.cpp.

void XMLParser::getComment ( long  startLine)
private

Consume a Comment production according to the XML specification. getComment throws an std::exception if the input does not match the production rule.

Definition at line 413 of file Teuchos_XMLParser.cpp.

int XMLParser::getSpace ( unsigned char &  lookahead)
private

Consumes a Space (block of whitepace) production according to the XML specification.

Parameters
lookahead[out] On output, specifies the first character after the whitespace.
Returns
Returns non-zero if the input stream was exhausted while reading whitespace.

Definition at line 511 of file Teuchos_XMLParser.cpp.

void XMLParser::getReference ( std::string &  refstr)
private

Consumes a Reference production according to the XML specification.

Parameters
refstr[out] On output, specifies the decoded reference.

Definition at line 447 of file Teuchos_XMLParser.cpp.

void XMLParser::ignoreXMLDeclaration ( )
private

Ignore the rest of an XML declaration tag.

Definition at line 577 of file Teuchos_XMLParser.cpp.

int XMLParser::assertChar ( unsigned char  cexp)
private

Determines if the next character on the stream.

Parameters
cexp[in] The expected character.
Returns
Returns non-zero if the next character on the stream is not cexp.

Definition at line 562 of file Teuchos_XMLParser.cpp.

Member Data Documentation

RCP<XMLInputStream> Teuchos::XMLParser::_is
private

Definition at line 56 of file Teuchos_XMLParser.hpp.

Teuchos::map<std::string,string> Teuchos::XMLParser::_entities
private

Definition at line 57 of file Teuchos_XMLParser.hpp.

long Teuchos::XMLParser::_lineNo
private

Definition at line 58 of file Teuchos_XMLParser.hpp.


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