SUMO - Simulation of Urban MObility
OptionsLoader.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // A SAX-Handler for loading options
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef OptionsLoader_h
22 #define OptionsLoader_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <xercesc/sax/HandlerBase.hpp>
35 #include <xercesc/sax/AttributeList.hpp>
36 #include <xercesc/sax/SAXParseException.hpp>
37 #include <xercesc/sax/SAXException.hpp>
38 #include <string>
39 
40 
41 // ===========================================================================
42 // class declarations
43 // ===========================================================================
44 class OptionsCont;
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
54 class OptionsLoader : public XERCES_CPP_NAMESPACE::HandlerBase {
55 public:
58  OptionsLoader(const bool routeOnly = false);
59 
60 
63 
64 
65 
66 
69 
74  virtual void startElement(const XMLCh* const name,
75  XERCES_CPP_NAMESPACE::AttributeList& attributes);
76 
77 
85  void characters(const XMLCh* const chars, const XERCES3_SIZE_t length);
86 
87 
92  void endElement(const XMLCh* const name);
94 
95 
96 
97 
100 
105  void warning(const XERCES_CPP_NAMESPACE::SAXParseException& exception);
106 
107 
112  void error(const XERCES_CPP_NAMESPACE::SAXParseException& exception);
113 
114 
119  void fatalError(const XERCES_CPP_NAMESPACE::SAXParseException& exception);
121 
122 
123 
125  bool errorOccured() const;
126 
128  const std::string& getItem() const {
129  return myItem;
130  }
131 
132 
133 private:
142  void setValue(const std::string& key, std::string& value);
143 
144 
154  bool setSecure(const std::string& name, const std::string& value) const;
155 
156 
157 private:
159  OptionsLoader(const OptionsLoader& s);
160 
161 
164 
165 
166 private:
169 
171  bool myError;
172 
175 
177  std::string myItem;
178 
180  std::string myValue;
181 
182 };
183 
184 
185 #endif
186 
187 /****************************************************************************/
188 
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.
const std::string & getItem() const
Returns the last item read.
OptionsCont & myOptions
The options to fill.
void error(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Called on an XML-error.
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:54
#define XERCES3_SIZE_t
Definition: config.h:231
bool setSecure(const std::string &name, const std::string &value) const
Tries to set the named option to the given value.
void warning(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Called on an XML-warning.
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:108
OptionsLoader & operator=(const OptionsLoader &s)