/* */ #include "Option.h" #include "prefs.h" Option::Option() {} Option::~Option() {} void Option::put(const string& name, const string& value) { table[name] = value; } bool Option::defined(const string& name) const { return table.count(name) == 1; } string Option::get(const string& name) const { map::const_iterator itr = table.find(name); if(itr == table.end()) { return ""; } else { return (*itr).second; } } int Option::getAsInt(const string& name) const { string value = get(name); if(value == "") { return 0; } else { return (int)strtol(value.c_str(), NULL, 10); } } long long int Option::getAsLLInt(const string& name) const { string value = get(name); if(value == "") { return 0; } else { return strtoll(value.c_str(), NULL, 10); } } bool Option::getAsBool(const string& name) const { string value = get(name); if(value == V_TRUE) { return true; } else { return false; } } double Option::getAsDouble(const string& name) const { string value = get(name); if(value == "") { return 0.0; } else { return strtod(value.c_str(), 0); } } void Option::clear() { table.clear(); }