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