Source-highlight Library
/home/bettini/work/source-highlight/src-highlite/lib/srchilite/settings.h
00001 /*
00002  * settings.h
00003  *
00004  *  Created on: Apr 18, 2009
00005  *      Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2008
00006  *  Copyright: See COPYING file that comes with this distribution
00007  */
00008 
00009 #ifndef SETTINGS_H_
00010 #define SETTINGS_H_
00011 
00012 #include <string>
00013 
00014 namespace srchilite {
00015 
00017 enum SettingError {
00018     NO_SETTING_ERROR = 0, CANT_CREATE_DIR, CANT_CREATE_FILE
00019 };
00020 
00068 class Settings {
00070     std::string homeDir;
00071 
00073     std::string confDir;
00074 
00076     std::string confFileName;
00077 
00079     std::string testFileName;
00080 
00082     std::string dataDir;
00083 public:
00084     Settings();
00085     ~Settings();
00086 
00087     const std::string getConfDir() const {
00088         return confDir;
00089     }
00090 
00091     void setConfDir(const std::string &dir) {
00092         confDir = dir;
00093     }
00094 
00095     const std::string getConfFileName() const {
00096         return confFileName;
00097     }
00098 
00099     const std::string getTestFileName() const {
00100         return testFileName;
00101     }
00102 
00103     void setTestFileName(const std::string &name) {
00104         testFileName = name;
00105     }
00106 
00107     const std::string getDataDir() const {
00108         return dataDir;
00109     }
00110 
00111     void setDataDir(const std::string &ddir) {
00112         dataDir = ddir;
00113     }
00114 
00119     bool checkForConfFile();
00120 
00125     bool checkForTestFile();
00126 
00131     bool readDataDir();
00132 
00137     SettingError save();
00138 
00161     static const std::string retrieveDataDir(bool reload = false);
00162 
00166     static const std::string getDefaultDataDir();
00167 
00174     static void setGlobalDataDir(const std::string &dataDir);
00175 
00182     static bool checkSettings();
00183 };
00184 
00185 }
00186 
00187 #endif /* SETTINGS_H_ */