SourceMod SDK  1.7
SourceMod::ITextParsers Class Referenceabstract

Contains various text stream parsing functions. More...

#include <public/ITextParsers.h>

Inheritance diagram for SourceMod::ITextParsers:
SourceMod::SMInterface

Public Member Functions

virtual const char * GetInterfaceName ()
 Must return a string defining the interface's unique name.
 
virtual unsigned int GetInterfaceVersion ()
 Must return an integer defining the interface's version.
 
virtual bool IsVersionCompatible (unsigned int version)
 Must return whether the requested version number is backwards compatible. Note: This can be overridden for breaking changes or custom versioning. More...
 
virtual bool ParseFile_INI (const char *file, ITextListener_INI *ini_listener, unsigned int *line, unsigned int *col)=0
 Parses an INI-format file. More...
 
virtual SMCError ParseFile_SMC (const char *file, ITextListener_SMC *smc_listener, SMCStates *states)=0
 Parses an SMC-format text file. Note that the parser makes every effort to obey broken syntax. For example, if an open brace is missing, but the section name has a colon, it will let you know. It is up to the event handlers to decide whether to be strict or not. More...
 
virtual const char * GetSMCErrorString (SMCError err)=0
 Converts an SMCError to a string. More...
 
virtual unsigned int GetUTF8CharBytes (const char *stream)=0
 Returns the number of bytes that a multi-byte character contains in a UTF-8 stream. If the current character is not multi-byte, the function returns 1. More...
 
virtual bool IsWhitespace (const char *stream)=0
 Returns whether the first multi-byte character in the given stream is a whitespace character. More...
 
virtual SMCError ParseSMCFile (const char *file, ITextListener_SMC *smc_listener, SMCStates *states, char *buffer, size_t maxsize)=0
 Same as ParseFile_SMC, but with an extended error buffer. More...
 
virtual SMCError ParseSMCStream (const char *stream, size_t length, ITextListener_SMC *smc_listener, SMCStates *states, char *buffer, size_t maxsize)=0
 Parses a raw UTF8 stream as an SMC file. More...
 

Detailed Description

Contains various text stream parsing functions.

Member Function Documentation

virtual const char* SourceMod::ITextParsers::GetSMCErrorString ( SMCError  err)
pure virtual

Converts an SMCError to a string.

Parameters
errSMCError.
Returns
String error message, or NULL if none.
virtual unsigned int SourceMod::ITextParsers::GetUTF8CharBytes ( const char *  stream)
pure virtual

Returns the number of bytes that a multi-byte character contains in a UTF-8 stream. If the current character is not multi-byte, the function returns 1.

Parameters
streamPointer to multi-byte ANSI character string.
Returns
Number of bytes in current character.
virtual bool SourceMod::ITextParsers::IsVersionCompatible ( unsigned int  version)
inlinevirtual

Must return whether the requested version number is backwards compatible. Note: This can be overridden for breaking changes or custom versioning.

Parameters
versionVersion number to compare against.
Returns
True if compatible, false otherwise.

Reimplemented from SourceMod::SMInterface.

virtual bool SourceMod::ITextParsers::IsWhitespace ( const char *  stream)
pure virtual

Returns whether the first multi-byte character in the given stream is a whitespace character.

Parameters
streamPointer to multi-byte character string.
Returns
True if first character is whitespace, false otherwise.
virtual bool SourceMod::ITextParsers::ParseFile_INI ( const char *  file,
ITextListener_INI ini_listener,
unsigned int *  line,
unsigned int *  col 
)
pure virtual

Parses an INI-format file.

Parameters
filePath to file.
ini_listenerEvent handler for reading file.
lineIf non-NULL, will contain last line parsed (0 if file could not be opened).
colIf non-NULL, will contain last column parsed (undefined if file could not be opened).
Returns
True if parsing succeeded, false if file couldn't be opened or there was a syntax error.
virtual SMCError SourceMod::ITextParsers::ParseFile_SMC ( const char *  file,
ITextListener_SMC smc_listener,
SMCStates states 
)
pure virtual

Parses an SMC-format text file. Note that the parser makes every effort to obey broken syntax. For example, if an open brace is missing, but the section name has a colon, it will let you know. It is up to the event handlers to decide whether to be strict or not.

Parameters
filePath to file.
smc_listenerEvent handler for reading file.
statesOptional pointer to store last known states.
Returns
An SMCError result code.
virtual SMCError SourceMod::ITextParsers::ParseSMCFile ( const char *  file,
ITextListener_SMC smc_listener,
SMCStates states,
char *  buffer,
size_t  maxsize 
)
pure virtual

Same as ParseFile_SMC, but with an extended error buffer.

Parameters
filePath to file.
smc_listenerEvent handler for reading file.
statesOptional pointer to store last known states.
bufferError message buffer.
maxsizeMaximum size of the error buffer.
Returns
Error code.
virtual SMCError SourceMod::ITextParsers::ParseSMCStream ( const char *  stream,
size_t  length,
ITextListener_SMC smc_listener,
SMCStates states,
char *  buffer,
size_t  maxsize 
)
pure virtual

Parses a raw UTF8 stream as an SMC file.

Parameters
streamMemory containing data.
lengthNumber of bytes in the stream.
smc_listenerEvent handler for reading file.
statesOptional pointer to store last known states.
bufferError message buffer.
maxsizeMaximum size of the error buffer.
Returns
Error code.

The documentation for this class was generated from the following file: