SourceMod SDK  1.7
SourceMod::ITextListener_INI Class Reference

Contains parse events for INI files. More...

#include <public/ITextParsers.h>

Public Member Functions

virtual unsigned int GetTextParserVersion1 ()
 Returns version number.
 
virtual bool ReadINI_NewSection (const char *section, bool invalid_tokens, bool close_bracket, bool extra_tokens, unsigned int *curtok)
 Called when a new section is encountered in an INI file. More...
 
virtual bool ReadINI_KeyValue (const char *key, const char *value, bool invalid_tokens, bool equal_token, bool quotes, unsigned int *curtok)
 Called when encountering a key/value pair in an INI file. More...
 
virtual bool ReadINI_RawLine (const char *line, unsigned int *curtok)
 Called after a line has been preprocessed, if it has text. More...
 

Detailed Description

Contains parse events for INI files.

The INI file format is defined as: WHITESPACE: 0x20,
, , IDENTIFIER: A-Z a-z 0-9 _ - , + . $ ? / STRING: Any set of symbols

Basic syntax is comprised of SECTIONs. A SECTION is defined as: [SECTIONNAME] OPTION OPTION OPTION...

SECTIONNAME is an IDENTIFIER. OPTION can be repeated any number of times, once per line. OPTION is defined as one of: KEY = "VALUE" KEY = VALUE KEY Where KEY is an IDENTIFIER and VALUE is a STRING.

WHITESPACE should always be omitted. COMMENTS should be stripped, and are defined as text occurring in: ;<TEXT>

Example file below. Note that The second line is technically invalid. The event handler must decide whether this should be allowed. –FILE BELOW– [gaben] hi = clams bye = "NO CLAMS"

[valve] cannot maintain products

Member Function Documentation

virtual bool SourceMod::ITextListener_INI::ReadINI_KeyValue ( const char *  key,
const char *  value,
bool  invalid_tokens,
bool  equal_token,
bool  quotes,
unsigned int *  curtok 
)
inlinevirtual

Called when encountering a key/value pair in an INI file.

Parameters
keyName of key.
valueString containing value (with quotes stripped, if any).
invalid_tokensWhether or not the key contained invalid tokens.
equal_tokenThere was an '=' sign present (in case the value is missing).
quotesWhether value was enclosed in quotes.
curtokContains the token index of the start of the value string. This can be changed when returning false.
Returns
True to keep parsing, false otherwise.
virtual bool SourceMod::ITextListener_INI::ReadINI_NewSection ( const char *  section,
bool  invalid_tokens,
bool  close_bracket,
bool  extra_tokens,
unsigned int *  curtok 
)
inlinevirtual

Called when a new section is encountered in an INI file.

Parameters
sectionName of section in between the [ and ] characters.
invalid_tokensTrue if invalid tokens were detected in the name.
close_bracketTrue if a closing bracket was detected, false otherwise.
extra_tokensTrue if extra tokens were detected on the line.
curtokContains current token in the line where the section name starts. You can add to this offset when failing to point to a token.
Returns
True to keep parsing, false otherwise.
virtual bool SourceMod::ITextListener_INI::ReadINI_RawLine ( const char *  line,
unsigned int *  curtok 
)
inlinevirtual

Called after a line has been preprocessed, if it has text.

Parameters
lineContents of line.
curtokPointer to optionally store failed position in string.
Returns
True to keep parsing, false otherwise.

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