#ifndef DATAQUEUE_CONFIGURE_HH #define DATAQUEUE_CONFIGURE_HH #include #include #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; } template std::vector vectorize(const std::string& str) { std::vector vec; boost::tokenizer > elements(str, white_spaces); BOOST_FOREACH(std::string elem, elements) { vec.push_back(boost::lexical_cast(elem)); } return vec; } } // ns detail #endif // DATAQUEUE_CONFIGURE_HH