Source-highlight Library
settings.h
1 /*
2  * settings.h
3  *
4  * Created on: Apr 18, 2009
5  * Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2008
6  * Copyright: See COPYING file that comes with this distribution
7  */
8 
9 #ifndef SETTINGS_H_
10 #define SETTINGS_H_
11 
12 #include <string>
13 
14 namespace srchilite {
15 
18  NO_SETTING_ERROR = 0, CANT_CREATE_DIR, CANT_CREATE_FILE
19 };
20 
68 class Settings {
70  std::string homeDir;
71 
73  std::string confDir;
74 
76  std::string confFileName;
77 
79  std::string testFileName;
80 
82  std::string dataDir;
83 public:
84  Settings();
85  ~Settings();
86 
87  const std::string getConfDir() const {
88  return confDir;
89  }
90 
91  void setConfDir(const std::string &dir) {
92  confDir = dir;
93  }
94 
95  const std::string getConfFileName() const {
96  return confFileName;
97  }
98 
99  const std::string getTestFileName() const {
100  return testFileName;
101  }
102 
103  void setTestFileName(const std::string &name) {
104  testFileName = name;
105  }
106 
107  const std::string getDataDir() const {
108  return dataDir;
109  }
110 
111  void setDataDir(const std::string &ddir) {
112  dataDir = ddir;
113  }
114 
119  bool checkForConfFile();
120 
125  bool checkForTestFile();
126 
131  bool readDataDir();
132 
137  SettingError save();
138 
161  static const std::string retrieveDataDir(bool reload = false);
162 
166  static const std::string getDefaultDataDir();
167 
174  static void setGlobalDataDir(const std::string &dataDir);
175 
182  static bool checkSettings();
183 };
184 
185 }
186 
187 #endif /* SETTINGS_H_ */
SettingError
an error dealing with setting configuration file
Definition: settings.h:17
bool readDataDir()
Reads the datadir from the configuration file.
Definition: settings.cpp:107
SettingError save()
Saves the setting (for datadir) in the conf file.
Definition: settings.cpp:128
bool checkForTestFile()
Checks whether the test file is in the datadir.
Definition: settings.cpp:93
std::string testFileName
test file to search for in the datadir (default: lang.map)
Definition: settings.h:79
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
Handles the settings for source-highlight (and its library).
Definition: settings.h:68
std::string confFileName
the name of the configuration file (default: source-highlight.conf)
Definition: settings.h:76
std::string confDir
the directory for configuration file (default: $HOME/.source-highlight/)
Definition: settings.h:73
static const std::string retrieveDataDir(bool reload=false)
Retrieves the value for the data dir.
Definition: settings.cpp:152
bool checkForConfFile()
Checks whether the conf file exists.
Definition: settings.cpp:100
static bool checkSettings()
Checks whether the current retrieved data dir is a valid data dir value for source-highlight.
Definition: settings.cpp:193
std::string homeDir
the home directory of the user
Definition: settings.h:70
static void setGlobalDataDir(const std::string &dataDir)
Sets the global data dir value.
Definition: settings.cpp:189
static const std::string getDefaultDataDir()
Definition: settings.cpp:185
std::string dataDir
the data dir (used for .lang, .outlang, lang.map, etc), this is read from the configuration file ...
Definition: settings.h:82