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