diff options
author | Ash Wolf <ninji@wuffs.org> | 2023-06-14 00:50:34 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2023-06-14 00:50:34 +0100 |
commit | 37e364b2c6cc7487a1c888d256a73e5337bb7189 (patch) | |
tree | eaf6e857382eef16c2dd940eb4125536fbe068bd /src/T2DLL/CTokenizer.cpp | |
download | t2win-37e364b2c6cc7487a1c888d256a73e5337bb7189.tar.gz t2win-37e364b2c6cc7487a1c888d256a73e5337bb7189.zip |
initial commit
Diffstat (limited to '')
-rw-r--r-- | src/T2DLL/CTokenizer.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/T2DLL/CTokenizer.cpp b/src/T2DLL/CTokenizer.cpp new file mode 100644 index 0000000..e205c0b --- /dev/null +++ b/src/T2DLL/CTokenizer.cpp @@ -0,0 +1,48 @@ +#include "CTokenizer.h" + +CTokenizer::CTokenizer(char *str, const char *newLineChars, const char *spaceChars) + : mNext(str) + , mCurrent(NULL) + , mNewLineChars(newLineChars) + , mSpaceChars(spaceChars) +{ +#line 31 + _ASSERT(mNext); + + if (!mNewLineChars) + mNewLineChars = "\r\n\t"; + if (!mSpaceChars) + mSpaceChars = " \r\n\t"; +} + +/*virtual*/ CTokenizer::~CTokenizer() { +} + +CTokenizer& CTokenizer::operator=(char *str) { + mNext = str; + mCurrent = NULL; + +#line 49 + _ASSERT(mNext); + return *this; +} + +const char* CTokenizer::NextToken(const char *delim) { +#line 58 + _ASSERT(delim); + + mCurrent = mNext; + + if (mNext) { + mNext = (char *) _mbspbrk((unsigned char *) mNext, (const unsigned char *) delim); + if (mNext) { + mNext[0] = 0; + mNext++; + mNext += _mbsspn((unsigned char *) mNext, (const unsigned char *) delim); + if (mNext[0] == 0) + mNext = NULL; + } + } + + return mCurrent; +} |