Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __BARRY_CONFIGFILE_H__
00023 #define __BARRY_CONFIGFILE_H__
00024
00025 #include "dll.h"
00026 #include "record.h"
00027 #include "pin.h"
00028 #include <string>
00029
00030 namespace Barry {
00031
00032 class BXEXPORT ConfigFile
00033 {
00034 public:
00035 class BXEXPORT DBListType : public std::vector<std::string>
00036 {
00037 public:
00038 bool IsSelected(const std::string &dbname) const;
00039 };
00040
00041 private:
00042
00043 Barry::Pin m_pin;
00044 std::string m_path;
00045 std::string m_filename;
00046 bool m_loaded;
00047 std::string m_last_error;
00048
00049
00050 DBListType m_backupList;
00051 DBListType m_restoreList;
00052 std::string m_deviceName;
00053 bool m_promptBackupLabel;
00054
00055
00056
00057 protected:
00058 void BuildFilename();
00059 void BuildDefaultPath();
00060 void Clear();
00061 void Load();
00062
00063 public:
00064
00065
00066
00067
00068
00069 explicit ConfigFile(Barry::Pin pin);
00070
00071
00072
00073
00074 ConfigFile(Barry::Pin pin, const Barry::DatabaseDatabase &db);
00075
00076 ~ConfigFile();
00077
00078
00079
00080
00081
00082 const std::string& get_last_error() const { return m_last_error; }
00083 bool IsConfigLoaded() const { return m_loaded; }
00084
00085 const std::string& GetPath() const { return m_path; }
00086
00087
00088
00089
00090
00091 const DBListType& GetBackupList() const { return m_backupList; }
00092 const DBListType& GetRestoreList() const { return m_restoreList; }
00093 const std::string& GetDeviceName() const { return m_deviceName; }
00094 bool HasDeviceName() const { return m_deviceName.size(); }
00095 bool PromptBackupLabel() const { return m_promptBackupLabel; }
00096
00097
00098
00099
00100
00101
00102
00103 bool Save();
00104
00105
00106
00107
00108 void Enlighten(const Barry::DatabaseDatabase &db);
00109
00110
00111
00112
00113
00114
00115 void SetBackupList(const DBListType &list);
00116 void SetRestoreList(const DBListType &list);
00117
00118 void SetDeviceName(const std::string &name);
00119 void SetBackupPath(const std::string &path);
00120 void SetPromptBackupLabel(bool prompt = true);
00121
00122
00123
00124
00125
00126
00127
00128 static bool CheckPath(const std::string &path, std::string *perr = 0);
00129 };
00130
00131 class BXEXPORT GlobalConfigFile
00132 {
00133 private:
00134 typedef std::map<std::string, std::string> keymap_type;
00135
00136
00137 std::string m_path;
00138 std::string m_filename;
00139 bool m_loaded;
00140 std::string m_last_error;
00141 std::string m_appname;
00142
00143
00144 Barry::Pin m_lastDevice;
00145 bool m_verboseLogging;
00146
00147
00148 keymap_type m_keymap;
00149
00150 protected:
00151 void BuildFilename();
00152 void Clear();
00153 void Load();
00154
00155 public:
00156
00157
00158
00159 GlobalConfigFile();
00160
00161
00162
00163
00164
00165 GlobalConfigFile(const std::string &appname);
00166
00167 ~GlobalConfigFile();
00168
00169
00170
00171
00172
00173 const std::string& get_last_error() const { return m_last_error; }
00174 bool IsConfigLoaded() const { return m_loaded; }
00175
00176
00177
00178
00179 Barry::Pin GetLastDevice() const { return m_lastDevice; }
00180 bool VerboseLogging() const { return m_verboseLogging; }
00181
00182
00183
00184
00185
00186
00187 bool Save();
00188
00189
00190 void SetKey(const std::string &key, const std::string &value);
00191 std::string GetKey(const std::string &key) const;
00192
00193
00194
00195
00196 void SetLastDevice(const Barry::Pin &pin);
00197 void SetVerboseLogging(bool verbose = true);
00198 };
00199
00200 }
00201
00202 #endif
00203