A class that models a XML reader object built on top of Xerces-C++. More...
#include <Reader.h>
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 | |
| ErrorHandler * | m_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... | |
| ReaderHandler * | m_readerH |
| A pointer to a content handler. More... | |
| xercesc::XMLPScanToken * | m_token |
| This keeps the parser state. More... | |
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 xerces/Reader.h.
| te::xerces::Reader::Reader | ( | ) |
Default constructor.
Definition at line 46 of file xerces/Reader.cpp.
References m_errH, m_parser, m_readerH, and TE_XERCES_READER_MAX_BUFFSIZE.
|
virtual |
Destructor.
Reimplemented from te::xml::Reader.
Definition at line 70 of file xerces/Reader.cpp.
References m_errH, m_parser, m_readerH, m_token, reset(), and TE_LOG_ERROR.
|
virtual |
It returns the attribute value in the case of an element node with valid attributes.
| name | The attribute name. |
Implements te::xml::Reader.
Definition at line 260 of file xerces/Reader.cpp.
References te::xerces::ReaderHandler::getElementAttrs(), m_readerH, and te::xerces::ToString().
|
virtual |
It returns the attribute value in the case of an element node with valid attributes.
| i | The attribute position. |
Implements te::xml::Reader.
Definition at line 269 of file xerces/Reader.cpp.
References te::xerces::ReaderHandler::getElementAttrs(), m_readerH, and te::xerces::ToString().
|
virtualinherited |
It returns the attribute value in the case of an element node with valid attributes.
| name | The attribute name. |
Definition at line 69 of file xml/Reader.cpp.
References te::xml::Reader::getAttr().
Referenced by te::ws::ogc::wms::serialize::GetMapRequestReader(), te::serialize::xml::ReadBandProperty(), te::serialize::xml::ReadExtent(), and te::serialize::xml::ReadGeoTransform().
|
virtualinherited |
It returns the attribute value in the case of an element node with valid attributes.
| i | The attribute position. |
Definition at line 74 of file xml/Reader.cpp.
References te::xml::Reader::getAttr().
|
virtualinherited |
It returns the attribute value in the case of an element node with valid attributes.
| name | The attribute name. |
Definition at line 49 of file xml/Reader.cpp.
References te::xml::Reader::getAttr().
Referenced by te::ws::ogc::wms::serialize::GetMapRequestReader(), te::serialize::xml::ReadBandProperty(), te::serialize::xml::ReadLiteral(), and te::xsd::serialize::ReadOccurs().
|
virtualinherited |
It returns the attribute value in the case of an element node with valid attributes.
| i | The attribute position. |
Definition at line 54 of file xml/Reader.cpp.
References te::xml::Reader::getAttr().
|
virtualinherited |
It returns the attribute value in the case of an element node with valid attributes.
| i | The attribute position. |
Definition at line 59 of file xml/Reader.cpp.
References te::xml::Reader::getAttr().
Referenced by te::serialize::xml::ReadDataSetType().
|
virtualinherited |
It returns the attribute value in the case of an element node with valid attributes.
| name | The attribute name. |
Definition at line 64 of file xml/Reader.cpp.
References te::xml::Reader::getAttr().
|
virtual |
It returns the local part of the attribute name for the i-th attribute.
| i | The attribute position index. |
Implements te::xml::Reader.
Definition at line 279 of file xerces/Reader.cpp.
References te::xerces::ReaderHandler::getElementAttrs(), m_readerH, and te::xerces::ToString().
|
virtual |
It returns the attribute position.
| name | The attribute name. |
Implements te::xml::Reader.
Definition at line 309 of file xerces/Reader.cpp.
References te::xerces::ReaderHandler::getElementAttrs(), and m_readerH.
|
virtual |
It returns the qualified name for the i-th attribute.
| i | The attribute position index. |
Implements te::xml::Reader.
Definition at line 289 of file xerces/Reader.cpp.
References te::xerces::ReaderHandler::getElementAttrs(), m_readerH, and te::xerces::ToString().
|
virtual |
It returns the attribute URI of the associated namespace in the case of an element node.
| i | The attribute position index. |
Implements te::xml::Reader.
Definition at line 299 of file xerces/Reader.cpp.
References te::xerces::ReaderHandler::getElementAttrs(), m_readerH, and te::xerces::ToString().
|
virtual |
It returns the element data value in the case of VALUE node.
It returns the element data value length in the case of VALUE or CDATA node.
Implements te::xml::Reader.
Definition at line 245 of file xerces/Reader.cpp.
References te::xerces::ReaderHandler::getDataLen(), and m_readerH.
|
virtual |
It returns the local part of the element name in the case of an element node.
Implements te::xml::Reader.
Definition at line 230 of file xerces/Reader.cpp.
References te::xerces::ReaderHandler::getElementLocalName(), m_readerH, and te::xerces::ToString().
|
virtual |
It returns the qualified name in the case of an element node.
Implements te::xml::Reader.
Definition at line 235 of file xerces/Reader.cpp.
References te::xerces::ReaderHandler::getElementQName(), m_readerH, and te::xerces::ToString().
|
virtual |
It returns the URI of the associated namespace in the case of an element node.
Implements te::xml::Reader.
Definition at line 225 of file xerces/Reader.cpp.
References te::xerces::ReaderHandler::getElementURI(), m_readerH, and te::xerces::ToString().
|
virtual |
It returns the element data value in the case of VALUE node.
Implements te::xml::Reader.
Definition at line 240 of file xerces/Reader.cpp.
References te::xerces::ReaderHandler::getElementValue(), m_readerH, and te::xerces::ToString().
|
virtualinherited |
It returns the element data value in the case of VALUE node.
Definition at line 42 of file xml/Reader.cpp.
References te::xml::Reader::getElementValue().
Referenced by te::map::serialize::ReadLayerChart(), te::se::serialize::ReadLinePlacement(), and te::se::serialize::ReadShadedRelief().
|
virtualinherited |
It returns the element data value in the case of VALUE node.
Definition at line 37 of file xml/Reader.cpp.
References te::xml::Reader::getElementValue().
Referenced by te::se::serialize::ReadContrastEnhancement(), te::se::serialize::ReadInterpolationPoint(), te::map::serialize::ReadLayerChart(), te::map::serialize::ReadLayerGrouping(), te::map::serialize::ReadLayerRasterContrast(), te::se::serialize::ReadMapItem(), te::se::serialize::ReadRule(), and te::se::serialize::ReadShadedRelief().
|
virtualinherited |
It returns the element data value in the case of VALUE node.
Definition at line 32 of file xml/Reader.cpp.
References te::xml::Reader::getElementValue().
Referenced by DataSetAdapterLayerReader(), DataSetLayerReader(), te::wms::serialize::LayerReader(), te::ws::ogc::wms::serialize::LayerReader(), QueryLayerReader(), RasterLayerReader(), te::serialize::xml::ReadGrid(), te::map::serialize::ReadLayerChart(), te::map::serialize::ReadLayerGrouping(), te::map::serialize::ReadLayerRasterContrast(), and te::map::serialize::ReadSRIDValue().
|
virtual |
Implements te::xml::Reader.
Definition at line 321 of file xerces/Reader.cpp.
References te::xerces::ReaderHandler::getNamespace(), m_readerH, and te::xerces::ToString().
|
virtual |
It return the type of node read.
Implements te::xml::Reader.
Definition at line 220 of file xerces/Reader.cpp.
References te::xerces::ReaderHandler::getNodeType(), and m_readerH.
Referenced by next().
|
virtual |
It returns the number of attributes in the case of an element node.
Implements te::xml::Reader.
Definition at line 255 of file xerces/Reader.cpp.
References te::xerces::ReaderHandler::getElementAttrs(), hasAttrs(), and m_readerH.
|
virtual |
Implements te::xml::Reader.
Definition at line 316 of file xerces/Reader.cpp.
References te::xerces::ReaderHandler::getNumberOfNamespaces(), and m_readerH.
|
virtual |
It tells if the element has attributes in the case of an element node.
Implements te::xml::Reader.
Definition at line 250 of file xerces/Reader.cpp.
References te::xerces::ReaderHandler::getElementAttrs(), and m_readerH.
Referenced by getNumberOfAttrs().
|
virtual |
It gets the next event to be read.
| Exception | It throws an exception if something goes wrong during the text read. |
Implements te::xml::Reader.
Definition at line 162 of file xerces/Reader.cpp.
References te::xml::END_ELEMENT, te::xerces::ErrorHandler::getErrors(), getNodeType(), te::xerces::ReaderHandler::getNodeType(), te::xerces::ReaderHandler::isInContractedForm(), m_errH, m_ignoreWhiteSpaces, m_parser, m_readerH, m_token, te::xerces::ReaderHandler::reset(), te::xerces::ReaderHandler::setInContractedForm(), te::xerces::ReaderHandler::setNodeType(), te::xml::START_ELEMENT, TE_TR, te::xerces::ToString(), te::xml::UNKNOWN, and te::xml::WHITESPACE.
Referenced by read().
|
virtual |
It prepare the given file to be read.
You must call read to start parsing the XML document.
| fileURI | A path to a XML file or any URI where it can be found. |
| Exception | It throws an exception if the file doesn't exist or if the internal parser can not read it. |
Implements te::xml::Reader.
Definition at line 117 of file xerces/Reader.cpp.
References file(), te::core::CharEncoding::fromUTF8(), te::xerces::ErrorHandler::getErrors(), te::xerces::ReaderHandler::getNodeType(), m_parser, m_readerH, m_token, next(), reset(), TE_TR, te::xerces::ToString(), and te::xml::UNKNOWN.
| void te::xerces::Reader::reset | ( | ) |
It resets the parser.
| Exception | It throws an exception if it is not possible to reset the parser. |
Definition at line 334 of file xerces/Reader.cpp.
References m_parser, m_token, TE_TR, and te::xerces::ToString().
|
virtual |
If true it caches the grammar in the pool for re-use in subsequent parses.
| d | If If true it caches the grammar in the pool for re-use in subsequent parses. |
Implements te::xml::Reader.
Definition at line 107 of file xerces/Reader.cpp.
References m_parser.
|
virtual |
It enables or disables the parser namespace processing.
| d | If true the internal parser will perform the namespace processing otherwise this will not be done. |
Implements te::xml::Reader.
Definition at line 87 of file xerces/Reader.cpp.
References m_parser.
|
virtual |
It enables or disables the parser schema processing.
| d | If true the internal parser will perform the schema processing otherwise this will not be done. |
Implements te::xml::Reader.
Definition at line 92 of file xerces/Reader.cpp.
References m_parser.
|
virtual |
If true the parser will ignore the white space characters.
| d | If true the parser will ignore the white space characters. |
Implements te::xml::Reader.
Definition at line 112 of file xerces/Reader.cpp.
References d, and m_ignoreWhiteSpaces.
|
virtual |
It sets the maximal allowed buffer size used for parsing.
| size | The maximal allowed buffer size used for parsing. |
Implements te::xml::Reader.
Definition at line 329 of file xerces/Reader.cpp.
References m_parser.
|
virtual |
If true the reader will use cached grammar if it exists in the pool.
| d | If true the reader will use cached grammar if it exists in the pool. |
Implements te::xml::Reader.
Definition at line 102 of file xerces/Reader.cpp.
References m_parser.
|
virtual |
If true the parser will perform a validation scheme.
| d | If true the parser will perform a validation scheme. |
Implements te::xml::Reader.
Definition at line 97 of file xerces/Reader.cpp.
References m_parser.
|
private |
A pointer to an error handler.
Definition at line 139 of file xerces/Reader.h.
|
private |
A flag that indicates if the parser should ignore white spaces.
Definition at line 141 of file xerces/Reader.h.
Referenced by next(), and setIgnoreWhiteSpaces().
|
private |
A pointer to the parser used by the reader.
Definition at line 137 of file xerces/Reader.h.
Referenced by next(), read(), Reader(), reset(), setCacheGrammarFromParse(), setDoNamespaces(), setDoSchema(), setInternalBufferSize(), setUseCachedGrammarInParse(), setValidationScheme(), and ~Reader().
|
private |
A pointer to a content handler.
Definition at line 138 of file xerces/Reader.h.
Referenced by getAttr(), getAttrLocalName(), getAttrPosition(), getAttrQName(), getAttrURI(), getElementDataLen(), getElementLocalName(), getElementQName(), getElementURI(), getElementValue(), getNamespace(), getNodeType(), getNumberOfAttrs(), getNumberOfNamespaces(), hasAttrs(), next(), read(), Reader(), and ~Reader().
|
private |