Eclipse SUMO - Simulation of Urban MObility
OptionsLoader.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-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 // A SAX-Handler for loading options
16 /****************************************************************************/
17 #ifndef OptionsLoader_h
18 #define OptionsLoader_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <xercesc/sax/HandlerBase.hpp>
27 #include <xercesc/sax/AttributeList.hpp>
28 #include <xercesc/sax/SAXParseException.hpp>
29 #include <xercesc/sax/SAXException.hpp>
30 #include <string>
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class OptionsCont;
37 
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
46 class OptionsLoader : public XERCES_CPP_NAMESPACE::HandlerBase {
47 public:
50  OptionsLoader(const bool routeOnly = false);
51 
52 
55 
56 
57 
58 
61 
66  virtual void startElement(const XMLCh* const name,
67  XERCES_CPP_NAMESPACE::AttributeList& attributes);
68 
69 
77  void characters(const XMLCh* const chars, const XERCES3_SIZE_t length);
78 
79 
84  void endElement(const XMLCh* const name);
86 
87 
88 
89 
92 
97  void warning(const XERCES_CPP_NAMESPACE::SAXParseException& exception);
98 
99 
104  void error(const XERCES_CPP_NAMESPACE::SAXParseException& exception);
105 
106 
111  void fatalError(const XERCES_CPP_NAMESPACE::SAXParseException& exception);
113 
114 
115 
117  bool errorOccurred() const;
118 
120  const std::string& getItem() const {
121  return myItem;
122  }
123 
124 
125 private:
134  void setValue(const std::string& key, std::string& value);
135 
136 
146  bool setSecure(const std::string& name, const std::string& value) const;
147 
148 
149 private:
151  OptionsLoader(const OptionsLoader& s);
152 
153 
156 
157 
158 private:
161 
163  bool myError;
164 
167 
169  std::string myItem;
170 
172  std::string myValue;
173 
174 };
175 
176 
177 #endif
178 
179 /****************************************************************************/
180 
OptionsLoader::setSecure
bool setSecure(const std::string &name, const std::string &value) const
Tries to set the named option to the given value.
Definition: OptionsLoader.cpp:94
OptionsLoader::warning
void warning(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Called on an XML-warning.
Definition: OptionsLoader.cpp:119
OptionsLoader::error
void error(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Called on an XML-error.
Definition: OptionsLoader.cpp:129
OptionsLoader::OptionsLoader
OptionsLoader(const bool routeOnly=false)
Constructor.
Definition: OptionsLoader.cpp:45
OptionsLoader::startElement
virtual void startElement(const XMLCh *const name, XERCES_CPP_NAMESPACE::AttributeList &attributes)
Called on the occurence of the beginning of a tag.
Definition: OptionsLoader.cpp:52
XERCES3_SIZE_t
#define XERCES3_SIZE_t
Definition: config.h:216
OptionsLoader::myItem
std::string myItem
The name of the currently parsed option.
Definition: OptionsLoader.h:169
OptionsLoader::~OptionsLoader
~OptionsLoader()
Definition: OptionsLoader.cpp:49
OptionsLoader::myRootOnly
bool myRootOnly
The information whether only the root element should be parsed.
Definition: OptionsLoader.h:160
OptionsLoader::errorOccurred
bool errorOccurred() const
Returns the information whether an error occurred.
Definition: OptionsLoader.cpp:153
OptionsLoader::getItem
const std::string & getItem() const
Returns the last item read.
Definition: OptionsLoader.h:120
OptionsLoader::characters
void characters(const XMLCh *const chars, const XERCES3_SIZE_t length)
Called on the occurence of character data.
Definition: OptionsLoader.cpp:87
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
OptionsLoader::myError
bool myError
The information whether an error occurred.
Definition: OptionsLoader.h:163
OptionsLoader
A SAX-Handler for loading options.
Definition: OptionsLoader.h:46
OptionsLoader::myValue
std::string myValue
The currently read characters string.
Definition: OptionsLoader.h:172
config.h
OptionsLoader::setValue
void setValue(const std::string &key, std::string &value)
Tries to set the named option to the given value.
Definition: OptionsLoader.cpp:71
OptionsLoader::fatalError
void fatalError(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Called on an XML-fatal error.
Definition: OptionsLoader.cpp:141
OptionsLoader::myOptions
OptionsCont & myOptions
The options to fill.
Definition: OptionsLoader.h:166
OptionsLoader::endElement
void endElement(const XMLCh *const name)
Called on the end of an element.
Definition: OptionsLoader.cpp:105
OptionsLoader::operator=
OptionsLoader & operator=(const OptionsLoader &s)