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 /****************************************************************************/
16 // A SAX-Handler for loading options
17 /****************************************************************************/
18 #ifndef OptionsLoader_h
19 #define OptionsLoader_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <xercesc/sax/HandlerBase.hpp>
28 #include <xercesc/sax/AttributeList.hpp>
29 #include <xercesc/sax/SAXParseException.hpp>
30 #include <xercesc/sax/SAXException.hpp>
31 #include <string>
32 
33 
34 // ===========================================================================
35 // class declarations
36 // ===========================================================================
37 class OptionsCont;
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
47 class OptionsLoader : public XERCES_CPP_NAMESPACE::HandlerBase {
48 public:
51  OptionsLoader(const bool routeOnly = false);
52 
53 
56 
57 
58 
59 
62 
67  virtual void startElement(const XMLCh* const name,
68  XERCES_CPP_NAMESPACE::AttributeList& attributes);
69 
70 
78  void characters(const XMLCh* const chars, const XERCES3_SIZE_t length);
79 
80 
85  void endElement(const XMLCh* const name);
87 
88 
89 
90 
93 
98  void warning(const XERCES_CPP_NAMESPACE::SAXParseException& exception);
99 
100 
105  void error(const XERCES_CPP_NAMESPACE::SAXParseException& exception);
106 
107 
112  void fatalError(const XERCES_CPP_NAMESPACE::SAXParseException& exception);
114 
115 
116 
118  bool errorOccurred() const;
119 
121  const std::string& getItem() const {
122  return myItem;
123  }
124 
125 
126 private:
135  void setValue(const std::string& key, std::string& value);
136 
137 
147  bool setSecure(const std::string& name, const std::string& value) const;
148 
149 
150 private:
152  OptionsLoader(const OptionsLoader& s);
153 
154 
157 
158 
159 private:
162 
164  bool myError;
165 
168 
170  std::string myItem;
171 
173  std::string myValue;
174 
175 };
176 
177 
178 #endif
179 
180 /****************************************************************************/
181 
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:93
OptionsLoader::warning
void warning(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Called on an XML-warning.
Definition: OptionsLoader.cpp:118
OptionsLoader::error
void error(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Called on an XML-error.
Definition: OptionsLoader.cpp:128
OptionsLoader::OptionsLoader
OptionsLoader(const bool routeOnly=false)
Constructor.
Definition: OptionsLoader.cpp:46
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:53
XERCES3_SIZE_t
#define XERCES3_SIZE_t
Definition: config.h:213
OptionsLoader::myItem
std::string myItem
The name of the currently parsed option.
Definition: OptionsLoader.h:170
OptionsLoader::~OptionsLoader
~OptionsLoader()
Definition: OptionsLoader.cpp:50
OptionsLoader::myRootOnly
bool myRootOnly
The information whether only the root element should be parsed.
Definition: OptionsLoader.h:161
OptionsLoader::errorOccurred
bool errorOccurred() const
Returns the information whether an error occurred.
Definition: OptionsLoader.cpp:152
OptionsLoader::getItem
const std::string & getItem() const
Returns the last item read.
Definition: OptionsLoader.h:121
OptionsLoader::characters
void characters(const XMLCh *const chars, const XERCES3_SIZE_t length)
Called on the occurence of character data.
Definition: OptionsLoader.cpp:86
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:90
OptionsLoader::myError
bool myError
The information whether an error occurred.
Definition: OptionsLoader.h:164
OptionsLoader
A SAX-Handler for loading options.
Definition: OptionsLoader.h:47
OptionsLoader::myValue
std::string myValue
The currently read characters string.
Definition: OptionsLoader.h:173
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:70
OptionsLoader::fatalError
void fatalError(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Called on an XML-fatal error.
Definition: OptionsLoader.cpp:140
OptionsLoader::myOptions
OptionsCont & myOptions
The options to fill.
Definition: OptionsLoader.h:167
OptionsLoader::endElement
void endElement(const XMLCh *const name)
Called on the end of an element.
Definition: OptionsLoader.cpp:104
OptionsLoader::operator=
OptionsLoader & operator=(const OptionsLoader &s)