Jpp  debug
the software that should make you happy
Functions
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  {
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  {
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;
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  }
std::string trim(const std::string &buffer)
Trim string.
Definition: JLangToolkit.hh:79
static const boost::char_separator< char > fields_sep("=")
static const boost::char_separator< char > args_sep(";")

◆ vectorize()

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

Definition at line 60 of file configure.hh.

61  {
62  std::vector<T> vec;
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  }
static const boost::char_separator< char > white_spaces("\t ")