Eclipse SUMO - Simulation of Urban MObility
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-2024 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 // ===========================================================================
32 class GenericSAXHandler;
33 class SUMOSAXHandler;
34 class SUMOSAXReader;
35 
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
62 class XMLSubSys {
63 public:
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 
107  static SUMOSAXReader* getSAXReader(SUMOSAXHandler& handler,
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 
147 private:
148  static std::string warnLocalScheme(const std::string& newScheme, const bool haveSUMO_HOME);
149 
150 private:
152  static std::vector<SUMOSAXReader*> myReaders;
153 
155  static int myNextFreeReader;
156 
158  static std::string myValidationScheme;
159 
161  static std::string myNetValidationScheme;
162 
164  static std::string myRouteValidationScheme;
165 
167  static XERCES_CPP_NAMESPACE::XMLGrammarPool* myGrammarPool;
168 
171 
172 };
A handler which converts occurring elements and attributes into enums.
SAX-handler base for SUMO-files.
SAX-reader encapsulation containing binary reader.
Definition: SUMOSAXReader.h:53
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:155
static std::vector< SUMOSAXReader * > myReaders
The XML Readers used for repeated parsing.
Definition: XMLSubSys.h:152
static void setHandler(GenericSAXHandler &handler)
Sets the given handler for the default reader.
Definition: XMLSubSys.cpp:142
static std::string myValidationScheme
Information whether built reader/parser shall validate XML-documents against schemata.
Definition: XMLSubSys.h:158
static void setValidation(const std::string &validationScheme, const std::string &netValidationScheme, const std::string &routeValidationScheme)
Enables or disables validation.
Definition: XMLSubSys.cpp:83
static XERCES_CPP_NAMESPACE::XMLGrammarPool * myGrammarPool
Schema cache to be used for grammars which are not declared.
Definition: XMLSubSys.h:167
static SUMOSAXReader * getSAXReader(SUMOSAXHandler &handler, const bool isNet=false, const bool isRoute=false)
Builds a reader and assigns the handler to it.
Definition: XMLSubSys.cpp:132
static void close()
Closes the xml-subsystem.
Definition: XMLSubSys.cpp:119
static void init()
Initialises the xml-subsystem.
Definition: XMLSubSys.cpp:56
static std::string warnLocalScheme(const std::string &newScheme, const bool haveSUMO_HOME)
Definition: XMLSubSys.cpp:67
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.
Definition: XMLSubSys.cpp:148
static std::string myRouteValidationScheme
Information whether built reader/parser shall validate SUMO routes against schemata.
Definition: XMLSubSys.h:164
static bool myNeedsValidationWarning
Whether a warning about missing SUMO_HOME should be emitted.
Definition: XMLSubSys.h:170
static std::string myNetValidationScheme
Information whether built reader/parser shall validate SUMO networks against schemata.
Definition: XMLSubSys.h:161