Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
detail Namespace Reference

Functions

static const boost::char_separator< char > args_sep (";")
 
static const boost::char_separator< char > fields_sep ("=")
 
static const boost::char_separator< char > white_spaces ("\t ")
 
boost::property_tree::ptree parse (std::string str)
 
template<typename T >
std::vector< T > vectorize (const std::string &str)
 

Detailed Description

Author
cpellegrino

Function Documentation

◆ args_sep()

static const boost::char_separator< char > detail::args_sep ( ";" )
static

◆ fields_sep()

static const boost::char_separator< char > detail::fields_sep ( )
static

◆ white_spaces()

static const boost::char_separator< char > detail::white_spaces ( "\t " )
static

◆ parse()

boost::property_tree::ptree detail::parse ( std::string str)
inline

Definition at line 24 of file configure.hh.

25 {
26 boost::algorithm::trim(str);
27 boost::property_tree::ptree pt;
28 boost::tokenizer<boost::char_separator<char> > tok(str, args_sep);
29
30 BOOST_FOREACH(std::string s, tok)
31 {
32 boost::algorithm::trim(s);
33 boost::tokenizer<boost::char_separator<char> > fields(s, fields_sep);
34 typedef boost::tokenizer<boost::char_separator<char> >::iterator Iter;
35
36 Iter it = fields.begin();
37
38 std::string varname = *it;
39 boost::algorithm::trim(varname);
40
41 ++it;
42 if (it != fields.end()) {
43 std::string val = *it;
44 boost::algorithm::trim(val);
45
46 pt.put(varname, val);
47 ++it;
48 } else {
49 throw std::runtime_error("Parsing error: malformed input buffer.");
50 }
51
52 if (it != fields.end()) {
53 throw std::runtime_error("Parsing error: malformed input buffer.");
54 }
55 }
56 return pt;
57 }

◆ vectorize()

template<typename T >
std::vector< T > detail::vectorize ( const std::string & str)

Definition at line 60 of file configure.hh.

61 {
63
64 boost::tokenizer<boost::char_separator<char> > elements(str, white_spaces);
65
66 BOOST_FOREACH(std::string elem, elements)
67 {
68 vec.push_back(boost::lexical_cast<T>(elem));
69 }
70
71 return vec;
72 }