-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathILanguageFileParser.h
86 lines (71 loc) · 1.65 KB
/
ILanguageFileParser.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef _INCLUDE_LANGFILEPARSER_H_
#define _INCLUDE_LANGFILEPARSER_H_
#include <IShareSys.h>
using namespace SourceMod;
#define SMINTERFACE_ILANGPARSER_NAME "IValveLanguageParser"
#define SMINTERFACE_ILANGPARSER_VERSION 10
#define MAX_KEY_LENGTH 128
#define MAX_PHRASE_LENGTH 4096
#ifdef _MSC_VER
using ucs2_t = wchar_t;
#else
using ucs2_t = char16_t;
#endif
enum ParseAction_t
{
Parse_Continue,
Parse_Halt,
Parse_HaltFail,
};
enum ParseError_t
{
ParseError_None,
ParseError_StreamOpen,
ParseError_StreamRead,
ParseError_Overflow,
ParseError_StreamEnd,
ParseError_InvalidToken,
ParseError_InvalidChar,
ParseError_SectionBegin,
ParseError_SectionEnd,
};
class ILanguageFileParserListener
{
public:
virtual ParseAction_t State_Started()
{
return Parse_Continue;
}
virtual ParseAction_t State_EnteredSection(const char* pszKey)
{
return Parse_Continue;
}
virtual ParseAction_t State_KeyValue(const char* pszKey, const char* pszValue)
{
return Parse_Continue;
}
virtual ParseAction_t State_LeftSection()
{
return Parse_Continue;
}
virtual void State_Ended(bool halted, bool failed)
{
}
};
class ILanguageFileParser :
public SMInterface
{
public:
const char* GetInterfaceName() override
{
return SMINTERFACE_ILANGPARSER_NAME;
}
unsigned int GetInterfaceVersion() override
{
return SMINTERFACE_ILANGPARSER_VERSION;
}
public:
virtual ParseError_t ParseFile(const char* pszRelativePath, ILanguageFileParserListener* pListener, char* error, size_t maxlength) = 0;
virtual ParseError_t ParseBuffer(const ucs2_t* pDataIn, ILanguageFileParserListener* pListener, char* error, size_t maxlength) = 0;
};
#endif // _INCLUDE_LANGFILEPARSER_H_