header movement #1 - reduced usage of TextParsers.h
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401412
This commit is contained in:
parent
269c0f2877
commit
017da078ef
@ -31,12 +31,12 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <ITextParsers.h>
|
||||||
#include "AdminCache.h"
|
#include "AdminCache.h"
|
||||||
#include "ShareSys.h"
|
#include "ShareSys.h"
|
||||||
#include "ForwardSys.h"
|
#include "ForwardSys.h"
|
||||||
#include "PlayerManager.h"
|
#include "PlayerManager.h"
|
||||||
#include "ConCmdManager.h"
|
#include "ConCmdManager.h"
|
||||||
#include "TextParsers.h"
|
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "sourcemod.h"
|
#include "sourcemod.h"
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
@ -89,10 +89,10 @@ private:
|
|||||||
m_bFileNameLogged = false;
|
m_bFileNameLogged = false;
|
||||||
g_SourceMod.BuildPath(Path_SM, m_File, sizeof(m_File), "configs/admin_levels.cfg");
|
g_SourceMod.BuildPath(Path_SM, m_File, sizeof(m_File), "configs/admin_levels.cfg");
|
||||||
|
|
||||||
if ((error = g_TextParser.ParseFile_SMC(m_File, this, &line, NULL))
|
if ((error = textparsers->ParseFile_SMC(m_File, this, &line, NULL))
|
||||||
!= SMCParse_Okay)
|
!= SMCParse_Okay)
|
||||||
{
|
{
|
||||||
const char *err_string = g_TextParser.GetSMCErrorString(error);
|
const char *err_string = textparsers->GetSMCErrorString(error);
|
||||||
if (!err_string)
|
if (!err_string)
|
||||||
{
|
{
|
||||||
err_string = "Unknown error";
|
err_string = "Unknown error";
|
||||||
|
@ -29,9 +29,9 @@
|
|||||||
* Version: $Id$
|
* Version: $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <ITextParsers.h>
|
||||||
#include "ChatTriggers.h"
|
#include "ChatTriggers.h"
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
#include "TextParsers.h"
|
|
||||||
#include "ConCmdManager.h"
|
#include "ConCmdManager.h"
|
||||||
|
|
||||||
/* :HACKHACK: We can't SH_DECL here because ConCmdManager.cpp does */
|
/* :HACKHACK: We can't SH_DECL here because ConCmdManager.cpp does */
|
||||||
@ -228,7 +228,7 @@ bool ChatTriggers::PreProcessTrigger(edict_t *pEdict, const char *args, bool is_
|
|||||||
size_t cmd_len = 0;
|
size_t cmd_len = 0;
|
||||||
const char *inptr = args;
|
const char *inptr = args;
|
||||||
while (*inptr != '\0'
|
while (*inptr != '\0'
|
||||||
&& !IsWhitespace(inptr)
|
&& !textparsers->IsWhitespace(inptr)
|
||||||
&& *inptr != '"'
|
&& *inptr != '"'
|
||||||
&& cmd_len < sizeof(cmd_buf) - 1)
|
&& cmd_len < sizeof(cmd_buf) - 1)
|
||||||
{
|
{
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
* Version: $Id$
|
* Version: $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <ITextParsers.h>
|
||||||
#include "CoreConfig.h"
|
#include "CoreConfig.h"
|
||||||
#include "sourcemod.h"
|
#include "sourcemod.h"
|
||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
@ -36,7 +37,6 @@
|
|||||||
#include "sm_version.h"
|
#include "sm_version.h"
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
#include "LibrarySys.h"
|
#include "LibrarySys.h"
|
||||||
#include "TextParsers.h"
|
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "PluginSys.h"
|
#include "PluginSys.h"
|
||||||
#include "ForwardSys.h"
|
#include "ForwardSys.h"
|
||||||
@ -115,10 +115,10 @@ void CoreConfig::Initialize()
|
|||||||
g_LibSys.PathFormat(filePath, sizeof(filePath), "%s/%s", g_SourceMod.GetGamePath(), corecfg);
|
g_LibSys.PathFormat(filePath, sizeof(filePath), "%s/%s", g_SourceMod.GetGamePath(), corecfg);
|
||||||
|
|
||||||
/* Parse config file */
|
/* Parse config file */
|
||||||
if ((err=g_TextParser.ParseFile_SMC(filePath, this, NULL, NULL)) != SMCParse_Okay)
|
if ((err=textparsers->ParseFile_SMC(filePath, this, NULL, NULL)) != SMCParse_Okay)
|
||||||
{
|
{
|
||||||
/* :TODO: This won't actually log or print anything :( - So fix that somehow */
|
/* :TODO: This won't actually log or print anything :( - So fix that somehow */
|
||||||
const char *error = g_TextParser.GetSMCErrorString(err);
|
const char *error = textparsers->GetSMCErrorString(err);
|
||||||
g_Logger.LogFatal("[SM] Error encountered parsing core config file: %s", error ? error : "");
|
g_Logger.LogFatal("[SM] Error encountered parsing core config file: %s", error ? error : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include "ShareSys.h"
|
#include "ShareSys.h"
|
||||||
#include "sourcemod.h"
|
#include "sourcemod.h"
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
#include "TextParsers.h"
|
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "ExtensionSys.h"
|
#include "ExtensionSys.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -84,12 +83,12 @@ void DBManager::OnSourceModLevelChange(const char *mapName)
|
|||||||
* potentially empty/corrupt list, which would be very bad.
|
* potentially empty/corrupt list, which would be very bad.
|
||||||
*/
|
*/
|
||||||
m_pConfigLock->Lock();
|
m_pConfigLock->Lock();
|
||||||
if ((err = g_TextParser.ParseFile_SMC(m_Filename, this, &line, NULL)) != SMCParse_Okay)
|
if ((err = textparsers->ParseFile_SMC(m_Filename, this, &line, NULL)) != SMCParse_Okay)
|
||||||
{
|
{
|
||||||
g_Logger.LogError("[SM] Detected parse error(s) in file \"%s\"", m_Filename);
|
g_Logger.LogError("[SM] Detected parse error(s) in file \"%s\"", m_Filename);
|
||||||
if (err != SMCParse_Custom)
|
if (err != SMCParse_Custom)
|
||||||
{
|
{
|
||||||
const char *txt = g_TextParser.GetSMCErrorString(err);
|
const char *txt = textparsers->GetSMCErrorString(err);
|
||||||
g_Logger.LogError("[SM] Line %d: %s", line, txt);
|
g_Logger.LogError("[SM] Line %d: %s", line, txt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "GameConfigs.h"
|
#include "GameConfigs.h"
|
||||||
#include "TextParsers.h"
|
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
#include "sourcemod.h"
|
#include "sourcemod.h"
|
||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
@ -504,12 +503,12 @@ bool CGameConfig::Reparse(char *error, size_t maxlength)
|
|||||||
sm_trie_clear(m_pProps);
|
sm_trie_clear(m_pProps);
|
||||||
sm_trie_clear(m_pKeys);
|
sm_trie_clear(m_pKeys);
|
||||||
|
|
||||||
if ((err=g_TextParser.ParseFile_SMC(path, this, NULL, NULL))
|
if ((err=textparsers->ParseFile_SMC(path, this, NULL, NULL))
|
||||||
!= SMCParse_Okay)
|
!= SMCParse_Okay)
|
||||||
{
|
{
|
||||||
if (error && (err != SMCParse_Custom))
|
if (error && (err != SMCParse_Custom))
|
||||||
{
|
{
|
||||||
const char *str = g_TextParser.GetSMCErrorString(err);
|
const char *str = textparsers->GetSMCErrorString(err);
|
||||||
snprintf(error, maxlength, "%s", str);
|
snprintf(error, maxlength, "%s", str);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -39,11 +39,12 @@
|
|||||||
#include "ShareSys.h"
|
#include "ShareSys.h"
|
||||||
|
|
||||||
TextParsers g_TextParser;
|
TextParsers g_TextParser;
|
||||||
|
ITextParsers *textparsers = &g_TextParser;
|
||||||
|
|
||||||
static int g_ini_chartable1[255] = {0};
|
static int g_ini_chartable1[255] = {0};
|
||||||
static int g_ws_chartable[255] = {0};
|
static int g_ws_chartable[255] = {0};
|
||||||
|
|
||||||
bool IsWhitespace(const char *stream)
|
bool TextParsers::IsWhitespace(const char *stream)
|
||||||
{
|
{
|
||||||
return g_ws_chartable[(unsigned)*stream] == 1;
|
return g_ws_chartable[(unsigned)*stream] == 1;
|
||||||
}
|
}
|
||||||
|
@ -37,26 +37,6 @@
|
|||||||
|
|
||||||
using namespace SourceMod;
|
using namespace SourceMod;
|
||||||
|
|
||||||
inline unsigned int _GetUTF8CharBytes(const char *stream)
|
|
||||||
{
|
|
||||||
unsigned char c = *(unsigned char *)stream;
|
|
||||||
if (c & (1<<7))
|
|
||||||
{
|
|
||||||
if (c & (1<<5))
|
|
||||||
{
|
|
||||||
if (c & (1<<4))
|
|
||||||
{
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsWhitespace(const char *stream);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param void * IN: Stream pointer
|
* @param void * IN: Stream pointer
|
||||||
* @param char * IN/OUT: Stream buffer
|
* @param char * IN/OUT: Stream buffer
|
||||||
@ -88,6 +68,7 @@ public:
|
|||||||
unsigned int GetUTF8CharBytes(const char *stream);
|
unsigned int GetUTF8CharBytes(const char *stream);
|
||||||
|
|
||||||
const char *GetSMCErrorString(SMCParseError err);
|
const char *GetSMCErrorString(SMCParseError err);
|
||||||
|
bool IsWhitespace(const char *stream);
|
||||||
private:
|
private:
|
||||||
SMCParseError ParseString_SMC(const char *stream,
|
SMCParseError ParseString_SMC(const char *stream,
|
||||||
ITextListener_SMC *smc,
|
ITextListener_SMC *smc,
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "Translator.h"
|
#include "Translator.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "TextParsers.h"
|
|
||||||
#include "LibrarySys.h"
|
#include "LibrarySys.h"
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
#include "sourcemod.h"
|
#include "sourcemod.h"
|
||||||
@ -139,9 +138,9 @@ void CPhraseFile::ReparseFile()
|
|||||||
|
|
||||||
unsigned int line=0, col=0;
|
unsigned int line=0, col=0;
|
||||||
|
|
||||||
if ((err=g_TextParser.ParseFile_SMC(path, this, &line, &col)) != SMCParse_Okay)
|
if ((err=textparsers->ParseFile_SMC(path, this, &line, &col)) != SMCParse_Okay)
|
||||||
{
|
{
|
||||||
const char *msg = g_TextParser.GetSMCErrorString(err);
|
const char *msg = textparsers->GetSMCErrorString(err);
|
||||||
if (!msg)
|
if (!msg)
|
||||||
{
|
{
|
||||||
msg = m_ParseError.c_str();
|
msg = m_ParseError.c_str();
|
||||||
@ -271,7 +270,7 @@ SMCParseResult CPhraseFile::ReadSMC_KeyValue(const char *key, const char *value,
|
|||||||
} else if (*value == ',') {
|
} else if (*value == ',') {
|
||||||
/* Do nothing */
|
/* Do nothing */
|
||||||
} else {
|
} else {
|
||||||
unsigned int bytes = g_TextParser.GetUTF8CharBytes(value);
|
unsigned int bytes = textparsers->GetUTF8CharBytes(value);
|
||||||
if (bytes != 1 || !isalpha(*value))
|
if (bytes != 1 || !isalpha(*value))
|
||||||
{
|
{
|
||||||
ParseWarning("Invalid token '%c' in #format property on line %d.", *value, m_CurLine);
|
ParseWarning("Invalid token '%c' in #format property on line %d.", *value, m_CurLine);
|
||||||
@ -288,7 +287,7 @@ SMCParseResult CPhraseFile::ReadSMC_KeyValue(const char *key, const char *value,
|
|||||||
return SMCParse_Continue;
|
return SMCParse_Continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unsigned int bytes = g_TextParser.GetUTF8CharBytes(value);
|
unsigned int bytes = textparsers->GetUTF8CharBytes(value);
|
||||||
if (bytes != 1 || !isdigit(*value))
|
if (bytes != 1 || !isdigit(*value))
|
||||||
{
|
{
|
||||||
ParseWarning("Token '%c' in #format property on line %d is not a digit, phrase will be ignored.",
|
ParseWarning("Token '%c' in #format property on line %d is not a digit, phrase will be ignored.",
|
||||||
@ -521,7 +520,7 @@ SMCParseResult CPhraseFile::ReadSMC_KeyValue(const char *key, const char *value,
|
|||||||
unsigned int bytes;
|
unsigned int bytes;
|
||||||
while (*in_ptr != '\0')
|
while (*in_ptr != '\0')
|
||||||
{
|
{
|
||||||
bytes = g_TextParser.GetUTF8CharBytes(in_ptr);
|
bytes = textparsers->GetUTF8CharBytes(in_ptr);
|
||||||
if (bytes != 1)
|
if (bytes != 1)
|
||||||
{
|
{
|
||||||
goto scrap_point;
|
goto scrap_point;
|
||||||
@ -809,9 +808,9 @@ void Translator::RebuildLanguageDatabase(const char *lang_header_file)
|
|||||||
/* Start anew */
|
/* Start anew */
|
||||||
SMCParseError err;
|
SMCParseError err;
|
||||||
unsigned int line=0, col=0;
|
unsigned int line=0, col=0;
|
||||||
if ((err=g_TextParser.ParseFile_SMC(lang_header_file, this, &line, &col)) != SMCParse_Okay)
|
if ((err=textparsers->ParseFile_SMC(lang_header_file, this, &line, &col)) != SMCParse_Okay)
|
||||||
{
|
{
|
||||||
const char *str_err = g_TextParser.GetSMCErrorString(err);
|
const char *str_err = textparsers->GetSMCErrorString(err);
|
||||||
if (!str_err)
|
if (!str_err)
|
||||||
{
|
{
|
||||||
str_err = m_CustomError.c_str();
|
str_err = m_CustomError.c_str();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="8,00"
|
Version="8.00"
|
||||||
Name="sourcemod_mm"
|
Name="sourcemod_mm"
|
||||||
ProjectGUID="{E39527CD-7CAB-4420-97CC-DA1B93B260BC}"
|
ProjectGUID="{E39527CD-7CAB-4420-97CC-DA1B93B260BC}"
|
||||||
RootNamespace="sourcemod_mm"
|
RootNamespace="sourcemod_mm"
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
#include "TextParsers.h"
|
#include <ITextParsers.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
inline const char *_strstr(const char *str, const char *substr)
|
inline const char *_strstr(const char *str, const char *substr)
|
||||||
@ -294,7 +294,7 @@ static cell_t BreakString(IPluginContext *pContext, const cell_t *params)
|
|||||||
|
|
||||||
const char *inptr = input;
|
const char *inptr = input;
|
||||||
/* Eat up whitespace */
|
/* Eat up whitespace */
|
||||||
while (*inptr != '\0' && IsWhitespace(inptr))
|
while (*inptr != '\0' && textparsers->IsWhitespace(inptr))
|
||||||
{
|
{
|
||||||
inptr++;
|
inptr++;
|
||||||
}
|
}
|
||||||
@ -329,7 +329,7 @@ static cell_t BreakString(IPluginContext *pContext, const cell_t *params)
|
|||||||
} else {
|
} else {
|
||||||
start = inptr;
|
start = inptr;
|
||||||
/* Read input until we reach a space */
|
/* Read input until we reach a space */
|
||||||
while (*inptr != '\0' && !IsWhitespace(inptr))
|
while (*inptr != '\0' && !textparsers->IsWhitespace(inptr))
|
||||||
{
|
{
|
||||||
/* Update the end point, increment the stream. */
|
/* Update the end point, increment the stream. */
|
||||||
end = inptr++;
|
end = inptr++;
|
||||||
@ -356,7 +356,7 @@ static cell_t BreakString(IPluginContext *pContext, const cell_t *params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Consume more of the string until we reach non-whitespace */
|
/* Consume more of the string until we reach non-whitespace */
|
||||||
while (*inptr != '\0' && IsWhitespace(inptr))
|
while (*inptr != '\0' && textparsers->IsWhitespace(inptr))
|
||||||
{
|
{
|
||||||
inptr++;
|
inptr++;
|
||||||
}
|
}
|
||||||
@ -502,7 +502,7 @@ static cell_t TrimString(IPluginContext *pContext, const cell_t *params)
|
|||||||
char *end = str + chars - 1;
|
char *end = str + chars - 1;
|
||||||
|
|
||||||
/* Iterate backwards through string until we reach first non-whitespace char */
|
/* Iterate backwards through string until we reach first non-whitespace char */
|
||||||
while (end >= str && IsWhitespace(end))
|
while (end >= str && textparsers->IsWhitespace(end))
|
||||||
{
|
{
|
||||||
end--;
|
end--;
|
||||||
}
|
}
|
||||||
@ -511,7 +511,7 @@ static cell_t TrimString(IPluginContext *pContext, const cell_t *params)
|
|||||||
*(end + 1) = '\0';
|
*(end + 1) = '\0';
|
||||||
|
|
||||||
/* Iterate forwards through string until first non-whitespace char is reached */
|
/* Iterate forwards through string until first non-whitespace char is reached */
|
||||||
while (IsWhitespace(str))
|
while (textparsers->IsWhitespace(str))
|
||||||
{
|
{
|
||||||
str++;
|
str++;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
#include "TextParsers.h"
|
#include <ITextParsers.h>
|
||||||
#include "HandleSys.h"
|
#include "HandleSys.h"
|
||||||
|
|
||||||
HandleType_t g_TypeSMC = 0;
|
HandleType_t g_TypeSMC = 0;
|
||||||
@ -280,7 +280,7 @@ static cell_t SMC_ParseFile(IPluginContext *pContext, const cell_t *params)
|
|||||||
g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "%s", file);
|
g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "%s", file);
|
||||||
|
|
||||||
unsigned int line = 0, col = 0;
|
unsigned int line = 0, col = 0;
|
||||||
SMCParseError p_err = g_TextParser.ParseFile_SMC(path, parse, &line, &col);
|
SMCParseError p_err = textparsers->ParseFile_SMC(path, parse, &line, &col);
|
||||||
|
|
||||||
cell_t *c_line, *c_col;
|
cell_t *c_line, *c_col;
|
||||||
pContext->LocalToPhysAddr(params[3], &c_line);
|
pContext->LocalToPhysAddr(params[3], &c_line);
|
||||||
@ -294,7 +294,7 @@ static cell_t SMC_ParseFile(IPluginContext *pContext, const cell_t *params)
|
|||||||
|
|
||||||
static cell_t SMC_GetErrorString(IPluginContext *pContext, const cell_t *params)
|
static cell_t SMC_GetErrorString(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
const char *str = g_TextParser.GetSMCErrorString((SMCParseError)params[1]);
|
const char *str = textparsers->GetSMCErrorString((SMCParseError)params[1]);
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
{
|
{
|
||||||
|
@ -807,10 +807,10 @@ void CPluginManager::LoadAll_FirstPass(const char *config, const char *basedir)
|
|||||||
SMCParseError err;
|
SMCParseError err;
|
||||||
unsigned int line, col;
|
unsigned int line, col;
|
||||||
m_AllPluginsLoaded = false;
|
m_AllPluginsLoaded = false;
|
||||||
if ((err=g_TextParser.ParseFile_SMC(config, &m_PluginInfo, &line, &col)) != SMCParse_Okay)
|
if ((err=textparsers->ParseFile_SMC(config, &m_PluginInfo, &line, &col)) != SMCParse_Okay)
|
||||||
{
|
{
|
||||||
g_Logger.LogError("[SM] Encountered fatal error parsing file \"%s\"", config);
|
g_Logger.LogError("[SM] Encountered fatal error parsing file \"%s\"", config);
|
||||||
const char *err_msg = g_TextParser.GetSMCErrorString(err);
|
const char *err_msg = textparsers->GetSMCErrorString(err);
|
||||||
if (err_msg)
|
if (err_msg)
|
||||||
{
|
{
|
||||||
g_Logger.LogError("[SM] Parse error encountered: \"%s\"", err_msg);
|
g_Logger.LogError("[SM] Parse error encountered: \"%s\"", err_msg);
|
||||||
|
@ -362,7 +362,36 @@ namespace SourceMod
|
|||||||
* @return Number of bytes in current character.
|
* @return Number of bytes in current character.
|
||||||
*/
|
*/
|
||||||
virtual unsigned int GetUTF8CharBytes(const char *stream) =0;
|
virtual unsigned int GetUTF8CharBytes(const char *stream) =0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns whether the first multi-byte character in the given stream
|
||||||
|
* is a whitespace character.
|
||||||
|
*
|
||||||
|
* @param stream Pointer to multi-byte character string.
|
||||||
|
* @return True if first character is whitespace, false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool IsWhitespace(const char *stream) =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline unsigned int _GetUTF8CharBytes(const char *stream)
|
||||||
|
{
|
||||||
|
unsigned char c = *(unsigned char *)stream;
|
||||||
|
if (c & (1<<7))
|
||||||
|
{
|
||||||
|
if (c & (1<<5))
|
||||||
|
{
|
||||||
|
if (c & (1<<4))
|
||||||
|
{
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern SourceMod::ITextParsers *textparsers;
|
||||||
|
|
||||||
#endif //_INCLUDE_SOURCEMOD_TEXTPARSERS_INTERFACE_H_
|
#endif //_INCLUDE_SOURCEMOD_TEXTPARSERS_INTERFACE_H_
|
||||||
|
Loading…
Reference in New Issue
Block a user