From 37e364b2c6cc7487a1c888d256a73e5337bb7189 Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Wed, 14 Jun 2023 00:50:34 +0100 Subject: initial commit --- src/T2DLL/CTokenizer.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/T2DLL/CTokenizer.cpp (limited to 'src/T2DLL/CTokenizer.cpp') 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; +} -- cgit v1.2.3