mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-21 06:06:25 +01:00
r269@gandalf: fugalh | 2006-08-03 20:18:05 -0600
Trunk merge conflicts resolved git-svn-id: svn://localhost/ardour2/branches/undo@756 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
b0b7234458
commit
79986643c0
372 changed files with 20759 additions and 10250 deletions
41
libs/pbd/strsplit.cc
Normal file
41
libs/pbd/strsplit.cc
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#include <pbd/strsplit.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void
|
||||
split (string str, vector<string>& result, char splitchar)
|
||||
{
|
||||
string::size_type pos;
|
||||
string remaining;
|
||||
string::size_type len = str.length();
|
||||
int cnt;
|
||||
|
||||
cnt = 0;
|
||||
|
||||
if (str.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (string::size_type n = 0; n < len; ++n) {
|
||||
if (str[n] == splitchar) {
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
if (cnt == 0) {
|
||||
result.push_back (str);
|
||||
return;
|
||||
}
|
||||
|
||||
remaining = str;
|
||||
|
||||
while ((pos = remaining.find_first_of (':')) != string::npos) {
|
||||
result.push_back (remaining.substr (0, pos));
|
||||
remaining = remaining.substr (pos+1);
|
||||
}
|
||||
|
||||
if (remaining.length()) {
|
||||
|
||||
result.push_back (remaining);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue