 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
43 const std::string& file,
const std::string& expectedRoot)
44 : myParentHandler(nullptr), myParentIndicator(
SUMO_TAG_NOTHING), myFileName(file), myExpectedRoot(expectedRoot), mySchemaSeen(false) {
46 while (tags[i].key != terminatorTag) {
47 myTagMap.insert(TagMap::value_type(tags[i].str, tags[i].key));
51 while (attrs[i].key != terminatorAttr) {
81 int len = (int)name.length();
82 XMLCh* ret =
new XMLCh[len + 1];
84 for (; i < len; i++) {
85 ret[i] = (XMLCh) name[i];
95 const XMLCh*
const qname,
96 const XERCES_CPP_NAMESPACE::Attributes& attrs) {
122 const XMLCh*
const qname) {
131 char* buf =
new char[len + 1];
143 }
catch (std::runtime_error&) {
177 TagMap::const_iterator i =
myTagMap.find(tag);
187 std::ostringstream buf;
189 buf << pMsg << std::endl;
190 buf <<
" In file '" <<
getFileName() <<
"'" << std::endl;
191 buf <<
" At line/column " << exception.getLineNumber() + 1
192 <<
'/' << exception.getColumnNumber() <<
"." << std::endl;
193 XERCES_CPP_NAMESPACE::XMLString::release(&pMsg);
void registerParent(const int tag, GenericSAXHandler *handler)
Assigning a parent handler which is enabled when the specified tag is closed.
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything's ok.
void warning(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Handler for XML-warnings.
#define WRITE_WARNING(msg)
virtual void myCharacters(int element, const std::string &chars)
Callback method for characters to implement by derived classes.
void fatalError(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Handler for XML-errors.
static std::string getConfigurationRelative(const std::string &configPath, const std::string &path)
Returns the second path as a relative path to the first file.
Encapsulated Xerces-SAX-attributes.
static void setHandler(GenericSAXHandler &handler)
Sets the given handler for the default reader.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Callback method for an opening tag to implement by derived classes.
@ SUMO_TAG_NOTHING
invalid tag
bool mySchemaSeen
whether the reader has already seen a schema
std::map< int, std::string > myPredefinedTagsMML
the map from ids to their string representation
int myParentIndicator
The tag indicating that control should be given back.
GenericSAXHandler(StringBijection< int >::Entry *tags, int terminatorTag, StringBijection< int >::Entry *attrs, int terminatorAttr, const std::string &file, const std::string &expectedRoot="")
Constructor.
void startElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const XERCES_CPP_NAMESPACE::Attributes &attrs)
The inherited method called when a new tag opens.
void endElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
The inherited method called when a tag is being closed.
virtual void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
std::string buildErrorMessage(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Builds an error message.
static std::string transcode(const XMLCh *const data)
converts a 0-terminated XMLCh* array (usually UTF-16, stemming from Xerces) into std::string in UTF-8
int convertTag(const std::string &tag) const
Converts a tag from its string into its numerical representation.
std::string transcode(const XMLCh *const qname)
const std::string & getFileName() const
returns the current file name
std::string myFileName
The name of the currently parsed file.
std::vector< std::string > myCharactersVector
A list of character strings obtained so far to build the complete characters string at the end.
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
void error(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Handler for XML-errors.
std::string myExpectedRoot
The root element to expect, empty string disables the check.
virtual ~GenericSAXHandler()
Destructor.
A handler which converts occuring elements and attributes into enums.
std::string getString(int id) const
Returns the string-value of the named (by its enum-value) attribute.
Encapsulated SAX-Attributes.
void characters(const XMLCh *const chars, const XERCES3_SIZE_t length)
The inherited method called when characters occurred.
XMLCh * convert(const std::string &name) const
converts from c++-string into unicode
void setFileName(const std::string &name)
Sets the current file name.
GenericSAXHandler * myParentHandler
The handler to give control back to.