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 /****************************************************************************/
15 // Utility methods for initialising, closing and using the XML-subsystem
16 /****************************************************************************/
17 #ifndef XMLSubSys_h
18 #define XMLSubSys_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <string>
27 #include <vector>
28 #include <xercesc/sax2/SAX2XMLReader.hpp>
29 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class GenericSAXHandler;
35 class SUMOSAXHandler;
36 class SUMOSAXReader;
37 
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
66 class XMLSubSys {
67 public:
76  static void init();
77 
78 
87  static void setValidation(const std::string& validationScheme, const std::string& netValidationScheme);
88 
89 
95  static bool isValidating(const bool net = false);
96 
97 
103  static void close();
104 
105 
117  static SUMOSAXReader* getSAXReader(SUMOSAXHandler& handler);
118 
119 
127  static void setHandler(GenericSAXHandler& handler);
128 
129 
148  static bool runParser(GenericSAXHandler& handler,
149  const std::string& file, const bool isNet = false);
150 
151 
152 private:
154  static std::vector<SUMOSAXReader*> myReaders;
155 
157  static int myNextFreeReader;
158 
160  static XERCES_CPP_NAMESPACE::SAX2XMLReader::ValSchemes myValidationScheme;
161 
163  static XERCES_CPP_NAMESPACE::SAX2XMLReader::ValSchemes myNetValidationScheme;
164 
165 };
166 
167 
168 #endif
169 
170 /****************************************************************************/
171 
XMLSubSys::myReaders
static std::vector< SUMOSAXReader * > myReaders
The XML Readers used for repeated parsing.
Definition: XMLSubSys.h:154
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:112
SUMOSAXHandler
SAX-handler base for SUMO-files.
Definition: SUMOSAXHandler.h:41
XMLSubSys::close
static void close()
Closes the xml-subsystem.
Definition: XMLSubSys.cpp:90
SUMOSAXReader
SAX-reader encapsulation containing binary reader.
Definition: SUMOSAXReader.h:55
XMLSubSys::setHandler
static void setHandler(GenericSAXHandler &handler)
Sets the given handler for the default reader.
Definition: XMLSubSys.cpp:106
XMLSubSys::myNextFreeReader
static int myNextFreeReader
Information whether the reader is parsing.
Definition: XMLSubSys.h:157
XMLSubSys
Utility methods for initialising, closing and using the XML-subsystem.
Definition: XMLSubSys.h:66
XMLSubSys::setValidation
static void setValidation(const std::string &validationScheme, const std::string &netValidationScheme)
Enables or disables validation.
Definition: XMLSubSys.cpp:58
XMLSubSys::init
static void init()
Initialises the xml-subsystem.
Definition: XMLSubSys.cpp:47
XMLSubSys::isValidating
static bool isValidating(const bool net=false)
Returns whether validation is enabled.
Definition: XMLSubSys.cpp:81
XMLSubSys::myValidationScheme
static XERCES_CPP_NAMESPACE::SAX2XMLReader::ValSchemes myValidationScheme
Information whether built reader/parser shall validate XML-documents against schemata.
Definition: XMLSubSys.h:160
config.h
GenericSAXHandler
A handler which converts occuring elements and attributes into enums.
Definition: GenericSAXHandler.h:67
XMLSubSys::getSAXReader
static SUMOSAXReader * getSAXReader(SUMOSAXHandler &handler)
Builds a reader and assigns the handler to it.
Definition: XMLSubSys.cpp:100
XMLSubSys::myNetValidationScheme
static XERCES_CPP_NAMESPACE::SAX2XMLReader::ValSchemes myNetValidationScheme
Information whether built reader/parser shall validate SUMO networks against schemata.
Definition: XMLSubSys.h:163