diff --git a/include/transport/config.h b/include/transport/config.h index 903480e953056b23a3106b3d4ee2ca7abb89a56c..4ced7c987d1a66bccc3504c77c7e636bc76a2e84 100644 --- a/include/transport/config.h +++ b/include/transport/config.h @@ -77,7 +77,7 @@ class Config { bool reload(); bool hasKey(const std::string &key) { - return m_variables.find(key) != m_variables.end(); + return m_variables.find(key) != m_variables.end() || m_unregistered.find(key) != m_unregistered.end(); } /// Returns value of variable defined by key. @@ -85,16 +85,15 @@ class Config { /// For variables in sections you can use "section.variable" key format. /// \param key config variable name const boost::program_options::variable_value &operator[] (const std::string &key) { - return m_variables[key]; + if (m_variables.find(key) != m_variables.end()) { + return m_variables[key]; + } + return m_unregistered[key]; } /// Returns path to config file from which data were loaded. const std::string &getConfigFile() { return m_file; } - const std::map &getUnregistered() { - return m_unregistered; - } - /// This signal is emitted when config is loaded/reloaded. boost::signal onConfigReloaded; @@ -102,7 +101,7 @@ class Config { int m_argc; char **m_argv; Variables m_variables; - std::map m_unregistered; + std::map m_unregistered; std::string m_file; };