#ifndef MONROUTER_CONFIGURE_HPP #define MONROUTER_CONFIGURE_HPP #include #include #include #include #include /** * \author cpellegrino */ namespace detail { static const boost::char_separator args_sep(";"); static const boost::char_separator fields_sep("="); static const boost::char_separator white_spaces("\t "); inline boost::property_tree::ptree parse(std::string str) { boost::algorithm::trim(str); boost::property_tree::ptree pt; boost::tokenizer > tok(str, args_sep); BOOST_FOREACH(std::string s, tok) { boost::algorithm::trim(s); boost::tokenizer > fields(s, fields_sep); typedef boost::tokenizer >::iterator Iter; Iter it = fields.begin(); std::string varname = *it; boost::algorithm::trim(varname); ++it; if (it != fields.end()) { std::string val = *it; boost::algorithm::trim(val); pt.put(varname, val); ++it; } else { throw std::runtime_error("Parsing error: malformed input buffer."); } if (it != fields.end()) { throw std::runtime_error("Parsing error: malformed input buffer."); } } return pt; } } // ns detail #endif // MONROUTER_CONFIGURE_HPP