forked from coolsee/OpenMugen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tokenizer.h
58 lines (44 loc) · 1.86 KB
/
tokenizer.h
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
57
58
#ifndef __OM_TOKENIZER__
#define __OM_TOKENIZER__
//Tokenizer by Nate Pendelton
class CTokenizer
{
public:
CTokenizer( int bufferSize = 256, char* commentChars = NULL, char** operators = NULL, int operatorCount = -1 );
~CTokenizer();
bool OpenFile( const char* filename ); // false if already open file or on fail
bool CloseFile(); // false if no file open
bool AtEndOfLine();
bool AtEndOfFile();
char* GetPartToken();
const char* GetToken();
bool GetToken( char* destString, int maxLength );
bool CheckToken( const char* stringToLookFor, bool consumeIfMatch = true );
bool CheckTokenIsNumber(); // returns true if token is a number
bool CheckTokenIsQuotedString(); // makes sure token is quoted string
int GetInt();
float GetFloat();
void SetIsCaseSensitive( bool b ) { m_IsCaseSensitive = b; }
void SetReturnNegativeSeperatelyFromNumber( bool b ) { m_ReturnNegativeSeperatelyFromNumber = b; }
const char* GetFileName() { return m_Filename; }
int GetLineNumber() { return m_CurrFileLine; }
int GetColumnNumber() { return m_CurrFilePos - m_LastLinePos; }
protected:
char* m_Buffer;
int m_BufferSize;
char m_Filename[ 256 ];
char* m_FileBuffer;
int m_FileSize;
int m_CurrFilePos;
int m_CurrFileLine;
int m_LastLinePos;
bool m_BufferIsNextToken, m_AtEndOfLine, m_AtEndOfFile;
char* m_CommentChars;
char** m_Operators;
int m_OperatorCount;
int m_NumOperatorCharsRead;
bool m_IsCaseSensitive;
bool m_ReturnNegativeSeperatelyFromNumber;
bool m_LastTokenWasQuotedString;
};
#endif