UtilParameters.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef UTIL_PARAMETERS_INCLUDED
00014 #define UTIL_PARAMETERS_INCLUDED
00015
00016
00017 #include <map>
00018 #include <string>
00019 #include <fstream>
00020 using namespace std;
00021
00022
00023 struct UtilParamT {
00024 string paramName;
00025 bool isUsed;
00026 };
00027 typedef struct UtilParamT UtilParam;
00028
00029
00030 class UtilParameters {
00031 private:
00032 UtilParameters(const UtilParameters& copy);
00033 UtilParameters& operator=(const UtilParameters& rhs);
00034
00035 private:
00036 map<string, UtilParam> m_paramMap;
00037
00038 public:
00039 UtilParameters()
00040 : m_paramMap() {}
00041
00042 UtilParameters(int& argc,
00043 char* argv[]) :
00044 m_paramMap() {
00045 ScanCmdLineArgs(argc, argv);
00046 };
00047
00048 ~UtilParameters() {};
00049
00050 void ScanCmdLineArgs(int& argc,
00051 char* argv[]);
00052 void LoadParamFile(string& paramFileName);
00053 void Add(string& section,
00054 string& name,
00055 string& value);
00056 void Add(const char* section,
00057 const char* name,
00058 const char* value);
00059 string GetSetting(const char* name,
00060 const char* defaultValue,
00061 const char* section = NULL);
00062 int GetSetting(const char* name,
00063 const int defaultValue,
00064 const char* section = NULL);
00065 bool GetSetting(const char* name,
00066 const bool defaultValue,
00067 const char* section = NULL);
00068 long GetSetting(const char* name,
00069 const long defaultValue,
00070 const char* section = NULL);
00071 double GetSetting(const char* name,
00072 const double defaultValue,
00073 const char* section = NULL);
00074
00075 private:
00076 UtilParam* FindEntry(const char* section,
00077 const char* name);
00078 string* Find(const char* section,
00079 const char* name);
00080 };
00081
00082 #endif