diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-04-14 09:29:01 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-04-14 09:29:01 +0000 |
commit | 14efff8cac3612ae7340e1f3ad791418c941468d (patch) | |
tree | de79e9f7666664d23b554c202f75fae93b5fc165 /plugins/!NotAdopted/name_day/utils | |
parent | 1e8ce03c8fe14ee1238e15c41391e1c7a5346d7c (diff) |
Add original sources for Name Day plugin from Tibor Szabo (not adopted)
git-svn-id: http://svn.miranda-ng.org/main/trunk@8969 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/!NotAdopted/name_day/utils')
-rw-r--r-- | plugins/!NotAdopted/name_day/utils/string_tokenizer.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/plugins/!NotAdopted/name_day/utils/string_tokenizer.h b/plugins/!NotAdopted/name_day/utils/string_tokenizer.h new file mode 100644 index 0000000000..3f8cf33200 --- /dev/null +++ b/plugins/!NotAdopted/name_day/utils/string_tokenizer.h @@ -0,0 +1,40 @@ +/** + * @brief tokenizer + * + */ +#ifndef string_tokenizer_h +#define string_tokenizer_h + +#include <string> +#include <vector> +using namespace std; + +static vector<string> string_tokenizer(const string &base_string, const string &delims) +{ + vector<string> tokens; + + // Skip delimiters at beginning. + string::size_type last_pos = base_string.find_first_not_of(delims, 0); + + // find first "non-delimiter". + string::size_type pos = base_string.find_first_of(delims, last_pos); + + while (string::npos != pos || string::npos != last_pos) { + + // found a token, add it to the vector. + + tokens.push_back(base_string.substr(last_pos, pos - last_pos)); + + // skip delimiters. + + last_pos = base_string.find_first_not_of(delims, pos); + + // find next "non-delimiter" + pos = base_string.find_first_of(delims, last_pos); + } + + return tokens; +} + + +#endif
\ No newline at end of file |