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.org/sumo
3 // Copyright (C) 2002-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // Utility methods for initialising, closing and using the XML-subsystem
17 /****************************************************************************/
18 #ifndef XMLSubSys_h
19 #define XMLSubSys_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <string>
28 #include <vector>
29 #include <xercesc/sax2/SAX2XMLReader.hpp>
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class GenericSAXHandler;
36 class SUMOSAXHandler;
37 class SUMOSAXReader;
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
67 class XMLSubSys {
68 public:
77  static void init();
78 
79 
88  static void setValidation(const std::string& validationScheme, const std::string& netValidationScheme);
89 
90 
96  static bool isValidating(const bool net = false);
97 
98 
104  static void close();
105 
106 
118  static SUMOSAXReader* getSAXReader(SUMOSAXHandler& handler);
119 
120 
128  static void setHandler(GenericSAXHandler& handler);
129 
130 
149  static bool runParser(GenericSAXHandler& handler,
150  const std::string& file, const bool isNet = false);
151 
152 
153 private:
155  static std::vector<SUMOSAXReader*> myReaders;
156 
158  static int myNextFreeReader;
159 
161  static XERCES_CPP_NAMESPACE::SAX2XMLReader::ValSchemes myValidationScheme;
162 
164  static XERCES_CPP_NAMESPACE::SAX2XMLReader::ValSchemes myNetValidationScheme;
165 
166 };
167 
168 
169 #endif
170 
171 /****************************************************************************/
172 
XMLSubSys::myReaders
static std::vector< SUMOSAXReader * > myReaders
The XML Readers used for repeated parsing.
Definition: XMLSubSys.h:155
XMLSubSys::runParser
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.
Definition: XMLSubSys.cpp:113
SUMOSAXHandler
SAX-handler base for SUMO-files.
Definition: SUMOSAXHandler.h:42
XMLSubSys::close
static void close()
Closes the xml-subsystem.
Definition: XMLSubSys.cpp:91
SUMOSAXReader
SAX-reader encapsulation containing binary reader.
Definition: SUMOSAXReader.h:56
XMLSubSys::setHandler
static void setHandler(GenericSAXHandler &handler)
Sets the given handler for the default reader.
Definition: XMLSubSys.cpp:107
XMLSubSys::myNextFreeReader
static int myNextFreeReader
Information whether the reader is parsing.
Definition: XMLSubSys.h:158
XMLSubSys
Utility methods for initialising, closing and using the XML-subsystem.
Definition: XMLSubSys.h:67
XMLSubSys::setValidation
static void setValidation(const std::string &validationScheme, const std::string &netValidationScheme)
Enables or disables validation.
Definition: XMLSubSys.cpp:59
XMLSubSys::init
static void init()
Initialises the xml-subsystem.
Definition: XMLSubSys.cpp:48
XMLSubSys::isValidating
static bool isValidating(const bool net=false)
Returns whether validation is enabled.
Definition: XMLSubSys.cpp:82
XMLSubSys::myValidationScheme
static XERCES_CPP_NAMESPACE::SAX2XMLReader::ValSchemes myValidationScheme
Information whether built reader/parser shall validate XML-documents against schemata.
Definition: XMLSubSys.h:161
config.h
GenericSAXHandler
A handler which converts occuring elements and attributes into enums.
Definition: GenericSAXHandler.h:68
XMLSubSys::getSAXReader
static SUMOSAXReader * getSAXReader(SUMOSAXHandler &handler)
Builds a reader and assigns the handler to it.
Definition: XMLSubSys.cpp:101
XMLSubSys::myNetValidationScheme
static XERCES_CPP_NAMESPACE::SAX2XMLReader::ValSchemes myNetValidationScheme
Information whether built reader/parser shall validate SUMO networks against schemata.
Definition: XMLSubSys.h:164