Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
XMLSubSys.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2002-2026 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
19// Utility methods for initialising, closing and using the XML-subsystem
20/****************************************************************************/
21#pragma once
22#include <config.h>
23
24#include <string>
25#include <vector>
26#include <xercesc/sax2/SAX2XMLReader.hpp>
27
28
29// ===========================================================================
30// class declarations
31// ===========================================================================
33class SUMOSAXHandler;
34class SUMOSAXReader;
35
36
37// ===========================================================================
38// class definitions
39// ===========================================================================
62class XMLSubSys {
63public:
72 static void init();
73
74
83 static void setValidation(const std::string& validationScheme, const std::string& netValidationScheme, const std::string& routeValidationScheme);
84
85
91 static void close();
92
93
108 const bool isNet = false, const bool isRoute = false);
109
110
118 static void setHandler(GenericSAXHandler& handler);
119
120
142 static bool runParser(GenericSAXHandler& handler, const std::string& file,
143 const bool isNet = false, const bool isRoute = false,
144 const bool isExternal = false, const bool catchExceptions = true);
145
146
151 static std::string transcode(const XMLCh* const data, int length = -1);
152
154 static std::string transcodeFromLocal(const std::string& localString);
155
157 static std::string transcodeToLocal(const std::string& utf8String);
158
159
160private:
161 static std::string warnLocalScheme(const std::string& newScheme, const bool haveSUMO_HOME);
162
163private:
165 static std::vector<SUMOSAXReader*> myReaders;
166
169
171 static std::string myValidationScheme;
172
174 static std::string myNetValidationScheme;
175
177 static std::string myRouteValidationScheme;
178
180 static XERCES_CPP_NAMESPACE::XMLGrammarPool* myGrammarPool;
181
184
186 static XERCES_CPP_NAMESPACE::XMLLCPTranscoder* myLCPTranscoder;
187
188};
A handler which converts occurring elements and attributes into enums.
SAX-handler base for SUMO-files.
SAX-reader encapsulation containing binary reader.
Utility methods for initialising, closing and using the XML-subsystem.
Definition XMLSubSys.h:62
static int myNextFreeReader
Information whether the reader is parsing.
Definition XMLSubSys.h:168
static std::vector< SUMOSAXReader * > myReaders
The XML Readers used for repeated parsing.
Definition XMLSubSys.h:165
static void setHandler(GenericSAXHandler &handler)
Sets the given handler for the default reader.
static std::string myValidationScheme
Information whether built reader/parser shall validate XML-documents against schemata.
Definition XMLSubSys.h:171
static void setValidation(const std::string &validationScheme, const std::string &netValidationScheme, const std::string &routeValidationScheme)
Enables or disables validation.
Definition XMLSubSys.cpp:88
static XERCES_CPP_NAMESPACE::XMLGrammarPool * myGrammarPool
Schema cache to be used for grammars which are not declared.
Definition XMLSubSys.h:180
static SUMOSAXReader * getSAXReader(SUMOSAXHandler &handler, const bool isNet=false, const bool isRoute=false)
Builds a reader and assigns the handler to it.
static void close()
Closes the xml-subsystem.
static std::string transcode(const XMLCh *const data, int length=-1)
converts a 0-terminated XMLCh* array (usually UTF-16, stemming from Xerces) into std::string in UTF-8
static void init()
Initialises the xml-subsystem.
Definition XMLSubSys.cpp:61
static std::string warnLocalScheme(const std::string &newScheme, const bool haveSUMO_HOME)
Definition XMLSubSys.cpp:72
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false, const bool isRoute=false, const bool isExternal=false, const bool catchExceptions=true)
Runs the given handler on the given file; returns if everything's ok.
static std::string transcodeToLocal(const std::string &utf8String)
convert a string from UTF-8 to the local codepage
static std::string myRouteValidationScheme
Information whether built reader/parser shall validate SUMO routes against schemata.
Definition XMLSubSys.h:177
static bool myNeedsValidationWarning
Whether a warning about missing SUMO_HOME should be emitted.
Definition XMLSubSys.h:183
static std::string myNetValidationScheme
Information whether built reader/parser shall validate SUMO networks against schemata.
Definition XMLSubSys.h:174
static std::string transcodeFromLocal(const std::string &localString)
convert a string from the local codepage to UTF-8
static XERCES_CPP_NAMESPACE::XMLLCPTranscoder * myLCPTranscoder
reusable transcoder for local <-> UTF-8 conversions
Definition XMLSubSys.h:186