00001 // Module: Log4CPLUS 00002 // File: property.h 00003 // Created: 2/2002 00004 // Author: Tad E. Smith 00005 // 00006 // 00007 // Copyright 2002-2009 Tad E. Smith 00008 // 00009 // Licensed under the Apache License, Version 2.0 (the "License"); 00010 // you may not use this file except in compliance with the License. 00011 // You may obtain a copy of the License at 00012 // 00013 // http://www.apache.org/licenses/LICENSE-2.0 00014 // 00015 // Unless required by applicable law or agreed to in writing, software 00016 // distributed under the License is distributed on an "AS IS" BASIS, 00017 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00018 // See the License for the specific language governing permissions and 00019 // limitations under the License. 00020 00023 #ifndef LOG4CPLUS_HELPERS_PROPERTY_HEADER_ 00024 #define LOG4CPLUS_HELPERS_PROPERTY_HEADER_ 00025 00026 #include "dcmtk/oflog/config.h" 00027 #include "dcmtk/oflog/streams.h" 00028 #include "dcmtk/oflog/tstring.h" 00029 //#include <map> 00030 #include "dcmtk/ofstd/ofmap.h" 00031 //#include <vector> 00032 #include "dcmtk/ofstd/oflist.h" 00033 00034 #if (defined(__MWERKS__) && defined(__MACOS__)) 00035 using STD_NAMESPACE size_t; 00036 #endif 00037 00038 00039 namespace log4cplus { 00040 namespace helpers { 00041 00042 class LOG4CPLUS_EXPORT Properties { 00043 public: 00044 Properties(); 00045 explicit Properties(log4cplus::tistream& input); 00046 explicit Properties(const log4cplus::tstring& inputFile); 00047 virtual ~Properties(); 00048 00049 // constants 00050 static const tchar PROPERTIES_COMMENT_CHAR; 00051 00052 // methods 00056 bool exists(const log4cplus::tstring& key) const { 00057 return data.find(key) != data.end(); 00058 } 00059 00060 00064 size_t size() const { 00065 return data.size(); 00066 } 00067 00074 log4cplus::tstring getProperty(const log4cplus::tstring& key) const; 00075 00083 log4cplus::tstring getProperty(const log4cplus::tstring& key, 00084 const log4cplus::tstring& defaultVal) const; 00085 00089 OFList<log4cplus::tstring> propertyNames() const; 00090 00094 void setProperty(const log4cplus::tstring& key, const log4cplus::tstring& value); 00095 00099 bool removeProperty(const log4cplus::tstring& key); 00100 00106 Properties getPropertySubset(const log4cplus::tstring& prefix) const; 00107 00108 protected: 00109 // Types 00110 // LOG4CPLUS_EXPIMP_TEMPLATE template class LOG4CPLUS_EXPORT STD_NAMESPACE map<log4cplus::tstring, log4cplus::tstring>; 00111 typedef OFMap<log4cplus::tstring, log4cplus::tstring> StringMap; 00112 00113 // Methods 00114 void init(log4cplus::tistream& input); 00115 00116 // Data 00117 StringMap data; 00118 }; 00119 } // end namespace helpers 00120 00121 } 00122 00123 00124 #endif // LOG4CPLUS_HELPERS_PROPERTY_HEADER_ 00125