10 Tokenize string, this should work for standard
11 strings aswell as Glib::ustring. This is a bit of a hack,
12 there are much better string tokenizing patterns out there.
14 template<typename StringType, typename Iter>
16 tokenize(const StringType& str,
17 const StringType& delims,
20 typename StringType::size_type start_pos = 0;
21 typename StringType::size_type end_pos = 0;
22 unsigned int token_count = 0;
25 start_pos = str.find_first_not_of(delims, start_pos);
26 end_pos = str.find_first_of(delims, start_pos);
27 if (start_pos != end_pos) {
28 if (end_pos == str.npos) {
29 end_pos = str.length();
31 *it++ = str.substr(start_pos, end_pos - start_pos);
33 start_pos = str.find_first_not_of(delims, end_pos + 1);
35 } while (start_pos != str.npos);
37 if (start_pos != str.npos) {
38 *it++ = str.substr(start_pos, str.length() - start_pos);
47 #endif // PBD_TOKENIZER