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