2 * Copyright (C) 2000-2015 Paul Davis <paul@linuxaudiosystems.com>
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 along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "pbd/strsplit.h"
25 split (string str, vector<string>& result, char splitchar)
27 string::size_type pos;
29 string::size_type len = str.length();
38 for (string::size_type n = 0; n < len; ++n) {
39 if (str[n] == splitchar) {
45 result.push_back (str);
51 while ((pos = remaining.find_first_of (splitchar)) != string::npos) {
53 result.push_back (remaining.substr (0, pos));
55 remaining = remaining.substr (pos+1);
58 if (remaining.length()) {
60 result.push_back (remaining);
65 split (ustring str, vector<ustring>& result, char splitchar)
67 ustring::size_type pos;
69 ustring::size_type len = str.length();
78 for (ustring::size_type n = 0; n < len; ++n) {
79 if (str[n] == gunichar(splitchar)) {
85 result.push_back (str);
91 while ((pos = remaining.find_first_of (splitchar)) != ustring::npos) {
92 result.push_back (remaining.substr (0, pos));
93 remaining = remaining.substr (pos+1);
96 if (remaining.length()) {
98 result.push_back (remaining);