35 #define BOOST_ASSERT_MSG_OSTREAM std::cout
36 #include <boost/assert.hpp>
101 static inline bool retypeVal(
const std::string &str, T &val) {
102 std::istringstream is(str.c_str());
104 if (!is)
return false;
109 static inline void notFoundWarning(
const std::string &keyString) {
110 std::cout <<
"No ConfigVal mapping found for \"" << keyString <<
"\"." << std::endl;
119 template <
class KEYTYPE,
class VALTYPE>
120 VALTYPE
ConfigVal(KEYTYPE keyString,
const VALTYPE &defaultVal,
bool warn=
true) {
124 notFoundWarning(keyString);
132 bool ok = retypeVal(valString, val);
134 std::string errString = string(
"ERROR: ConfigVal is unable to retype value.\n\tKey:\t'")
135 + keyString + string(
"'\n\tValue:\t'") + valString + string(
"'\n");
136 std::cout << errString;
147 #if (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x500) || \
148 (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)))
149 #define QUOTED_STRING const char *
151 #define QUOTED_STRING char *
155 BOOST_ASSERT_MSG(
ConfigValMap::map !=
nullptr,
"The global config map is NULL!");
159 if (warn) notFoundWarning(keyString);
165 BOOST_ASSERT_MSG(
ConfigValMap::map !=
nullptr ,
"The global config map is NULL!");
169 if (warn) notFoundWarning(keyString);
175 BOOST_ASSERT_MSG(
ConfigValMap::map !=
nullptr,
"The global config map is NULL!");
179 if (warn) notFoundWarning(keyString);
184 inline std::string
ConfigVal(std::string keyString, std::string defaultVal,
bool warn=
true) {
185 BOOST_ASSERT_MSG(
ConfigValMap::map !=
nullptr,
"The global config map is NULL!");
189 if (warn) notFoundWarning(keyString);