2 Copyright (C) 2000-2007 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <pbd/strsplit.h>
26 split (string str, vector<string>& result, char splitchar)
28 string::size_type pos;
30 string::size_type len = str.length();
39 for (string::size_type n = 0; n < len; ++n) {
40 if (str[n] == splitchar) {
46 result.push_back (str);
52 while ((pos = remaining.find_first_of (splitchar)) != string::npos) {
53 result.push_back (remaining.substr (0, pos));
54 remaining = remaining.substr (pos+1);
57 if (remaining.length()) {
59 result.push_back (remaining);
64 split (ustring str, vector<ustring>& result, char splitchar)
66 ustring::size_type pos;
68 ustring::size_type len = str.length();
77 for (ustring::size_type n = 0; n < len; ++n) {
78 if (str[n] == gunichar(splitchar)) {
84 result.push_back (str);
90 while ((pos = remaining.find_first_of (splitchar)) != ustring::npos) {
91 result.push_back (remaining.substr (0, pos));
92 remaining = remaining.substr (pos+1);
95 if (remaining.length()) {
97 result.push_back (remaining);