Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
SUMOSAXReader Class Reference

SAX-reader encapsulation containing binary reader. More...

#include <SUMOSAXReader.h>

Collaboration diagram for SUMOSAXReader:
[legend]

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 SUMOSAXReaderoperator= (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.
 
GenericSAXHandlermyHandler
 generic SAX Handler
 
std::unique_ptr< IStreamInputSourcemyInputStream
 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< SumoXMLTagmyXMLStack
 The stack of begun xml elements.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SUMOSAXReader() [1/2]

SUMOSAXReader::SUMOSAXReader ( GenericSAXHandler handler,
const std::string &  validationScheme,
XERCES_CPP_NAMESPACE::XMLGrammarPool *  grammarPool 
)

Constructor.

Parameters
[in]fileThe name of the processed file

Definition at line 50 of file SUMOSAXReader.cpp.

References setHandler().

◆ ~SUMOSAXReader()

SUMOSAXReader::~SUMOSAXReader ( )

Destructor.

Definition at line 65 of file SUMOSAXReader.cpp.

References myNextSection, and myXMLReader.

◆ SUMOSAXReader() [2/2]

SUMOSAXReader::SUMOSAXReader ( const SUMOSAXReader s)
privatedelete

invalidated copy constructor

Member Function Documentation

◆ ensureSAXReader()

void SUMOSAXReader::ensureSAXReader ( )
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().

Here is the caller graph for this function:

◆ operator=()

const SUMOSAXReader & SUMOSAXReader::operator= ( const SUMOSAXReader s)
privatedelete

invalidated assignment operator

◆ parse()

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.

Parameters
[in]systemIDfile name

Definition at line 108 of file SUMOSAXReader.cpp.

References ensureSAXReader(), FileHelpers::isDirectory(), FileHelpers::isReadable(), myXMLReader, TLF, and StringUtils::transcodeToLocal().

◆ parseFirst()

bool SUMOSAXReader::parseFirst ( std::string  systemID)

Start parsing the given file using parseFirst of myXMLReader.

Parameters
[in]systemIDfile name
Returns
whether the prolog could be parsed successfully

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().

Here is the caller graph for this function:

◆ parseNext()

bool SUMOSAXReader::parseNext ( )

Continue a progressive parse started by parseFirst.

Returns
whether the next token could be parsed successfully

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().

Here is the caller graph for this function:

◆ parseSection()

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

Returns
whether the next section could be parsed successfully

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.

◆ parseString()

void SUMOSAXReader::parseString ( std::string  content)

Parse XML from the given string.

Parameters
[in]contentXML string

Definition at line 126 of file SUMOSAXReader.cpp.

References ensureSAXReader(), and myXMLReader.

Referenced by GUISettingsHandler::GUISettingsHandler(), NITypeLoader::load(), and main().

Here is the caller graph for this function:

◆ setHandler()

void SUMOSAXReader::setHandler ( GenericSAXHandler handler)

Sets the given handler as content and error handler for the reader.

Parameters
[in]handlerThe handler to assign to the reader

Definition at line 72 of file SUMOSAXReader.cpp.

References myHandler, and myXMLReader.

Referenced by SUMOSAXReader().

Here is the caller graph for this function:

◆ setValidation()

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.

Parameters
[in]validationSchemeThe 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().

Here is the caller graph for this function:

Field Documentation

◆ myGrammarPool

XERCES_CPP_NAMESPACE::XMLGrammarPool* SUMOSAXReader::myGrammarPool
private

Schema cache to be used for grammars which are not declared.

Definition at line 159 of file SUMOSAXReader.h.

Referenced by ensureSAXReader().

◆ myHandler

GenericSAXHandler* SUMOSAXReader::myHandler
private

generic SAX Handler

Definition at line 153 of file SUMOSAXReader.h.

Referenced by ensureSAXReader(), parseSection(), and setHandler().

◆ myInputStream

std::unique_ptr<IStreamInputSource> SUMOSAXReader::myInputStream
private

input stream

Definition at line 171 of file SUMOSAXReader.h.

Referenced by parseFirst().

◆ myIStream

std::unique_ptr<std::istream> SUMOSAXReader::myIStream
private

istream

Definition at line 168 of file SUMOSAXReader.h.

Referenced by parseFirst().

◆ myLocalResolver

LocalSchemaResolver SUMOSAXReader::myLocalResolver
private

local resolver

Definition at line 180 of file SUMOSAXReader.h.

Referenced by setValidation().

◆ myNextSection

std::pair<int, SUMOSAXAttributes*> SUMOSAXReader::myNextSection
private

next section

Definition at line 186 of file SUMOSAXReader.h.

Referenced by parseSection(), and ~SUMOSAXReader().

◆ myNoOpResolver

LocalSchemaResolver SUMOSAXReader::myNoOpResolver
private

no operation resolver

Definition at line 183 of file SUMOSAXReader.h.

Referenced by setValidation().

◆ mySchemaResolver

LocalSchemaResolver SUMOSAXReader::mySchemaResolver
private

schema resolver

Definition at line 177 of file SUMOSAXReader.h.

Referenced by setValidation().

◆ myToken

XERCES_CPP_NAMESPACE::XMLPScanToken SUMOSAXReader::myToken
private

token

Definition at line 162 of file SUMOSAXReader.h.

Referenced by parseFirst(), parseNext(), and parseSection().

◆ myValidationScheme

std::string SUMOSAXReader::myValidationScheme
private

Information whether built reader/parser shall validate XML-documents against schemata.

Definition at line 156 of file SUMOSAXReader.h.

Referenced by setValidation().

◆ myXMLReader

XERCES_CPP_NAMESPACE::SAX2XMLReader* SUMOSAXReader::myXMLReader
private

◆ myXMLStack

std::vector<SumoXMLTag> SUMOSAXReader::myXMLStack
private

The stack of begun xml elements.

Definition at line 174 of file SUMOSAXReader.h.


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