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-2022 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
140 static bool runParser(GenericSAXHandler& handler, const std::string& file,
141 const bool isNet = false, const bool isRoute = false);
142
143
144private:
146 static std::vector<SUMOSAXReader*> myReaders;
147
150
152 static std::string myValidationScheme;
153
155 static std::string myNetValidationScheme;
156
158 static std::string myRouteValidationScheme;
159
161 static XERCES_CPP_NAMESPACE::XMLGrammarPool* myGrammarPool;
162
163};
A handler which converts occuring 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:149
static std::vector< SUMOSAXReader * > myReaders
The XML Readers used for repeated parsing.
Definition: XMLSubSys.h:146
static void setHandler(GenericSAXHandler &handler)
Sets the given handler for the default reader.
Definition: XMLSubSys.cpp:131
static std::string myValidationScheme
Information whether built reader/parser shall validate XML-documents against schemata.
Definition: XMLSubSys.h:152
static void setValidation(const std::string &validationScheme, const std::string &netValidationScheme, const std::string &routeValidationScheme)
Enables or disables validation.
Definition: XMLSubSys.cpp:65
static XERCES_CPP_NAMESPACE::XMLGrammarPool * myGrammarPool
Schema cache to be used for grammars which are not declared.
Definition: XMLSubSys.h:161
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:121
static void close()
Closes the xml-subsystem.
Definition: XMLSubSys.cpp:108
static void init()
Initialises the xml-subsystem.
Definition: XMLSubSys.cpp:54
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false, const bool isRoute=false)
Runs the given handler on the given file; returns if everything's ok.
Definition: XMLSubSys.cpp:137
static std::string myRouteValidationScheme
Information whether built reader/parser shall validate SUMO routes against schemata.
Definition: XMLSubSys.h:158
static std::string myNetValidationScheme
Information whether built reader/parser shall validate SUMO networks against schemata.
Definition: XMLSubSys.h:155