00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00016 #ifndef LOG4CPLUS_HELPERS_PROPERTY_HEADER_
00017 #define LOG4CPLUS_HELPERS_PROPERTY_HEADER_
00018
00019 #include <log4cplus/config.h>
00020 #include <log4cplus/streams.h>
00021 #include <log4cplus/tstring.h>
00022 #include <map>
00023 #include <vector>
00024
00025 #if (defined(__MWERKS__) && defined(__MACOS__))
00026 using std::size_t;
00027 #endif
00028
00029
00030 namespace log4cplus {
00031 namespace helpers {
00032
00033 class LOG4CPLUS_EXPORT Properties {
00034 public:
00035 Properties();
00036 explicit Properties(log4cplus::tistream& input);
00037 explicit Properties(const log4cplus::tstring& inputFile);
00038 virtual ~Properties();
00039
00040
00041 static const tchar PROPERTIES_COMMENT_CHAR;
00042
00043
00047 bool exists(const log4cplus::tstring& key) const {
00048 return data.find(key) != data.end();
00049 }
00050
00051
00055 size_t size() const {
00056 return data.size();
00057 }
00058
00065 log4cplus::tstring getProperty(const log4cplus::tstring& key) const;
00066
00074 log4cplus::tstring getProperty(const log4cplus::tstring& key,
00075 const log4cplus::tstring& defaultVal) const;
00076
00080 std::vector<log4cplus::tstring> propertyNames() const;
00081
00085 void setProperty(const log4cplus::tstring& key, const log4cplus::tstring& value);
00086
00090 bool removeProperty(const log4cplus::tstring& key);
00091
00097 Properties getPropertySubset(const log4cplus::tstring& prefix) const;
00098
00099 protected:
00100
00101
00102 typedef std::map<log4cplus::tstring, log4cplus::tstring> StringMap;
00103
00104
00105 void init(log4cplus::tistream& input);
00106
00107
00108 StringMap data;
00109 };
00110 }
00111
00112 }
00113
00114
00115 #endif // LOG4CPLUS_HELPERS_PROPERTY_HEADER_
00116