Eclipse SUMO - Simulation of Urban MObility
|
SAX-reader encapsulation containing binary reader. More...
#include <SUMOSAXReader.h>
Data Structures | |
class | LocalSchemaResolver |
Local Schema Resolver. More... | |
Public Member Functions | |
void | parse (std::string systemID) |
Parse the given file completely by calling parse of myXMLReader. | |
bool | parseFirst (std::string systemID) |
Start parsing the given file using parseFirst of myXMLReader. | |
bool | parseNext () |
Continue a progressive parse started by parseFirst. | |
bool | parseSection (SumoXMLTag element) |
Continue a progressive parse started by parseFirst until the given element is encountered. | |
void | parseString (std::string content) |
Parse XML from the given string. | |
void | setHandler (GenericSAXHandler &handler) |
Sets the given handler as content and error handler for the reader. | |
void | setValidation (std::string validationScheme="") |
Sets a new validation scheme and applies the validation settings to the XML reader. | |
SUMOSAXReader (GenericSAXHandler &handler, const std::string &validationScheme, XERCES_CPP_NAMESPACE::XMLGrammarPool *grammarPool) | |
Constructor. | |
~SUMOSAXReader () | |
Destructor. | |
Private Member Functions | |
void | ensureSAXReader () |
Builds a reader, if needed. | |
const SUMOSAXReader & | operator= (const SUMOSAXReader &s)=delete |
invalidated assignment operator | |
SUMOSAXReader (const SUMOSAXReader &s)=delete | |
invalidated copy constructor | |
Private Attributes | |
XERCES_CPP_NAMESPACE::XMLGrammarPool * | myGrammarPool |
Schema cache to be used for grammars which are not declared. | |
GenericSAXHandler * | myHandler |
generic SAX Handler | |
std::unique_ptr< IStreamInputSource > | myInputStream |
input stream | |
std::unique_ptr< std::istream > | myIStream |
istream | |
LocalSchemaResolver | myLocalResolver |
local resolver | |
std::pair< int, SUMOSAXAttributes * > | myNextSection |
next section | |
LocalSchemaResolver | myNoOpResolver |
no operation resolver | |
LocalSchemaResolver | mySchemaResolver |
schema resolver | |
XERCES_CPP_NAMESPACE::XMLPScanToken | myToken |
token | |
std::string | myValidationScheme |
Information whether built reader/parser shall validate XML-documents against schemata. | |
XERCES_CPP_NAMESPACE::SAX2XMLReader * | myXMLReader |
XML reader. | |
std::vector< SumoXMLTag > | myXMLStack |
The stack of begun xml elements. | |
SAX-reader encapsulation containing binary reader.
This class generates on demand either a SAX2XMLReader or parses the SUMO binary xml. The interface is inspired by but not identical to SAX2XMLReader.
Definition at line 53 of file SUMOSAXReader.h.
SUMOSAXReader::SUMOSAXReader | ( | GenericSAXHandler & | handler, |
const std::string & | validationScheme, | ||
XERCES_CPP_NAMESPACE::XMLGrammarPool * | grammarPool | ||
) |
Constructor.
[in] | file | The name of the processed file |
Definition at line 50 of file SUMOSAXReader.cpp.
References setHandler().
SUMOSAXReader::~SUMOSAXReader | ( | ) |
Destructor.
Definition at line 65 of file SUMOSAXReader.cpp.
References myNextSection, and myXMLReader.
|
privatedelete |
invalidated copy constructor
|
private |
Builds a reader, if needed.
Tries to build a SAX2XMLReader using XMLReaderFactory::createXMLReader, if no reader has been created yet. If this fails, a ProcessError is thrown. Otherwise the validation is set matching the value of "myValidationScheme". If validation is not wanted, a WFXMLScanner is used (see http://www.ibm.com/developerworks/library/x-xercesperf.html).
Definition at line 192 of file SUMOSAXReader.cpp.
References myGrammarPool, myHandler, myXMLReader, setValidation(), and TL.
Referenced by parse(), parseFirst(), and parseString().
|
privatedelete |
invalidated assignment operator
void SUMOSAXReader::parse | ( | std::string | systemID | ) |
Parse the given file completely by calling parse of myXMLReader.
This throws a ProcessError if the file is not readable and can handle gzipped XML as well.
[in] | systemID | file name |
Definition at line 108 of file SUMOSAXReader.cpp.
References ensureSAXReader(), FileHelpers::isDirectory(), FileHelpers::isReadable(), myXMLReader, TLF, and StringUtils::transcodeToLocal().
bool SUMOSAXReader::parseFirst | ( | std::string | systemID | ) |
Start parsing the given file using parseFirst of myXMLReader.
[in] | systemID | file name |
Definition at line 134 of file SUMOSAXReader.cpp.
References ensureSAXReader(), FileHelpers::isDirectory(), FileHelpers::isReadable(), myInputStream, myIStream, myToken, myXMLReader, TLF, and StringUtils::transcodeToLocal().
Referenced by MSStateHandler::MSStateTimeHandler::getTime(), MSDevice_FCDReplay::init(), PCNetProjectionLoader::load(), and SUMORouteLoader::SUMORouteLoader().
bool SUMOSAXReader::parseNext | ( | ) |
Continue a progressive parse started by parseFirst.
Definition at line 154 of file SUMOSAXReader.cpp.
References myToken, myXMLReader, and TL.
Referenced by MSStateHandler::MSStateTimeHandler::getTime(), PCNetProjectionLoader::load(), SUMORouteLoader::loadUntil(), and MSDevice_FCDReplay::parseNext().
bool SUMOSAXReader::parseSection | ( | SumoXMLTag | element | ) |
Continue a progressive parse started by parseFirst until the given element is encountered.
The parse will continue until the section encapsulated by the element is completed
Definition at line 163 of file SUMOSAXReader.cpp.
References myHandler, myNextSection, GenericSAXHandler::myStartElement(), myToken, myXMLReader, GenericSAXHandler::retrieveNextSectionStart(), GenericSAXHandler::sectionFinished(), GenericSAXHandler::setSection(), TL, toString(), and WRITE_WARNINGF.
void SUMOSAXReader::parseString | ( | std::string | content | ) |
Parse XML from the given string.
[in] | content | XML string |
Definition at line 126 of file SUMOSAXReader.cpp.
References ensureSAXReader(), and myXMLReader.
Referenced by GUISettingsHandler::GUISettingsHandler(), NITypeLoader::load(), and main().
void SUMOSAXReader::setHandler | ( | GenericSAXHandler & | handler | ) |
Sets the given handler as content and error handler for the reader.
[in] | handler | The handler to assign to the reader |
Definition at line 72 of file SUMOSAXReader.cpp.
References myHandler, and myXMLReader.
Referenced by SUMOSAXReader().
void SUMOSAXReader::setValidation | ( | std::string | validationScheme = "" | ) |
Sets a new validation scheme and applies the validation settings to the XML reader.
If no new scheme is given, the settings of the current scheme are applied.
[in] | validationScheme | The validation scheme (one of "never", "local", "auto", or "always") |
Definition at line 82 of file SUMOSAXReader.cpp.
References myLocalResolver, myNoOpResolver, mySchemaResolver, myValidationScheme, and myXMLReader.
Referenced by ensureSAXReader().
|
private |
Schema cache to be used for grammars which are not declared.
Definition at line 159 of file SUMOSAXReader.h.
Referenced by ensureSAXReader().
|
private |
generic SAX Handler
Definition at line 153 of file SUMOSAXReader.h.
Referenced by ensureSAXReader(), parseSection(), and setHandler().
|
private |
|
private |
|
private |
|
private |
next section
Definition at line 186 of file SUMOSAXReader.h.
Referenced by parseSection(), and ~SUMOSAXReader().
|
private |
no operation resolver
Definition at line 183 of file SUMOSAXReader.h.
Referenced by setValidation().
|
private |
|
private |
token
Definition at line 162 of file SUMOSAXReader.h.
Referenced by parseFirst(), parseNext(), and parseSection().
|
private |
Information whether built reader/parser shall validate XML-documents against schemata.
Definition at line 156 of file SUMOSAXReader.h.
Referenced by setValidation().
|
private |
XML reader.
Definition at line 165 of file SUMOSAXReader.h.
Referenced by ensureSAXReader(), parse(), parseFirst(), parseNext(), parseSection(), parseString(), setHandler(), setValidation(), and ~SUMOSAXReader().
|
private |
The stack of begun xml elements.
Definition at line 174 of file SUMOSAXReader.h.