te::xerces::Reader Class Reference

A class that models a XML reader object built on top of Xerces-C++. More...

#include <Reader.h>

Inheritance diagram for te::xerces::Reader:
te::xml::Reader

Public Member Functions

std::string getAttr (const std::string &name) const
 It returns the attribute value in the case of an element node with valid attributes. More...
 
std::string getAttr (std::size_t i) const
 It returns the attribute value in the case of an element node with valid attributes. More...
 
virtual double getAttrAsDouble (const std::string &name) const
 It returns the attribute value in the case of an element node with valid attributes. More...
 
virtual double getAttrAsDouble (std::size_t i) const
 It returns the attribute value in the case of an element node with valid attributes. More...
 
virtual boost::int32_t getAttrAsInt32 (const std::string &name) const
 It returns the attribute value in the case of an element node with valid attributes. More...
 
virtual boost::int32_t getAttrAsInt32 (std::size_t i) const
 It returns the attribute value in the case of an element node with valid attributes. More...
 
virtual boost::uint32_t getAttrAsUInt32 (std::size_t i) const
 It returns the attribute value in the case of an element node with valid attributes. More...
 
virtual boost::uint32_t getAttrAsUInt32 (const std::string name) const
 It returns the attribute value in the case of an element node with valid attributes. More...
 
std::string getAttrLocalName (std::size_t i) const
 It returns the local part of the attribute name for the i-th attribute. More...
 
std::size_t getAttrPosition (const std::string &name) const
 It returns the attribute position. More...
 
std::string getAttrQName (std::size_t i) const
 It returns the qualified name for the i-th attribute. More...
 
std::string getAttrURI (std::size_t i) const
 It returns the attribute URI of the associated namespace in the case of an element node. More...
 
std::size_t getElementDataLen () const
 It returns the element data value in the case of VALUE node. More...
 
std::string getElementLocalName () const
 It returns the local part of the element name in the case of an element node. More...
 
std::string getElementQName () const
 It returns the qualified name in the case of an element node. More...
 
std::string getElementURI () const
 It returns the URI of the associated namespace in the case of an element node. More...
 
std::string getElementValue () const
 It returns the element data value in the case of VALUE node. More...
 
virtual bool getElementValueAsBoolean () const
 It returns the element data value in the case of VALUE node. More...
 
virtual double getElementValueAsDouble () const
 It returns the element data value in the case of VALUE node. More...
 
virtual boost::int32_t getElementValueAsInt32 () const
 It returns the element data value in the case of VALUE node. More...
 
void getNamespace (std::size_t i, std::pair< std::string, std::string > &ns) const
 
te::xml::NodeType getNodeType () const
 It return the type of node read. More...
 
std::size_t getNumberOfAttrs () const
 It returns the number of attributes in the case of an element node. More...
 
std::size_t getNumberOfNamespaces () const
 
bool hasAttrs () const
 It tells if the element has attributes in the case of an element node. More...
 
bool next ()
 It gets the next event to be read. More...
 
void read (const std::string &fileURI)
 It prepare the given file to be read. More...
 
 Reader ()
 Default constructor. More...
 
void reset ()
 It resets the parser. More...
 
void setCacheGrammarFromParse (bool d)
 If true it caches the grammar in the pool for re-use in subsequent parses. More...
 
void setDoNamespaces (bool d)
 It enables or disables the parser namespace processing. More...
 
void setDoSchema (bool d)
 It enables or disables the parser schema processing. More...
 
void setIgnoreWhiteSpaces (bool d)
 If true the parser will ignore the white space characters. More...
 
void setInternalBufferSize (const std::size_t size)
 It sets the maximal allowed buffer size used for parsing. More...
 
void setUseCachedGrammarInParse (bool d)
 If true the reader will use cached grammar if it exists in the pool. More...
 
void setValidationScheme (bool d)
 If true the parser will perform a validation scheme. More...
 
 ~Reader ()
 Destructor. More...
 

Private Attributes

ErrorHandlerm_errH
 A pointer to an error handler. More...
 
bool m_ignoreWhiteSpaces
 A flag that indicates if the parser should ignore white spaces. More...
 
xercesc::SAX2XMLReader * m_parser
 A pointer to the parser used by the reader. More...
 
ReaderHandlerm_readerH
 A pointer to a content handler. More...
 
xercesc::XMLPScanToken * m_token
 This keeps the parser state. More...
 

Detailed Description

A class that models a XML reader object built on top of Xerces-C++.

This API is intend to simplify the task of reading XML files. We have tried to model it close to the Libxml2 API (see http://xmlsoft.org/xmlreader.html for more information) but keeping all Xerces-C++ support capabilities: schema validation and grammar cache.

If you prefer to use the SAX or DOM parsers, please, look the Xerces-C++ documentation available at http://xerces.apache.org/xerces-c.

Definition at line 66 of file Reader.h.

Constructor & Destructor Documentation

te::xerces::Reader::Reader ( )

Default constructor.

te::xerces::Reader::~Reader ( )
virtual

Destructor.

Reimplemented from te::xml::Reader.

Member Function Documentation

std::string te::xerces::Reader::getAttr ( const std::string &  name) const
virtual

It returns the attribute value in the case of an element node with valid attributes.

Parameters
nameThe attribute name.
Returns
The attribute value in the case of an element node with valid attributes.

Implements te::xml::Reader.

std::string te::xerces::Reader::getAttr ( std::size_t  i) const
virtual

It returns the attribute value in the case of an element node with valid attributes.

Parameters
iThe attribute position.
Returns
The attribute value in the case of an element node with valid attributes.

Implements te::xml::Reader.

virtual double te::xml::Reader::getAttrAsDouble ( const std::string &  name) const
virtualinherited

It returns the attribute value in the case of an element node with valid attributes.

Parameters
nameThe attribute name.
Returns
The attribute value in the case of an element node with valid attributes.
Note
Just call this method if you know that the attribute value can be converted to a double.
virtual double te::xml::Reader::getAttrAsDouble ( std::size_t  i) const
virtualinherited

It returns the attribute value in the case of an element node with valid attributes.

Parameters
iThe attribute position.
Returns
The attribute value in the case of an element node with valid attributes.
Note
Just call this method if you know that the attribute value can be converted to a double.
virtual boost::int32_t te::xml::Reader::getAttrAsInt32 ( const std::string &  name) const
virtualinherited

It returns the attribute value in the case of an element node with valid attributes.

Parameters
nameThe attribute name.
Returns
The attribute value in the case of an element node with valid attributes.
Note
Just call this method if you know that the attribute value can be converted to a 32-bit integer.
virtual boost::int32_t te::xml::Reader::getAttrAsInt32 ( std::size_t  i) const
virtualinherited

It returns the attribute value in the case of an element node with valid attributes.

Parameters
iThe attribute position.
Returns
The attribute value in the case of an element node with valid attributes.
Note
Just call this method if you know that the attribute value can be converted to a 32-bit integer.
virtual boost::uint32_t te::xml::Reader::getAttrAsUInt32 ( std::size_t  i) const
virtualinherited

It returns the attribute value in the case of an element node with valid attributes.

Parameters
iThe attribute position.
Returns
The attribute value in the case of an element node with valid attributes.
Note
Just call this method if you know that the attribute value can be converted to a 32-bit unsigned integer.
virtual boost::uint32_t te::xml::Reader::getAttrAsUInt32 ( const std::string  name) const
virtualinherited

It returns the attribute value in the case of an element node with valid attributes.

Parameters
nameThe attribute name.
Returns
The attribute value in the case of an element node with valid attributes.
Note
Just call this method if you know that the attribute value can be converted to a 32-bit unsigned integer.
std::string te::xerces::Reader::getAttrLocalName ( std::size_t  i) const
virtual

It returns the local part of the attribute name for the i-th attribute.

Parameters
iThe attribute position index.
Returns
The local part of the attribute name in the case of an element node.

Implements te::xml::Reader.

std::size_t te::xerces::Reader::getAttrPosition ( const std::string &  name) const
virtual

It returns the attribute position.

Parameters
nameThe attribute name.
Returns
The attribute position.

Implements te::xml::Reader.

std::string te::xerces::Reader::getAttrQName ( std::size_t  i) const
virtual

It returns the qualified name for the i-th attribute.

Parameters
iThe attribute position index.
Returns
The qualified attribute name in the case of an element node.

Implements te::xml::Reader.

std::string te::xerces::Reader::getAttrURI ( std::size_t  i) const
virtual

It returns the attribute URI of the associated namespace in the case of an element node.

Parameters
iThe attribute position index.
Returns
The attribute URI of the associated namespace in the case of an element node.

Implements te::xml::Reader.

std::size_t te::xerces::Reader::getElementDataLen ( ) const
virtual

It returns the element data value in the case of VALUE node.

Returns
The element data value in the case of VALUE node.
Note
Just call this method if you know that the element value can be converted to a bool.

It returns the element data value length in the case of VALUE or CDATA node.

Returns
The element data value in the case of VALUE or CDATA node.

Implements te::xml::Reader.

std::string te::xerces::Reader::getElementLocalName ( ) const
virtual

It returns the local part of the element name in the case of an element node.

Returns
The local part of the element name in the case of an element node.

Implements te::xml::Reader.

std::string te::xerces::Reader::getElementQName ( ) const
virtual

It returns the qualified name in the case of an element node.

Returns
The qualified name in the case of an element node.

Implements te::xml::Reader.

std::string te::xerces::Reader::getElementURI ( ) const
virtual

It returns the URI of the associated namespace in the case of an element node.

Returns
The URI of the associated namespace in the case of an element node.

Implements te::xml::Reader.

std::string te::xerces::Reader::getElementValue ( ) const
virtual

It returns the element data value in the case of VALUE node.

Returns
The element data value in the case of VALUE node.

Implements te::xml::Reader.

virtual bool te::xml::Reader::getElementValueAsBoolean ( ) const
virtualinherited

It returns the element data value in the case of VALUE node.

Returns
The element data value in the case of VALUE node.
Note
Just call this method if you know that the element value can be converted to a boolean.
virtual double te::xml::Reader::getElementValueAsDouble ( ) const
virtualinherited

It returns the element data value in the case of VALUE node.

Returns
The element data value in the case of VALUE node.
Note
Just call this method if you know that the element value can be converted to a double.
virtual boost::int32_t te::xml::Reader::getElementValueAsInt32 ( ) const
virtualinherited

It returns the element data value in the case of VALUE node.

Returns
The element data value in the case of VALUE node.
Note
Just call this method if you know that the element value can be converted to a 32-bit integer.
void te::xerces::Reader::getNamespace ( std::size_t  i,
std::pair< std::string, std::string > &  ns 
) const
virtual

Implements te::xml::Reader.

te::xml::NodeType te::xerces::Reader::getNodeType ( ) const
virtual

It return the type of node read.

Returns
The type of node read.

Implements te::xml::Reader.

std::size_t te::xerces::Reader::getNumberOfAttrs ( ) const
virtual

It returns the number of attributes in the case of an element node.

Returns
The number of attributes in the case of an element node.

Implements te::xml::Reader.

std::size_t te::xerces::Reader::getNumberOfNamespaces ( ) const
virtual

Implements te::xml::Reader.

bool te::xerces::Reader::hasAttrs ( ) const
virtual

It tells if the element has attributes in the case of an element node.

Returns
True if the element has attributes in the case of an element node, otherwise, false.

Implements te::xml::Reader.

bool te::xerces::Reader::next ( )
virtual

It gets the next event to be read.

Returns
True if an event was read otherwise false.
Exceptions
ExceptionIt throws an exception if something goes wrong during the text read.

Implements te::xml::Reader.

void te::xerces::Reader::read ( const std::string &  fileURI)
virtual

It prepare the given file to be read.

You must call read to start parsing the XML document.

Parameters
fileURIA path to a XML file or any URI where it can be found.
Exceptions
ExceptionIt throws an exception if the file doesn't exist or if the internal parser can not read it.

Implements te::xml::Reader.

void te::xerces::Reader::reset ( )

It resets the parser.

Exceptions
ExceptionIt throws an exception if it is not possible to reset the parser.
Note
Xerces extended method.
void te::xerces::Reader::setCacheGrammarFromParse ( bool  d)
virtual

If true it caches the grammar in the pool for re-use in subsequent parses.

Parameters
dIf If true it caches the grammar in the pool for re-use in subsequent parses.
Note
By default the reader is set to cache the grammar.

Implements te::xml::Reader.

void te::xerces::Reader::setDoNamespaces ( bool  d)
virtual

It enables or disables the parser namespace processing.

Parameters
dIf true the internal parser will perform the namespace processing otherwise this will not be done.
Note
By default the reader is set to do namespace processing.

Implements te::xml::Reader.

void te::xerces::Reader::setDoSchema ( bool  d)
virtual

It enables or disables the parser schema processing.

Parameters
dIf true the internal parser will perform the schema processing otherwise this will not be done.
Note
If set to true the namespace processing must also be turned on.
By default the reader is set to parser schema.

Implements te::xml::Reader.

void te::xerces::Reader::setIgnoreWhiteSpaces ( bool  d)
virtual

If true the parser will ignore the white space characters.

Parameters
dIf true the parser will ignore the white space characters.
Note
By default the reader is set to consider white spaces.

Implements te::xml::Reader.

void te::xerces::Reader::setInternalBufferSize ( const std::size_t  size)
virtual

It sets the maximal allowed buffer size used for parsing.

Parameters
sizeThe maximal allowed buffer size used for parsing.
Note
Default: 65536 bytes (64 kbytes), see the macro TE_XML_READER_MAX_BUFFSIZE.
The default value may be implementation dependent!

Implements te::xml::Reader.

void te::xerces::Reader::setUseCachedGrammarInParse ( bool  d)
virtual

If true the reader will use cached grammar if it exists in the pool.

Parameters
dIf true the reader will use cached grammar if it exists in the pool.
Note
By default the reader is set to use cached grammar.

Implements te::xml::Reader.

void te::xerces::Reader::setValidationScheme ( bool  d)
virtual

If true the parser will perform a validation scheme.

Parameters
dIf true the parser will perform a validation scheme.
Note
By default the reader is set to validate the scheme.

Implements te::xml::Reader.

Member Data Documentation

ErrorHandler* te::xerces::Reader::m_errH
private

A pointer to an error handler.

Definition at line 139 of file Reader.h.

bool te::xerces::Reader::m_ignoreWhiteSpaces
private

A flag that indicates if the parser should ignore white spaces.

Definition at line 141 of file Reader.h.

xercesc::SAX2XMLReader* te::xerces::Reader::m_parser
private

A pointer to the parser used by the reader.

Definition at line 137 of file Reader.h.

ReaderHandler* te::xerces::Reader::m_readerH
private

A pointer to a content handler.

Definition at line 138 of file Reader.h.

xercesc::XMLPScanToken* te::xerces::Reader::m_token
private

This keeps the parser state.

Definition at line 140 of file Reader.h.


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