#pragma once #include "stg/common.h" #include "stg/optional.h" #include #include namespace SGCONF { template inline void MaybeSet(const std::map & options, const std::string & name, STG::Optional & res) { std::map::const_iterator it(options.find(name)); if (it == options.end()) return; T value; if (str2x(it->second, value) < 0) return; res = value; } template inline void MaybeSet(const std::map & options, const std::string & name, T & res, F conv) { std::map::const_iterator it(options.find(name)); if (it == options.end()) return; conv(it->second, res); } template <> inline void MaybeSet(const std::map & options, const std::string & name, STG::Optional & res) { std::map::const_iterator it(options.find(name)); if (it == options.end()) return; res = it->second; } } // namespace SGCONF