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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
18 // A SAX-Handler for loading options
19 /****************************************************************************/
20 #ifndef OptionsLoader_h
21 #define OptionsLoader_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <xercesc/sax/HandlerBase.hpp>
34 #include <xercesc/sax/AttributeList.hpp>
35 #include <xercesc/sax/SAXParseException.hpp>
36 #include <xercesc/sax/SAXException.hpp>
37 #include <string>
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class OptionsCont;
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
53 class OptionsLoader : public XERCES_CPP_NAMESPACE::HandlerBase {
54 public:
57  OptionsLoader(const bool routeOnly = false);
58 
59 
62 
63 
64 
65 
68 
73  virtual void startElement(const XMLCh* const name,
74  XERCES_CPP_NAMESPACE::AttributeList& attributes);
75 
76 
84  void characters(const XMLCh* const chars, const XERCES3_SIZE_t length);
85 
86 
91  void endElement(const XMLCh* const name);
93 
94 
95 
96 
99 
104  void warning(const XERCES_CPP_NAMESPACE::SAXParseException& exception);
105 
106 
111  void error(const XERCES_CPP_NAMESPACE::SAXParseException& exception);
112 
113 
118  void fatalError(const XERCES_CPP_NAMESPACE::SAXParseException& exception);
120 
121 
122 
124  bool errorOccured() const;
125 
127  const std::string& getItem() const {
128  return myItem;
129  }
130 
131 
132 private:
141  void setValue(const std::string& key, std::string& value);
142 
143 
153  bool setSecure(const std::string& name, const std::string& value) const;
154 
155 
156 private:
158  OptionsLoader(const OptionsLoader& s);
159 
160 
163 
164 
165 private:
168 
170  bool myError;
171 
174 
176  std::string myItem;
177 
179  std::string myValue;
180 
181 };
182 
183 
184 #endif
185 
186 /****************************************************************************/
187 
std::string myItem
The name of the currently parsed option.
std::string myValue
The currently read characters string.
void endElement(const XMLCh *const name)
Called on the end of an element.
OptionsCont & myOptions
The options to fill.
void error(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Called on an XML-error.
bool setSecure(const std::string &name, const std::string &value) const
Tries to set the named option to the given value.
bool myError
The information whether an error occured.
OptionsLoader(const bool routeOnly=false)
Constructor.
bool myRootOnly
The information whether only the root element should be parsed.
void setValue(const std::string &key, std::string &value)
Tries to set the named option to the given value.
virtual void startElement(const XMLCh *const name, XERCES_CPP_NAMESPACE::AttributeList &attributes)
Called on the occurence of the beginning of a tag.
void fatalError(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Called on an XML-fatal error.
bool errorOccured() const
Returns the information whether an error occured.
A SAX-Handler for loading options.
Definition: OptionsLoader.h:53
#define XERCES3_SIZE_t
Definition: config.h:216
void warning(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Called on an XML-warning.
const std::string & getItem() const
Returns the last item read.
void characters(const XMLCh *const chars, const XERCES3_SIZE_t length)
Called on the occurence of character data.
A storage for options typed value containers)
Definition: OptionsCont.h:98
OptionsLoader & operator=(const OptionsLoader &s)