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 
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 occurred.
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.
A SAX-Handler for loading options.
Definition: OptionsLoader.h:47
#define XERCES3_SIZE_t
Definition: config.h:213
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:90
bool errorOccurred() const
Returns the information whether an error occurred.
OptionsLoader & operator=(const OptionsLoader &s)