23 auto pred=[](
char c){
return std::isspace(c); };
25 std::string::const_iterator left
26 =std::find_if_not(s.begin(), s.end(), pred);
32 std::string::const_reverse_iterator right
33 =std::find_if_not(s.rbegin(), s.rend(), pred);
36 return s.substr(i, (j-i+1));
52 std::vector<std::string> &result,
67 INVARIANT(n > 0,
"Empty string case should already be handled");
76 std::string new_s=s.substr(start, i-start);
81 if(!remove_empty || !new_s.empty())
82 result.push_back(new_s);
88 std::string new_s=s.substr(start, n-start);
93 if(!remove_empty || !new_s.empty())
94 result.push_back(new_s);
101 const std::string &s,
110 std::vector<std::string> result;
113 if(result.size() != 2)
116 "' to contain two substrings " 118 delim +
" but has " +
127 const std::string &s,
132 std::vector<std::string> result;
138 const std::string &s,
141 std::string result=
"";
142 const size_t index=s.find_last_of(delim);
143 if(index!=std::string::npos)
144 result=s.substr(0, index);
152 for(std::size_t i=0; i<s.size(); i++)
154 if(s[i]==
'\\' || s[i]==
'"')
173 const std::string &from,
174 const std::string &to)
176 size_t start_pos = 0;
177 while((start_pos = str.find(from, start_pos)) != std::string::npos)
179 str.replace(start_pos, from.length(), to);
180 start_pos += to.length();
Thrown when failing to deserialize a value from some low level format, like JSON or raw bytes.
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
std::string strip_string(const std::string &s)
Remove all whitespace characters from either end of a string.
unsignedbv_typet size_type()
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
void replace_all(std::string &str, const std::string &from, const std::string &to)
Replace all occurrences of a string inside a string.
#define PRECONDITION(CONDITION)
std::string escape(const std::string &s)
Generic escaping of strings; this is not meant to be a particular programming language.
void split_string(const std::string &s, char delim, std::vector< std::string > &result, bool strip, bool remove_empty)
Given a string s, split into a sequence of substrings when separated by specified delimiter.
std::string trim_from_last_delimiter(const std::string &s, const char delim)