blob: e60f422a2f77ca5743416018cd96d3d67d0ed518 (
plain) (
blame)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#include <bfc/bfc_assert.h>
#include "pathparse.h"
PathParserW::PathParserW(const wchar_t *_str, const wchar_t *sep, int uniquestrs) :
processed(FALSE), str(_str ? _str : L""), separators(sep), uniques(uniquestrs)
{
ASSERT(sep != NULL);
}
int PathParserW::getNumStrings() {
process();
return strings.getNumItems();
}
wchar_t *PathParserW::enumString(int i) {
process();
return strings[i];
}
wchar_t *PathParserW::enumStringSafe(int i, wchar_t *def_val) {
wchar_t *ret = enumString(i);
if (ret == NULL) ret = def_val;
return ret;
}
void PathParserW::process() {
if (processed) return;
processed = 1;
preProcess(str);
wchar_t *nonconst = str.getNonConstVal();
wchar_t *context=0;
wchar_t *pt = WCSTOK(nonconst, separators, &context);
if (pt == NULL) return;
postProcess(pt);
strings.addItem(pt);
for (;;) {
wchar_t *pt = WCSTOK(NULL, separators, &context);
if (pt == NULL) break;
postProcess(pt);
if (uniques) {
int exists = 0;
foreach(strings)
if (!WCSICMP(strings.getfor(), pt))
{
exists=1;
break;
}
endfor;
if (exists) continue;
}
strings.addItem(pt);
}
}
|