aboutsummaryrefslogtreecommitdiffstats
path: root/vdstestlib/src/vespa/vdstestlib/config/dirconfig.hpp
blob: 17e2f7363e67b96b35cd5e80ae5ce65cbb59a709 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/vdstestlib/config/dirconfig.h>

#include <sstream>
#include <boost/lexical_cast.hpp>

namespace vdstestlib {

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);
}

} // storage