diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2007-12-20 20:23:56 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2007-12-20 20:23:56 (GMT) |
commit | 03dce043b78103a977bd6c48b81bb1b462aaac5f (patch) | |
tree | 6cc49956acf8c4049f7d6702058534d29c1c15c2 /src/FbTk | |
parent | b90a7e21a9f56f8e9f92c7ec357cbf683e6fd712 (diff) | |
download | fluxbox-03dce043b78103a977bd6c48b81bb1b462aaac5f.zip fluxbox-03dce043b78103a977bd6c48b81bb1b462aaac5f.tar.bz2 |
added ForEach key command
Diffstat (limited to 'src/FbTk')
-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 |