00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _BOGOTEL_PROPERTIES_H_
00011 #define _BOGOTEL_PROPERTIES_H_
00012
00013 #include <map>
00014 #include <string>
00015 #include <fstream>
00016 #include <iostream>
00017 #include <stdexcept>
00018
00019 namespace bogotel {
00020
00021 class CPropertiesFailure : public std::runtime_error {
00022 public:
00023 CPropertiesFailure(const std::string& reason);
00024 };
00025
00026 class CProperties : public std::map<std::string, std::string>
00027 {
00028 public:
00029 CProperties();
00030 virtual ~CProperties();
00031
00033 void load(const std::string filename) throw (CPropertiesFailure);
00034
00036
00037
00038 void putAll(CProperties& prop);
00039
00040 const std::string getProperty(const std::string& strKey);
00041
00042 const std::string getProperty(const std::string& strKey, const std::string& strDefault);
00043 const int getProperty(const std::string& strKey, const int iDefault);
00044 const long getProperty(const std::string& strKey, const long lDefault);
00045 const unsigned long getProperty(const std::string& strKey, const unsigned long ulDefault);
00046
00047 const int setProperty(const std::string& strKey, const int iValue);
00048 const std::string setProperty(const std::string& strKey, const std::string& strValue);
00049
00050 void list(std::ostream& out);
00051
00052 protected:
00053 static const std::string _strBlank;
00054
00055 private:
00056
00057 static const char * const szKeyTerminators;
00058
00059 public:
00060 typedef std::map<std::string, std::string> StringMap;
00061 };
00062 }
00063
00064 #endif // ! def _BOGOTEL_PROPERTIES_H_
00065