2007-01-25 23:36:38 +01:00
|
|
|
/**
|
2007-03-22 22:50:20 +01:00
|
|
|
* vim: set ts=4 :
|
2007-08-01 04:12:47 +02:00
|
|
|
* ================================================================
|
|
|
|
* SourceMod
|
|
|
|
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
|
|
|
|
* ================================================================
|
2007-01-25 23:36:38 +01:00
|
|
|
*
|
2007-08-01 04:12:47 +02:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License,
|
|
|
|
* version 3.0, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* As a special exception, AlliedModders LLC gives you permission to
|
|
|
|
* link the code of this program (as well as its derivative works) to
|
|
|
|
* "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any
|
|
|
|
* Game MODs that run on software by the Valve Corporation. You must
|
|
|
|
* obey the GNU General Public License in all respects for all other
|
|
|
|
* code used. Additionally, AlliedModders LLC grants this exception
|
|
|
|
* to all derivative works. AlliedModders LLC defines further
|
|
|
|
* exceptions, found in LICENSE.txt (as of this writing, version
|
|
|
|
* JULY-31-2007), or <http://www.sourcemod.net/license.php>.
|
2007-01-25 23:36:38 +01:00
|
|
|
*
|
|
|
|
* Version: $Id$
|
|
|
|
*/
|
|
|
|
|
2006-11-06 11:57:37 +01:00
|
|
|
#ifndef _INCLUDE_SOURCEMOD_TEXTPARSERS_H_
|
|
|
|
#define _INCLUDE_SOURCEMOD_TEXTPARSERS_H_
|
|
|
|
|
2007-01-19 06:33:04 +01:00
|
|
|
#include <ITextParsers.h>
|
2007-01-25 00:43:31 +01:00
|
|
|
#include "sm_globals.h"
|
2006-11-06 11:57:37 +01:00
|
|
|
|
|
|
|
using namespace SourceMod;
|
|
|
|
|
2006-11-07 01:53:06 +01:00
|
|
|
inline unsigned int _GetUTF8CharBytes(const char *stream)
|
2006-11-06 11:57:37 +01:00
|
|
|
{
|
2006-11-07 01:53:06 +01:00
|
|
|
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;
|
|
|
|
}
|
2006-11-06 11:57:37 +01:00
|
|
|
|
2007-03-16 21:10:13 +01:00
|
|
|
bool IsWhitespace(const char *stream);
|
|
|
|
|
2006-12-08 21:54:49 +01:00
|
|
|
/**
|
|
|
|
* @param void * IN: Stream pointer
|
|
|
|
* @param char * IN/OUT: Stream buffer
|
|
|
|
* @param size_t IN: Maximum size of buffer
|
|
|
|
* @param unsigned int * OUT: Number of bytes read (0 = end of stream)
|
|
|
|
* @return True on success, false on failure
|
|
|
|
*/
|
|
|
|
typedef bool (*STREAMREADER)(void *, char *, size_t, unsigned int *);
|
|
|
|
|
2007-03-15 05:45:17 +01:00
|
|
|
class TextParsers :
|
2007-01-25 00:43:31 +01:00
|
|
|
public ITextParsers,
|
|
|
|
public SMGlobalClass
|
2006-11-07 01:53:06 +01:00
|
|
|
{
|
2006-11-06 11:57:37 +01:00
|
|
|
public:
|
2007-03-15 05:45:17 +01:00
|
|
|
TextParsers();
|
2007-01-25 00:43:31 +01:00
|
|
|
public: //SMGlobalClass
|
|
|
|
void OnSourceModAllInitialized();
|
2006-11-06 11:57:37 +01:00
|
|
|
public:
|
2007-01-06 08:53:56 +01:00
|
|
|
bool ParseFile_INI(const char *file,
|
2006-11-06 11:57:37 +01:00
|
|
|
ITextListener_INI *ini_listener,
|
|
|
|
unsigned int *line,
|
|
|
|
unsigned int *col);
|
|
|
|
|
2007-01-06 08:53:56 +01:00
|
|
|
SMCParseError ParseFile_SMC(const char *file,
|
2006-11-06 11:57:37 +01:00
|
|
|
ITextListener_SMC *smc_listener,
|
|
|
|
unsigned int *line,
|
2006-12-08 21:54:49 +01:00
|
|
|
unsigned int *col);
|
2006-11-07 01:53:06 +01:00
|
|
|
|
2007-01-06 08:53:56 +01:00
|
|
|
unsigned int GetUTF8CharBytes(const char *stream);
|
|
|
|
|
|
|
|
const char *GetSMCErrorString(SMCParseError err);
|
2006-12-08 21:54:49 +01:00
|
|
|
private:
|
|
|
|
SMCParseError ParseString_SMC(const char *stream,
|
|
|
|
ITextListener_SMC *smc,
|
|
|
|
unsigned int *line,
|
|
|
|
unsigned int *col);
|
|
|
|
SMCParseError ParseStream_SMC(void *stream,
|
|
|
|
STREAMREADER srdr,
|
|
|
|
ITextListener_SMC *smc,
|
|
|
|
unsigned int *line,
|
|
|
|
unsigned int *col);
|
|
|
|
|
2006-11-06 11:57:37 +01:00
|
|
|
};
|
|
|
|
|
2007-03-15 05:45:17 +01:00
|
|
|
extern TextParsers g_TextParser;
|
2006-11-06 11:57:37 +01:00
|
|
|
|
|
|
|
#endif //_INCLUDE_SOURCEMOD_TEXTPARSERS_H_
|