diff options
Diffstat (limited to 'src/FbTk/StringUtil.hh')
-rw-r--r-- | src/FbTk/StringUtil.hh | 21 |
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 |
68 | void getFirstWord(const std::string &in, std::string &first, std::string &rest); | 68 | void getFirstWord(const std::string &in, std::string &first, std::string &rest); |
69 | 69 | ||
70 | template <typename Container> | ||
71 | static 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 |
71 | template <typename Container> | 92 | template <typename Container> |
72 | static void | 93 | static void |