aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/StringUtil.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/StringUtil.hh')
-rw-r--r--src/FbTk/StringUtil.hh21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/FbTk/StringUtil.hh b/src/FbTk/StringUtil.hh
index d3c131e..bca48bc 100644
--- a/src/FbTk/StringUtil.hh
+++ b/src/FbTk/StringUtil.hh
@@ -67,6 +67,27 @@ std::string::size_type removeTrailingWhitespace(std::string &str);
67/// splits input at first non-leading whitespace and returns both parts 67/// splits input at first non-leading whitespace and returns both parts
68void getFirstWord(const std::string &in, std::string &first, std::string &rest); 68void getFirstWord(const std::string &in, std::string &first, std::string &rest);
69 69
70template <typename Container>
71static void stringTokensBetween(Container &container, const std::string &in,
72 std::string &rest, char first, char last,
73 const char *ok_chars = " \t\n", bool allow_nesting = true) {
74
75 std::string token;
76 int err = 0, pos = 0;
77
78 while (true) {
79 err = getStringBetween(token, in.c_str() + pos, first, last, ok_chars,
80 allow_nesting);
81 if (err == 0)
82 break;
83 container.push_back(token);
84 pos += err;
85 }
86
87 rest = in.c_str() + pos;
88
89}
90
70/// Breaks a string into tokens 91/// Breaks a string into tokens
71template <typename Container> 92template <typename Container>
72static void 93static void