SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SUMOSAXAttributes.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Encapsulated SAX-Attributes
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef SUMOSAXAttributes_h
23 #define SUMOSAXAttributes_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <vector>
37 #include <utils/common/SUMOTime.h>
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
53 public:
54  /* @brief Constructor
55  * @param[in] tagName The name of the parsed object type; used for error message generation
56  */
57  SUMOSAXAttributes(const std::string& objectType) ;
58 
59 
61  virtual ~SUMOSAXAttributes() { }
62 
63 
77  int getIntReporting(int attr, const char* objectid, bool& ok,
78  bool report = true) const ;
79 
80 
96  int getOptIntReporting(int attr, const char* objectid, bool& ok,
97  int defaultValue, bool report = true) const ;
98 
99 
100 
114  long getLongReporting(int attr, const char* objectid, bool& ok,
115  bool report = true) const ;
116 
117 
118 
132  SUMOReal getSUMORealReporting(int attr, const char* objectid, bool& ok,
133  bool report = true) const ;
134 
135 
136 
152  SUMOReal getOptSUMORealReporting(int attr, const char* objectid, bool& ok,
153  SUMOReal defaultValue, bool report = true) const ;
154 
155 
156 
170  bool getBoolReporting(int attr, const char* objectid, bool& ok,
171  bool report = true) const ;
172 
173 
174 
190  bool getOptBoolReporting(int attr, const char* objectid, bool& ok,
191  bool defaultValue, bool report = true) const ;
192 
193 
194 
208  std::string getStringReporting(int attr, const char* objectid, bool& ok,
209  bool report = true) const ;
210 
211 
212 
228  std::string getOptStringReporting(int attr, const char* objectid, bool& ok,
229  const std::string& defaultValue, bool report = true) const ;
230 
231 
232 
249  SUMOTime getSUMOTimeReporting(int attr, const char* objectid, bool& ok,
250  bool report = true) const ;
251 
252 
253 
272  SUMOTime getOptSUMOTimeReporting(int attr, const char* objectid, bool& ok,
273  SUMOTime defaultValue, bool report = true) const ;
274 
275 
276 
277 
278 
279 
280 
281 
284 
290  virtual bool hasAttribute(int id) const = 0;
291 
292 
298  virtual bool hasAttribute(const std::string& id) const = 0;
299 
300 
316  virtual bool getBool(int id) const throw(EmptyData, BoolFormatException) = 0;
317 
332  virtual bool getBoolSecure(int id, bool val) const throw(EmptyData) = 0;
333 
334 
350  virtual int getInt(int id) const throw(EmptyData, NumberFormatException) = 0;
351 
352 
368  virtual long getLong(int id) const throw(EmptyData, NumberFormatException) = 0;
369 
370 
388  virtual int getIntSecure(int id, int def) const throw(EmptyData, NumberFormatException) = 0;
389 
390 
403  virtual std::string getString(int id) const throw(EmptyData) = 0;
404 
405 
418  virtual std::string getStringSecure(int id,
419  const std::string& def) const throw(EmptyData) = 0;
420 
421 
437  virtual SUMOReal getFloat(int id) const throw(EmptyData, NumberFormatException) = 0;
438 
456  virtual SUMOReal getFloatSecure(int id, SUMOReal def) const throw(EmptyData, NumberFormatException) = 0;
457 
458 
474  virtual SUMOReal getFloat(const std::string& id) const throw(EmptyData, NumberFormatException) = 0;
475 
476 
486  virtual std::string getStringSecure(const std::string& id,
487  const std::string& def) const = 0;
488  //}
489 
490 
496  virtual std::string getName(int attr) const = 0;
497 
498 
507  static void parseStringVector(const std::string& def, std::vector<std::string> &into) ;
508 
509 
511  const std::string& getObjectType() const {
512  return myObjectType;
513  }
514 
515 
517  static const std::string ENCODING;
518 
519 
520 protected:
521  void emitUngivenError(const std::string& attrname, const char* objectid) const ;
522  void emitEmptyError(const std::string& attrname, const char* objectid) const ;
523  void emitFormatError(const std::string& attrname, const std::string& type, const char* objectid) const ;
524 
525 private:
528 
529 private:
532 
535 
537  std::string myObjectType;
538 
539 };
540 
541 
542 #endif
543 
544 /****************************************************************************/
545