00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef SUMOSAXAttributes_h
00020 #define SUMOSAXAttributes_h
00021
00022
00023
00024
00025
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031
00032 #include <string>
00033 #include <vector>
00034 #include <utils/common/SUMOTime.h>
00035 #include "SUMOXMLDefinitions.h"
00036 #include <utils/common/UtilExceptions.h>
00037
00038
00039
00040
00041
00050 class SUMOSAXAttributes {
00051 public:
00053 SUMOSAXAttributes() throw() { }
00054
00055
00057 virtual ~SUMOSAXAttributes() throw() { }
00058
00059
00071 bool setIDFromAttributes(const char *objecttype, std::string &id,
00072 bool report=true) const throw();
00073
00074
00075
00090 int getIntReporting(SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok,
00091 bool report=true) const throw();
00092
00093
00110 int getOptIntReporting(SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok,
00111 int defaultValue, bool report=true) const throw();
00112
00113
00114
00129 SUMOReal getSUMORealReporting(SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok,
00130 bool report=true) const throw();
00131
00132
00133
00150 SUMOReal getOptSUMORealReporting(SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok,
00151 SUMOReal defaultValue, bool report=true) const throw();
00152
00153
00154
00169 bool getBoolReporting(SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok,
00170 bool report=true) const throw();
00171
00172
00173
00190 bool getOptBoolReporting(SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok,
00191 bool defaultValue, bool report=true) const throw();
00192
00193
00194
00209 std::string getStringReporting(SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok,
00210 bool report=true) const throw();
00211
00212
00213
00230 std::string getOptStringReporting(SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok,
00231 const std::string &defaultValue, bool report=true) const throw();
00232
00233
00234
00252 SUMOTime getSUMOTimeReporting(SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok,
00253 bool report=true) const throw();
00254
00255
00256
00276 SUMOTime getOptSUMOTimeReporting(SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok,
00277 SUMOTime defaultValue, bool report=true) const throw();
00278
00279
00280
00281
00282
00283
00284
00285
00288
00294 virtual bool hasAttribute(SumoXMLAttr id) const throw() = 0;
00295
00296
00302 virtual bool hasAttribute(const std::string &id) const throw() = 0;
00303
00304
00320 virtual bool getBool(SumoXMLAttr id) const throw(EmptyData, BoolFormatException) = 0;
00321
00336 virtual bool getBoolSecure(SumoXMLAttr id, bool val) const throw(EmptyData) = 0;
00337
00338
00354 virtual int getInt(SumoXMLAttr id) const throw(EmptyData, NumberFormatException) = 0;
00355
00356
00374 virtual int getIntSecure(SumoXMLAttr id, int def) const throw(EmptyData, NumberFormatException) = 0;
00375
00376
00389 virtual std::string getString(SumoXMLAttr id) const throw(EmptyData) = 0;
00390
00391
00404 virtual std::string getStringSecure(SumoXMLAttr id,
00405 const std::string &def) const throw(EmptyData) = 0;
00406
00407
00423 virtual SUMOReal getFloat(SumoXMLAttr id) const throw(EmptyData, NumberFormatException) = 0;
00424
00442 virtual SUMOReal getFloatSecure(SumoXMLAttr id, SUMOReal def) const throw(EmptyData, NumberFormatException) = 0;
00443
00444
00460 virtual SUMOReal getFloat(const std::string &id) const throw(EmptyData, NumberFormatException) = 0;
00461
00462
00472 virtual std::string getStringSecure(const std::string &id,
00473 const std::string &def) const throw() = 0;
00474
00475
00476
00482 virtual std::string getName(SumoXMLAttr attr) const throw() = 0;
00483
00484
00493 static void parseStringVector(const std::string &def, std::vector<std::string> &into) throw();
00494
00495 protected:
00496 void emitUngivenError(const std::string &attrname, const char *objecttype, const char *objectid) const throw();
00497 void emitEmptyError(const std::string &attrname, const char *objecttype, const char *objectid) const throw();
00498 void emitFormatError(const std::string &attrname, const std::string &type, const char *objecttype, const char *objectid) const throw();
00499
00500 private:
00502 static bool myHaveInformedAboutDeprecatedDivider;
00503
00504 private:
00506 SUMOSAXAttributes(const SUMOSAXAttributes &src);
00507
00509 SUMOSAXAttributes &operator=(const SUMOSAXAttributes &src);
00510
00511
00512 };
00513
00514
00515 #endif
00516
00517
00518