added API for getting error messages
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40277
This commit is contained in:
parent
814007df49
commit
43005abc2f
@ -6,7 +6,7 @@
|
||||
#include <assert.h>
|
||||
#include "CTextParsers.h"
|
||||
|
||||
CTextParsers g_TextParse;
|
||||
CTextParsers g_TextParser;
|
||||
|
||||
static int g_ini_chartable1[255] = {0};
|
||||
static int g_ws_chartable[255] = {0};
|
||||
@ -898,3 +898,28 @@ event_failed:
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *CTextParsers::GetSMCErrorString(SMCParseError err)
|
||||
{
|
||||
static const char *s_errors[] =
|
||||
{
|
||||
NULL,
|
||||
"Stream failed to open",
|
||||
"Stream returned read error",
|
||||
NULL,
|
||||
"Un-quoted section has invalid tokens",
|
||||
"Section declared without header",
|
||||
"Section declared with unknown tokens",
|
||||
"Section ending without a matching section beginning",
|
||||
"Line contained too many invalid tokens",
|
||||
"Token buffer overflowed",
|
||||
"A property was declared outside of a section",
|
||||
};
|
||||
|
||||
if (err < SMCParse_Okay || err > SMCParse_InvalidProperty1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return s_errors[err];
|
||||
}
|
||||
|
@ -37,17 +37,19 @@ class CTextParsers : public ITextParsers
|
||||
public:
|
||||
CTextParsers();
|
||||
public:
|
||||
virtual bool ParseFile_INI(const char *file,
|
||||
bool ParseFile_INI(const char *file,
|
||||
ITextListener_INI *ini_listener,
|
||||
unsigned int *line,
|
||||
unsigned int *col);
|
||||
|
||||
virtual SMCParseError ParseFile_SMC(const char *file,
|
||||
SMCParseError ParseFile_SMC(const char *file,
|
||||
ITextListener_SMC *smc_listener,
|
||||
unsigned int *line,
|
||||
unsigned int *col);
|
||||
|
||||
virtual unsigned int GetUTF8CharBytes(const char *stream);
|
||||
unsigned int GetUTF8CharBytes(const char *stream);
|
||||
|
||||
const char *GetSMCErrorString(SMCParseError err);
|
||||
private:
|
||||
SMCParseError ParseString_SMC(const char *stream,
|
||||
ITextListener_SMC *smc,
|
||||
@ -61,6 +63,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
extern CTextParsers g_TextParse;
|
||||
extern CTextParsers g_TextParser;
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_TEXTPARSERS_H_
|
||||
|
@ -149,7 +149,7 @@ namespace SourceMod
|
||||
|
||||
enum SMCParseError
|
||||
{
|
||||
SMCParse_Okay, //no error
|
||||
SMCParse_Okay = 0, //no error
|
||||
SMCParse_StreamOpen, //stream failed to open
|
||||
SMCParse_StreamError, //the stream died... somehow
|
||||
SMCParse_Custom, //a custom handler threw an error
|
||||
@ -292,6 +292,15 @@ namespace SourceMod
|
||||
ITextListener_SMC *smc_listener,
|
||||
unsigned int *line,
|
||||
unsigned int *col) =0;
|
||||
|
||||
/**
|
||||
* @brief Converts an SMCParseError to a stirng.
|
||||
*
|
||||
* @param err SMCParseError.
|
||||
* @return String error message, or NULL if none.
|
||||
*/
|
||||
virtual const char *GetSMCErrorString(SMCParseError err) =0;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Returns the number of bytes that a multi-byte character contains in a UTF-8 stream.
|
||||
|
Loading…
Reference in New Issue
Block a user