plugins/include/textparse.inc
branchsourcemod-1.1.0
changeset 2283 03a67e41afbc
parent 1951 c7b4237fff50
child 2287 017a725c9d17
     1.1 --- a/plugins/include/textparse.inc	Fri Mar 28 06:21:34 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,203 +0,0 @@
     1.4 -/**
     1.5 - * vim: set ts=4 :
     1.6 - * =============================================================================
     1.7 - * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     1.8 - * =============================================================================
     1.9 - *
    1.10 - * This file is part of the SourceMod/SourcePawn SDK.
    1.11 - *
    1.12 - * This program is free software; you can redistribute it and/or modify it under
    1.13 - * the terms of the GNU General Public License, version 3.0, as published by the
    1.14 - * Free Software Foundation.
    1.15 - * 
    1.16 - * This program is distributed in the hope that it will be useful, but WITHOUT
    1.17 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.18 - * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.19 - * details.
    1.20 - *
    1.21 - * You should have received a copy of the GNU General Public License along with
    1.22 - * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.23 - *
    1.24 - * As a special exception, AlliedModders LLC gives you permission to link the
    1.25 - * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.26 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.27 - * by the Valve Corporation.  You must obey the GNU General Public License in
    1.28 - * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.29 - * this exception to all derivative works.  AlliedModders LLC defines further
    1.30 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.31 - * or <http://www.sourcemod.net/license.php>.
    1.32 - *
    1.33 - * Version: $Id$
    1.34 - */
    1.35 - 
    1.36 -#if defined _textparse_included
    1.37 - #endinput
    1.38 -#endif
    1.39 -#define _textparse_included
    1.40 -
    1.41 -
    1.42 -/********************************
    1.43 - * Everything below describes the SMC Parse, or "SourceMod Configuration" format.
    1.44 - * This parser is entirely event based.  You must hook events to receive data.
    1.45 - * The file format itself is nearly identical to Valve's KeyValues format.
    1.46 - ********************************/
    1.47 -
    1.48 -/**
    1.49 - * Parse result directive.
    1.50 - */
    1.51 -enum SMCResult
    1.52 -{
    1.53 -	SMCParse_Continue,			/**< Continue parsing */
    1.54 -	SMCParse_Halt,				/**< Stop parsing here */
    1.55 -	SMCParse_HaltFail			/**< Stop parsing and return failure */
    1.56 -};
    1.57 -
    1.58 -/**
    1.59 - * Parse error codes.
    1.60 - */
    1.61 -enum SMCError
    1.62 -{
    1.63 -	SMCError_Okay = 0,			/**< No error */
    1.64 -	SMCError_StreamOpen,		/**< Stream failed to open */
    1.65 -	SMCError_StreamError,		/**< The stream died... somehow */
    1.66 -	SMCError_Custom,			/**< A custom handler threw an error */
    1.67 -	SMCError_InvalidSection1,	/**< A section was declared without quotes, and had extra tokens */
    1.68 -	SMCError_InvalidSection2,	/**< A section was declared without any header */
    1.69 -	SMCError_InvalidSection3,	/**< A section ending was declared with too many unknown tokens */
    1.70 -	SMCError_InvalidSection4,	/**< A section ending has no matching beginning */
    1.71 -	SMCError_InvalidSection5,	/**< A section beginning has no matching ending */
    1.72 -	SMCError_InvalidTokens,		/**< There were too many unidentifiable strings on one line */
    1.73 -	SMCError_TokenOverflow,		/**< The token buffer overflowed */
    1.74 -	SMCError_InvalidProperty1,	/**< A property was declared outside of any section */
    1.75 -};
    1.76 -
    1.77 -/**
    1.78 - * Creates a new SMC file format parser.  This is used to set parse hooks.
    1.79 - *
    1.80 - * @return			A new Handle to an SMC Parse structure.
    1.81 - */
    1.82 -native Handle:SMC_CreateParser();
    1.83 -
    1.84 -/**
    1.85 - * Parses an SMC file.
    1.86 - *
    1.87 - * @param smc			A Handle to an SMC Parse structure.
    1.88 - * @param file			A string containing the file path.
    1.89 - * @param line			An optional by reference cell to store the last line number read.
    1.90 - * @param col			An optional by reference cell to store the last column number read.
    1.91 - * @return				An SMCParseError result.
    1.92 - * @error				Invalid or corrupt Handle. 
    1.93 - */
    1.94 -native SMCError:SMC_ParseFile(Handle:smc, const String:file[], &line=0, &col=0);
    1.95 -
    1.96 -/**
    1.97 - * Gets an error string for an SMCError code.
    1.98 - * @note SMCError_Okay returns false.
    1.99 - * @note SMCError_Custom (which is thrown on SMCParse_HaltFail) returns false.
   1.100 - *
   1.101 - * @param error			The SMCParseError code.
   1.102 - * @param buffer		A string buffer for the error (contents undefined on failure).
   1.103 - * @param buf_max		The maximum size of the buffer.
   1.104 - * @return				True on success, false otherwise.
   1.105 - */
   1.106 -native bool:SMC_GetErrorString(SMCError:error, String:buffer[], buf_max);
   1.107 -
   1.108 -/**
   1.109 - * Called when parsing is started.
   1.110 - *
   1.111 - * @param smc			The SMC Parse Handle.
   1.112 - * @noreturn
   1.113 - */
   1.114 -functag SMC_ParseStart public(Handle:smc);
   1.115 -
   1.116 -/**
   1.117 - * Sets the SMC_ParseStart function of a parse Handle.
   1.118 - *
   1.119 - * @param smc			Handle to an SMC Parse.
   1.120 - * @param func			SMC_ParseStart function.
   1.121 - * @noreturn
   1.122 - * @error				Invalid or corrupt Handle. 
   1.123 - */
   1.124 -native SMC_SetParseStart(Handle:smc, SMC_ParseStart:func);
   1.125 -
   1.126 -/**
   1.127 - * Called when parsing is halted.
   1.128 - *
   1.129 - * @param smc			The SMC Parse Handle.
   1.130 - * @param halted		True if abnormally halted, false otherwise.
   1.131 - * @param failed		True if parsing failed, false otherwise.
   1.132 - * @noreturn
   1.133 - */
   1.134 -functag SMC_ParseEnd public(Handle:smc, bool:halted, bool:failed);
   1.135 -
   1.136 -/**
   1.137 - * Sets the SMC_ParseEnd of a parse handle.
   1.138 - *
   1.139 - * @param smc			Handle to an SMC Parse.
   1.140 - * @param func			SMC_ParseEnd function.
   1.141 - * @noreturn
   1.142 - * @error				Invalid or corrupt Handle. 
   1.143 - */
   1.144 -native SMC_SetParseEnd(Handle:smc, SMC_ParseEnd:func);
   1.145 -
   1.146 -/**
   1.147 - * Called when the parser is entering a new section or sub-section.
   1.148 - * @note Enclosing quotes are always stripped.
   1.149 - *
   1.150 - * @param smc			The SMC Parse Handle.
   1.151 - * @param name			String containing section name.
   1.152 - * @param opt_quotes	True if the section name was quote-enclosed in the file.
   1.153 - * @return				An SMCResult action to take.
   1.154 - */
   1.155 -functag SMC_NewSection SMCResult:public(Handle:smc, const String:name[], bool:opt_quotes);
   1.156 -
   1.157 -/**
   1.158 - * Called when the parser finds a new key/value pair.
   1.159 - * @note Enclosing quotes are always stripped.
   1.160 - *
   1.161 - * @param smc			The SMC Parse Handle.
   1.162 - * @param key			String containing key name.
   1.163 - * @param value			String containing value name.
   1.164 - * @param key_quotes	Whether or not the key was enclosed in quotes.
   1.165 - * @param value_quotes	Whether or not the value was enclosed in quotes.
   1.166 - * @return				An SMCResult action to take.
   1.167 - */
   1.168 -functag SMC_KeyValue SMCResult:public(Handle:smc, const String:key[], const String:value[], bool:key_quotes, bool:value_quotes);
   1.169 -
   1.170 -/**
   1.171 - * Called when the parser finds the end of the current section.
   1.172 - *
   1.173 - * @param smc			The SMC Parse Handle.
   1.174 - * @return				An SMCResult action to take.
   1.175 - */
   1.176 -functag SMC_EndSection SMCResult:public(Handle:smc);
   1.177 -
   1.178 -/**
   1.179 - * Sets the three main reader functions.
   1.180 - *
   1.181 - * @param smc			An SMC parse Handle.
   1.182 - * @param ns			An SMC_NewSection function pointer.
   1.183 - * @param kv			An SMC_KeyValue function pointer.
   1.184 - * @param es			An SMC_EndSection function pointer.
   1.185 - * @noreturn
   1.186 - */
   1.187 -native SMC_SetReaders(Handle:smc, SMC_NewSection:ns, SMC_KeyValue:kv, SMC_EndSection:es);
   1.188 -
   1.189 -/**
   1.190 - * Called whenever a raw line is read.
   1.191 - *
   1.192 - * @param smc			The SMC Parse Handle.
   1.193 - * @param line			A string containing the raw line from the file.
   1.194 - * @param lineno		The line number it occurs on.
   1.195 - * @return				An SMCResult action to take.
   1.196 - */
   1.197 -functag SMC_RawLine SMCResult:public(Handle:smc, const String:line[], lineno);
   1.198 -
   1.199 -/**
   1.200 - * Sets a raw line reader on an SMC parser Handle.
   1.201 - *
   1.202 - * @param smc			Handle to an SMC Parse.
   1.203 - * @param func			SMC_RawLine function.
   1.204 - * @noreturn
   1.205 - */
   1.206 -native SMC_SetRawLine(Handle:smc, SMC_RawLine:func);