diff options
-rw-r--r-- | raul/Configuration.hpp | 4 | ||||
-rw-r--r-- | src/Configuration.cpp | 20 |
2 files changed, 19 insertions, 5 deletions
diff --git a/raul/Configuration.hpp b/raul/Configuration.hpp index 6e45d3c..3449767 100644 --- a/raul/Configuration.hpp +++ b/raul/Configuration.hpp @@ -135,7 +135,9 @@ public: void print(std::ostream& os, const std::string mime_type="text/plain") const; - const Value& option(const std::string& long_name); + const Value& option(const std::string& long_name) const; + bool set(const std::string& long_name, const Value& value); + const std::list<std::string>& files() const { return _files; } private: diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 58898e2..151be45 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -152,14 +152,26 @@ Configuration::print(std::ostream& os, const std::string mime_type) const } const Raul::Configuration::Value& -Configuration::option(const std::string& long_name) +Configuration::option(const std::string& long_name) const { static const Value nil; - Options::iterator o = _options.find(long_name); - if (o == _options.end()) + Options::const_iterator o = _options.find(long_name); + if (o == _options.end()) { return nil; - else + } else { return o->second.value; + } +} + +bool +Configuration::set(const std::string& long_name, const Value& value) +{ + Options::iterator o = _options.find(long_name); + if (o != _options.end()) { + o->second.value = value; + return true; + } + return false; } } // namespace Raul |