1 #ifndef DATAQUEUE_CONFIGURE_HH
2 #define DATAQUEUE_CONFIGURE_HH
7 #include <boost/foreach.hpp>
8 #include <boost/tokenizer.hpp>
9 #include <boost/lexical_cast.hpp>
10 #include <boost/property_tree/ptree.hpp>
11 #include <boost/algorithm/string/trim.hpp>
19 static const boost::char_separator<char>
args_sep(
";");
20 static const boost::char_separator<char>
fields_sep(
"=");
24 boost::property_tree::ptree
parse(std::string str)
27 boost::property_tree::ptree pt;
28 boost::tokenizer<boost::char_separator<char> > tok(str,
args_sep);
30 BOOST_FOREACH(std::string s, tok)
33 boost::tokenizer<boost::char_separator<char> > fields(s,
fields_sep);
34 typedef boost::tokenizer<boost::char_separator<char> >::iterator Iter;
36 Iter it = fields.begin();
38 std::string varname = *it;
42 if (it != fields.end()) {
43 std::string val = *it;
49 throw std::runtime_error(
"Parsing error: malformed input buffer.");
52 if (it != fields.end()) {
53 throw std::runtime_error(
"Parsing error: malformed input buffer.");
64 boost::tokenizer<boost::char_separator<char> > elements(str,
white_spaces);
66 BOOST_FOREACH(std::string elem, elements)
68 vec.push_back(boost::lexical_cast<T>(elem));
std::string trim(const std::string &buffer)
Trim string.
static const boost::char_separator< char > fields_sep("=")
static const boost::char_separator< char > args_sep(";")
std::vector< T > vectorize(const std::string &str)
static const boost::char_separator< char > white_spaces("\t ")
boost::property_tree::ptree parse(std::string str)