24 auto pred=[](
char c){
return std::isspace(c); };
26 std::string::const_iterator left
27 =std::find_if_not(s.begin(), s.end(), pred);
33 std::string::const_reverse_iterator right
34 =std::find_if_not(s.rbegin(), s.rend(), pred);
37 return s.substr(i, (j-i+1));
43 std::vector<std::string> &result,
59 INVARIANT(n > 0,
"Empty string case should already be handled");
68 std::string new_s=s.substr(start, i-start);
73 if(!remove_empty || !new_s.empty())
74 result.push_back(new_s);
80 std::string new_s=s.substr(start, n-start);
85 if(!remove_empty || !new_s.empty())
86 result.push_back(new_s);
88 if(!remove_empty && result.empty())
102 std::vector<std::string> result;
105 if(result.size() != 2)
108 "' to contain two substrings "
110 delim +
" but has " +
119 const std::string &s,
124 std::vector<std::string> result;
130 const std::string &s,
134 const size_t index=s.find_last_of(delim);
135 if(index!=std::string::npos)
136 result=s.substr(0, index);
144 for(std::size_t i=0; i<s.size(); i++)
146 if(s[i]==
'\\' || s[i]==
'"')
157 std::ostringstream escaped;
158 for(
auto &ch : to_escape)
165 escaped <<
'_' << std::hex << std::setfill(
'0') << std::setw(2)
168 return escaped.str();