core/TextParsers.h
author David Anderson <dvander@alliedmods.net>
Sun Oct 14 21:31:39 2007 +0000 (2007-10-14)
changeset 1558 95a3d8bf618d
parent 1406 f5c07ec3c052
child 1656 b0b86d57530c
permissions -rw-r--r--
all pdbs are now packaged with windows
dvander@591
     1
/**
ds@653
     2
 * vim: set ts=4 :
ds@1330
     3
 * =============================================================================
dvander@1231
     4
 * SourceMod
dvander@1231
     5
 * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
ds@1330
     6
 * =============================================================================
dvander@591
     7
 *
ds@1330
     8
 * This program is free software; you can redistribute it and/or modify it under
ds@1330
     9
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330
    10
 * Free Software Foundation.
dvander@1231
    11
 * 
ds@1330
    12
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330
    13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330
    14
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1330
    15
 * details.
dvander@1231
    16
 *
ds@1330
    17
 * You should have received a copy of the GNU General Public License along with
ds@1330
    18
 * this program.  If not, see <http://www.gnu.org/licenses/>.
dvander@1231
    19
 *
ds@1330
    20
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330
    21
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330
    22
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330
    23
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1330
    24
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1330
    25
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1330
    26
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330
    27
 * or <http://www.sourcemod.net/license.php>.
dvander@591
    28
 *
dvander@591
    29
 * Version: $Id$
dvander@591
    30
 */
dvander@591
    31
dvander@591
    32
#ifndef _INCLUDE_SOURCEMOD_TEXTPARSERS_H_
dvander@591
    33
#define _INCLUDE_SOURCEMOD_TEXTPARSERS_H_
dvander@591
    34
dvander@591
    35
#include <ITextParsers.h>
dvander@591
    36
#include "sm_globals.h"
dvander@591
    37
dvander@591
    38
using namespace SourceMod;
dvander@591
    39
dvander@591
    40
/**
dvander@591
    41
 * @param void *			IN: Stream pointer
dvander@591
    42
 * @param char *			IN/OUT: Stream buffer
dvander@591
    43
 * @param size_t			IN: Maximum size of buffer
dvander@591
    44
 * @param unsigned int *	OUT: Number of bytes read (0 = end of stream)
dvander@591
    45
 * @return					True on success, false on failure
dvander@591
    46
 */
dvander@591
    47
typedef bool (*STREAMREADER)(void *, char *, size_t, unsigned int *);
dvander@591
    48
dvander@616
    49
class TextParsers : 
dvander@591
    50
	public ITextParsers,
dvander@591
    51
	public SMGlobalClass
dvander@591
    52
{
dvander@591
    53
public:
dvander@616
    54
	TextParsers();
dvander@591
    55
public: //SMGlobalClass
dvander@591
    56
	void OnSourceModAllInitialized();
dvander@591
    57
public:
dvander@591
    58
	bool ParseFile_INI(const char *file, 
dvander@591
    59
		ITextListener_INI *ini_listener,
dvander@591
    60
		unsigned int *line,
dvander@591
    61
		unsigned int *col);
dvander@591
    62
dvander@591
    63
	SMCParseError ParseFile_SMC(const char *file, 
dvander@591
    64
		ITextListener_SMC *smc_listener, 
dvander@591
    65
		unsigned int *line, 
dvander@591
    66
		unsigned int *col);
dvander@591
    67
dvander@591
    68
	unsigned int GetUTF8CharBytes(const char *stream);
dvander@591
    69
dvander@591
    70
	const char *GetSMCErrorString(SMCParseError err);
dvander@1406
    71
	bool IsWhitespace(const char *stream);
dvander@591
    72
private:
dvander@591
    73
	SMCParseError ParseString_SMC(const char *stream, 
dvander@591
    74
		ITextListener_SMC *smc,
dvander@591
    75
		unsigned int *line,
dvander@591
    76
		unsigned int *col);
dvander@591
    77
	SMCParseError ParseStream_SMC(void *stream, 
dvander@591
    78
		STREAMREADER srdr,
dvander@591
    79
		ITextListener_SMC *smc,
dvander@591
    80
		unsigned int *line, 
dvander@591
    81
		unsigned int *col);
dvander@591
    82
dvander@591
    83
};
dvander@591
    84
dvander@616
    85
extern TextParsers g_TextParser;
dvander@591
    86
dvander@591
    87
#endif //_INCLUDE_SOURCEMOD_TEXTPARSERS_H_