File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ Author: Daniel Poetzl
1212#include < cctype>
1313#include < algorithm>
1414
15- // / Remove all whitespace characters from the end of a string. Whitespace
15+ // / Remove all whitespace characters from either end of a string. Whitespace
1616// / in the middle of the string is left unchanged
1717// / \param s: the string to strip
1818// / \return The stripped string
@@ -34,6 +34,16 @@ std::string strip_string(const std::string &s)
3434 return s.substr (i, (j-i+1 ));
3535}
3636
37+ // / Given a string s, split into a sequence of substrings when separated by
38+ // / specified delimiter.
39+ // / \param s: The string to split up
40+ // / \param delim: The character to use as the delimiter
41+ // / \param [out] result: The sub strings
42+ // / \param strip: If true, strip_string will be used on each element, removing
43+ // / whitespace from the beginning and end of each element
44+ // / \param remove_empty: If true, all empty-string elements will be removed.
45+ // / This is applied after strip so whitespace only elements will be removed if
46+ // / both are set to true
3747void split_string (
3848 const std::string &s,
3949 char delim,
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 if strip is enabled
21+ char delim,
2222 std::vector<std::string> &result,
23- bool strip = false , // strip whitespace from the end of elements
24- bool remove_empty = false ); // remove empty elements
23+ bool strip = false ,
24+ bool remove_empty = false );
2525
2626void split_string (
2727 const std::string &s,
You can’t perform that action at this time.
0 commit comments