summaryrefslogtreecommitdiff
path: root/src/T2DLL/CTokenizer.h
blob: 080d5cd8285e9d25dd25fcf110410263c18bc1d4 (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
#pragma once
#include "common.h"

class AFX_CLASS_EXPORT CTokenizer {
public:
	CTokenizer(char *str, const char *newLineChars = NULL, const char *spaceChars = NULL);
	virtual ~CTokenizer();
	CTokenizer& operator=(char *str);

	const char* Current() const {
		return mCurrent;
	}

	const char* NextString(const char *delim = NULL) {
		return NextToken(delim ? delim : mNewLineChars);
	}

	const char* NextWord(const char *delim = NULL) {
		return NextToken(delim ? delim : mSpaceChars);
	}

	int NextInteger(const char *delim = NULL) {
		return atoi(NextToken(delim ? delim : mSpaceChars));
	}

protected:
	const char* NextToken(const char *delim);

	char *mNext;
	char *mCurrent;
	const char *mNewLineChars;
	const char *mSpaceChars;
};