File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ Author: Daniel Poetzl
1212#include < cctype>
1313#include < algorithm>
1414
15+ // / Remove all whitespace characters from the end of a string. Whitespace
16+ // / in the middle of the string is left unchanged
17+ // / \param s: the string to strip
18+ // / \return The stripped string
1519std::string strip_string (const std::string &s)
1620{
1721 auto pred=[](char c){ return std::isspace (c); };
@@ -38,7 +42,7 @@ void split_string(
3842 bool remove_empty)
3943{
4044 assert (result.empty ());
41- assert (!std::isspace (delim));
45+ assert (!strip || ! std::isspace (delim));
4246
4347 if (s.empty ())
4448 {
Original file line number Diff line number Diff line change @@ -18,10 +18,10 @@ std::string strip_string(const std::string &s);
1818
1919void split_string (
2020 const std::string &s,
21- char delim, // must not be a whitespace character
21+ char delim, // must not be a whitespace character if strip is enabled
2222 std::vector<std::string> &result,
23- bool strip= false , // strip whitespace from elements
24- bool remove_empty= false ); // remove empty elements
23+ bool strip = false , // strip whitespace from the end of elements
24+ bool remove_empty = false ); // remove empty elements
2525
2626void split_string (
2727 const std::string &s,
You can’t perform that action at this time.
0 commit comments