Public Member Functions

SourceMod::ITextParsers Class Reference

Contains various text stream parsing functions. More...

#include <public/ITextParsers.h>

Inherits SourceMod::SMInterface.

Collaboration diagram for SourceMod::ITextParsers:
Collaboration graph
[legend]

List of all members.

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.
virtual bool ParseFile_INI (const char *file, ITextListener_INI *ini_listener, unsigned int *line, unsigned int *col)=0
 Parses an INI-format file.
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.
virtual const char * GetSMCErrorString (SMCError err)=0
 Converts an SMCError to a string.
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.
virtual bool IsWhitespace (const char *stream)=0
 Returns whether the first multi-byte character in the given stream is a whitespace character.
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.
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.

Detailed Description

Contains various text stream parsing functions.

Definition at line 318 of file ITextParsers.h.


Member Function Documentation

virtual bool SourceMod::ITextParsers::IsVersionCompatible ( unsigned int  version  )  [inline, virtual]

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

Parameters:
version Version number to compare against.
Returns:
True if compatible, false otherwise.

Reimplemented from SourceMod::SMInterface.

Definition at line 329 of file ITextParsers.h.

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:
file Path to file.
ini_listener Event handler for reading file.
line If non-NULL, will contain last line parsed (0 if file could not be opened).
col If 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:
file Path to file.
smc_listener Event handler for reading file.
states Optional pointer to store last known states.
Returns:
An SMCError result code.
virtual const char* SourceMod::ITextParsers::GetSMCErrorString ( SMCError  err  )  [pure virtual]

Converts an SMCError to a string.

Parameters:
err SMCError.
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:
stream Pointer to multi-byte ANSI character string.
Returns:
Number of bytes in current character.
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:
stream Pointer to multi-byte character string.
Returns:
True if first character is whitespace, false otherwise.
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:
file Path to file.
smc_listener Event handler for reading file.
states Optional pointer to store last known states.
buffer Error message buffer.
maxsize Maximum 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:
stream Memory containing data.
length Number of bytes in the stream.
smc_listener Event handler for reading file.
states Optional pointer to store last known states.
buffer Error message buffer.
maxsize Maximum size of the error buffer.
Returns:
Error code.

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