fyrenmoo@3129: /** fyrenmoo@3129: * vim: set ts=4 : fyrenmoo@3129: * ============================================================================= fyrenmoo@3129: * SourceMod fyrenmoo@3129: * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. fyrenmoo@3129: * ============================================================================= fyrenmoo@3129: * fyrenmoo@3129: * This program is free software; you can redistribute it and/or modify it under fyrenmoo@3129: * the terms of the GNU General Public License, version 3.0, as published by the fyrenmoo@3129: * Free Software Foundation. fyrenmoo@3129: * fyrenmoo@3129: * This program is distributed in the hope that it will be useful, but WITHOUT fyrenmoo@3129: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS fyrenmoo@3129: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more fyrenmoo@3129: * details. fyrenmoo@3129: * fyrenmoo@3129: * You should have received a copy of the GNU General Public License along with fyrenmoo@3129: * this program. If not, see . fyrenmoo@3129: * fyrenmoo@3129: * As a special exception, AlliedModders LLC gives you permission to link the fyrenmoo@3129: * code of this program (as well as its derivative works) to "Half-Life 2," the fyrenmoo@3129: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software fyrenmoo@3129: * by the Valve Corporation. You must obey the GNU General Public License in fyrenmoo@3129: * all respects for all other code used. Additionally, AlliedModders LLC grants fyrenmoo@3129: * this exception to all derivative works. AlliedModders LLC defines further fyrenmoo@3129: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), fyrenmoo@3129: * or . fyrenmoo@3129: * fyrenmoo@3129: * Version: $Id$ fyrenmoo@3129: */ fyrenmoo@3129: fyrenmoo@3129: #ifndef _INCLUDE_SOURCEMOD_TEXTPARSERS_H_ fyrenmoo@3129: #define _INCLUDE_SOURCEMOD_TEXTPARSERS_H_ fyrenmoo@3129: fyrenmoo@3129: #include fyrenmoo@3129: #include "gdc.h" fyrenmoo@3129: fyrenmoo@3129: using namespace SourceMod; fyrenmoo@3129: fyrenmoo@3129: /** fyrenmoo@3129: * @param void * IN: Stream pointer fyrenmoo@3129: * @param char * IN/OUT: Stream buffer fyrenmoo@3129: * @param size_t IN: Maximum size of buffer fyrenmoo@3129: * @param unsigned int * OUT: Number of bytes read (0 = end of stream) fyrenmoo@3129: * @return True on success, false on failure fyrenmoo@3129: */ fyrenmoo@3129: typedef bool (*STREAMREADER)(void *, char *, size_t, unsigned int *); fyrenmoo@3129: fyrenmoo@3129: class TextParsers : fyrenmoo@3129: public ITextParsers fyrenmoo@3129: { fyrenmoo@3129: public: fyrenmoo@3129: TextParsers(); fyrenmoo@3129: public: fyrenmoo@3129: bool ParseFile_INI(const char *file, fyrenmoo@3129: ITextListener_INI *ini_listener, fyrenmoo@3129: unsigned int *line, fyrenmoo@3129: unsigned int *col); fyrenmoo@3129: fyrenmoo@3129: SMCError ParseFile_SMC(const char *file, fyrenmoo@3129: ITextListener_SMC *smc_listener, fyrenmoo@3129: SMCStates *states); fyrenmoo@3129: fyrenmoo@3129: SMCError ParseSMCFile(const char *file, fyrenmoo@3129: ITextListener_SMC *smc_listener, fyrenmoo@3129: SMCStates *states, fyrenmoo@3129: char *buffer, fyrenmoo@3129: size_t maxsize); fyrenmoo@3129: fyrenmoo@3129: SMCError ParseSMCStream(const char *stream, fyrenmoo@3129: size_t length, fyrenmoo@3129: ITextListener_SMC *smc_listener, fyrenmoo@3129: SMCStates *states, fyrenmoo@3129: char *buffer, fyrenmoo@3129: size_t maxsize); fyrenmoo@3129: fyrenmoo@3129: unsigned int GetUTF8CharBytes(const char *stream); fyrenmoo@3129: fyrenmoo@3129: const char *GetSMCErrorString(SMCError err); fyrenmoo@3129: bool IsWhitespace(const char *stream); fyrenmoo@3129: private: fyrenmoo@3129: SMCError ParseStream_SMC(void *stream, fyrenmoo@3129: STREAMREADER srdr, fyrenmoo@3129: ITextListener_SMC *smc, fyrenmoo@3129: SMCStates *states); fyrenmoo@3129: fyrenmoo@3129: }; fyrenmoo@3129: fyrenmoo@3129: extern TextParsers g_TextParser; fyrenmoo@3129: fyrenmoo@3129: #endif //_INCLUDE_SOURCEMOD_TEXTPARSERS_H_ fyrenmoo@3129: