diff options
-rw-r--r-- | vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.cpp | 18 | ||||
-rw-r--r-- | vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.h | 15 |
2 files changed, 20 insertions, 13 deletions
diff --git a/vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.cpp b/vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.cpp index 666ea593b89..fbcf15d23c0 100644 --- a/vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.cpp +++ b/vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.cpp @@ -142,6 +142,24 @@ DirConfig::getConfig(const ConfigName& name, bool createIfNonExisting) return it->second; } +template<typename T> +void +DirConfig::Config::setValue(const ConfigKey& key, const T& value) +{ + std::ostringstream ost; + ost << value; + set(key, ost.str()); +} + +template<typename T> +T +DirConfig::Config::getValue(const ConfigKey& key, const T& defVal) const +{ + const ConfigValue* val(get(key)); + if (val == 0) return defVal; + return boost::lexical_cast<T>(*val); +} + void DirConfig::removeConfig(const ConfigName& name) { diff --git a/vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.h b/vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.h index 116f2f76e93..5fe933fb689 100644 --- a/vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.h +++ b/vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.h @@ -17,7 +17,6 @@ */ #pragma once -#include <boost/lexical_cast.hpp> #include <list> #include <map> #include <string> @@ -41,21 +40,11 @@ struct DirConfig { void set(const ConfigKey&); // Set valueless key, such as array size void set(const ConfigKey&, const ConfigValue&); template<typename T> - void setValue(const ConfigKey& key, const T& value) - { - std::ostringstream ost; - ost << value; - set(key, ost.str()); - } + void setValue(const ConfigKey& key, const T& value); void remove(const ConfigKey&); const ConfigValue* get(const ConfigKey&) const; template<typename T> - T getValue(const ConfigKey& key, const T& defVal) const - { - const ConfigValue* val(get(key)); - if (val == 0) return defVal; - return boost::lexical_cast<T>(*val); - } + T getValue(const ConfigKey& key, const T& defVal) const; }; DirConfig(); |