blob: c60ad9683c73cd25a558206849e03f8c47ed4165 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include "slang-string-util.h"
namespace Slang {
/* static */void StringUtil::split(const UnownedStringSlice& in, char splitChar, List<UnownedStringSlice>& slicesOut)
{
slicesOut.Clear();
const char* start = in.begin();
const char* end = in.end();
while (start < end)
{
// Move cur so it's either at the end or at next split character
const char* cur = start;
while (cur < end && *cur != splitChar)
{
cur++;
}
// Add to output
slicesOut.Add(UnownedStringSlice(start, cur));
// Skip the split character, if at end we are okay anyway
start = cur + 1;
}
}
} // namespace Slang
|