1 #ifndef SOCKETCAN_INTERFACE_SETTINGS_H
2 #define SOCKETCAN_INTERFACE_SETTINGS_H
8 #include <boost/lexical_cast.hpp>
14 template <
typename T> T
get_optional(
const std::string &n,
const T& def)
const {
19 return boost::lexical_cast<T>(repr);
21 template <
typename T>
bool get(
const std::string &n, T& val)
const {
23 if(!
getRepr(n, repr))
return false;
24 val = boost::lexical_cast<T>(repr);
29 virtual bool getRepr(
const std::string &n, std::string & repr)
const = 0;
38 virtual bool getRepr(
const std::string &n, std::string & repr)
const {
return false; }
43 virtual bool getRepr(
const std::string &n, std::string & repr)
const {
44 std::map<std::string, std::string>::const_iterator it =
settings_.find(n);
50 template <
typename T>
void set(
const std::string &n,
const T& val) {
51 settings_[n] = boost::lexical_cast<std::string>(val);
53 static std::shared_ptr<SettingsMap>
create() {
return std::shared_ptr<SettingsMap>(
new SettingsMap); }