summaryrefslogtreecommitdiff
path: root/src/T2DLL/CTokenizer.cpp
blob: b13b92e7effaf4fcbf8df4639c52ae3c14c429aa (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
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
56
#include "StdAfx.h"
#define DONT_INCLUDE_AFXTEMPL
#include "CTokenizer.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

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;
}