diff options
author | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
---|---|---|
committer | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
commit | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Wasabi/bfc/parse/PathParseW.cpp | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/Wasabi/bfc/parse/PathParseW.cpp')
-rw-r--r-- | Src/Wasabi/bfc/parse/PathParseW.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Src/Wasabi/bfc/parse/PathParseW.cpp b/Src/Wasabi/bfc/parse/PathParseW.cpp new file mode 100644 index 00000000..e60f422a --- /dev/null +++ b/Src/Wasabi/bfc/parse/PathParseW.cpp @@ -0,0 +1,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); + } +} + |