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