Go to the documentation of this file.
42 #include <boost/regex.hpp>
100 ValueContainer::iterator iter =
values_.find(key);
127 ValueContainer::iterator iter =
values_.find(key);
129 string msg =
"Key " + key +
" not found";
132 return (*iter).second.size();
151 string msg =
"Wrong type of value: " +
value;
172 string msg =
"Wrong type of value: " +
value;
214 string msg =
"Wrong type of value: " +
value;
229 ValueContainer::iterator iter =
values_.find(key);
231 string msg =
"Key " + key +
" not found";
236 for (
size_t i = 0; i < (*iter).second.size(); i++) {
237 value += (*iter).second[i] +
" ";
246 size_t pos =
value.find(
"-");
247 string year =
value.substr(0, pos);
248 value.replace(0, pos + 1,
"");
250 pos =
value.find(
"-");
251 string month =
value.substr(0, pos);
252 value.replace(0, pos + 1,
"");
254 pos =
value.find(
" ");
255 string day =
value.substr(0, pos);
256 value.replace(0, pos + 1,
"");
258 pos =
value.find(
":");
259 string hours =
value.substr(0, pos);
260 value.replace(0, pos + 1,
"");
262 string minutes =
value;
268 timeinfo = localtime (&rawtime);
271 timeinfo->tm_year = temp - 1900;
273 timeinfo->tm_mon = temp - 1;
275 timeinfo->tm_mday = temp;
277 timeinfo->tm_hour = temp;
279 timeinfo->tm_min = temp;
281 return mktime(timeinfo);
293 const std::string& key,
295 bool caseSensitive) {
313 const std::string&) {
328 while (getline(inputStream, line)) {
335 const char* regExp =
"[ ]*(.+)[ ]*=[ ]*(.+)[ ]*";
336 boost::regex expression(regExp);
338 if (!boost::regex_match(line, what, expression)) {
368 ValueContainer::iterator iter =
values_.find(key);
372 for (
size_t i = 0; i < values.size(); i++) {
373 (*iter).second.push_back(values[i]);
389 if (line.substr(0, 1) ==
"#") {
407 const std::string& key,
408 const std::string& value,
410 const std::string& line) {
412 KeyContainer::iterator iter =
keys_.begin();
413 while (iter !=
keys_.end()) {
414 Key* current = (*iter).first;
416 if (current->
name_ == key) {
428 if (iter ==
keys_.end()) {
485 const char* regExp =
"([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{2})";
486 boost::regex expression(regExp);
488 if (!boost::regex_match(line, what, expression)) {
506 ValueContainer::iterator iter =
values_.find(key);
508 string msg =
"Key " + key +
" not found";
512 if (index < 0 || index >
static_cast<int>((*iter).second.size()) - 1) {
513 string msg =
"Index out of range.";
516 return (*iter).second[index];
bool caseSensitive_
True if name is case sensitive.
ConfigurationFile(bool doChecking=false)
bool booleanValue(const std::string &key, int index=0)
int itemCount(const std::string &key)
virtual bool handleError(int lineNumber, ConfigurationFileError error, const std::string &line)
void parse(std::istream &inputStream)
float floatValue(const std::string &key, int index=0)
#define IGNORE_CLANG_WARNING(X)
@ VT_UNIX_TIMESTAMP
Time as seconds since starting of 1970.
@ VT_INTEGER
Integer value.
ValueContainer values_
Contains all the values of configuration file.
bool check_
True if semantics of the configuration file is checked.
@ FE_UNKNOWN_KEY
Unknown key error.
bool isComment(const std::string &line)
std::string value(const std::string &key, int index=0)
std::string name_
Name of the key.
bool legalTime(const std::string &line)
@ VT_BOOLEAN
Boolean value.
virtual ~ConfigurationFile()
KeyContainer keys_
Contains all the legal keys of the configuration file.
bool checkSemantics(const std::string &key, const std::string &value, int lineNumber, const std::string &line)
@ FE_ILLEGAL_TYPE
Illegal type error.
void load(std::istream &inputStream)
int intValue(const std::string &key, int index=0)
unsigned int timeStampValue(const std::string &key)
static int toInt(const T &source)
bool hasKey(const std::string &key)
void addSupportedKey(const std::string &key, ConfigurationValueType type, bool caseSensitive=false)
std::string stringValue(const std::string &key, int index=0)
@ FE_MISSING_VALUE
Missing value error.
std::string valueOfKey(const std::string &key, int index)
static float toFloat(const T &source)
@ VT_READABLE_TIME
Time in readable format.