Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

property.h

Go to the documentation of this file.
00001 // Module:  Log4CPLUS
00002 // File:    property.h
00003 // Created: 2/2002
00004 // Author:  Tad E. Smith
00005 //
00006 //
00007 // Copyright (C) Tad E. Smith  All rights reserved.
00008 //
00009 // This software is published under the terms of the Apache Software
00010 // License version 1.1, a copy of which has been included with this
00011 // distribution in the LICENSE.APL file.
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           // constants
00041             static const tchar PROPERTIES_COMMENT_CHAR;
00042 
00043           // methods
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           // Types
00101 //            LOG4CPLUS_EXPIMP_TEMPLATE template class LOG4CPLUS_EXPORT std::map<log4cplus::tstring, log4cplus::tstring>;
00102             typedef std::map<log4cplus::tstring, log4cplus::tstring> StringMap;
00103 
00104           // Methods
00105             void init(log4cplus::tistream& input);
00106 
00107           // Data
00108             StringMap data;
00109         };
00110     } // end namespace helpers
00111 
00112 }
00113 
00114 
00115 #endif // LOG4CPLUS_HELPERS_PROPERTY_HEADER_
00116 

Generated on Mon Feb 9 09:10:30 2004 for log4cplus by doxygen 1.3.2