36 std::string& child1, std::string& child2)
38 std::stringstream is(input);
39 std::stringstream os(std::stringstream::out);
40 std::stringstream os1(std::stringstream::out);
41 std::stringstream os2(std::stringstream::out);
46 if (i < 0)
throw std::runtime_error(
"Error parsing expression:" + input);
49 else if (c ==
'(') i++;
50 else if (c ==
')') i--;
51 else if ((i == 1) && (c ==
',')) j++;
55 else if (j == 0) os1 << c;
59 if (i != 0)
throw std::runtime_error(
"Error parsing expression:" + input);
71 std::vector<std::string>& childs)
73 std::stringstream is(input);
74 std::stringstream os(std::stringstream::out);
75 std::stringstream os1(std::stringstream::out);
82 if (i < 0)
throw std::runtime_error(
"Error parsing expression:" + input);
90 else if ((c ==
')') && (--i == 0))
92 childs.push_back(os1.str());
94 else if ((i == 1) && (c ==
','))
96 childs.push_back(os1.str());
97 os1.str(std::string());
105 if (i != 0)
throw std::runtime_error(
"Error parsing expression:" + input);
113 void split(std::string &input,
char delim, std::vector<std::string> &elems){
114 std::stringstream ss(input);
116 while (std::getline(ss, item, delim)){
117 elems.push_back(item);
Namespace of the library interface.
Functions to parse strings.
void split(std::string &input, char delim, std::vector< std::string > &elems)
Splits the input string with a delimiter to extract elements.
void parseExpresion(std::string input, std::string &parent, std::string &child1, std::string &child2)
Parse expresions of the form Parent(Child1, Child2).