Main Page   Namespace List   Class Hierarchy   Data Structures   File List   Namespace Members   Data Fields   Globals   Related Pages  

Properties.h

Go to the documentation of this file.
00001 /*
00002  * Properties.h
00003  *
00004  * Copyright 2003, MobileSpear Inc. (www.mobilespear.com). All rights reserved.
00005  * Copyright 2003, David Resnick. All rights reserved.
00006  *
00007  * See the file doc\license.txt for the terms of usage and distribution.
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         // These mappings will replace any mappings that this CProperties had for any of 
00037         // the keys currently in the specified CProperties.
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 

Generated on Tue Aug 12 12:41:30 2003 for bogotel by doxygen 1.3. Hosted by SourceForge.net Logo