Class TCODParser

Class Documentation

class TCODParser

Public Functions

TCODParser()

Use this function to create a generic parser.

Then you’ll specialize this parser by defining the structures it can read.

TCODParser(const TCODParser&) = delete
TCODParser &operator=(const TCODParser&) = delete
TCODParser(TCODParser&&) = default
TCODParser &operator=(TCODParser&&) = default
TCODParserStruct *newStructure(const char *name)

TCODParser parser(); TCODParserStruct *itemTypeStruct = parser.newStructure(“item_type”);

TCOD_parser_t parser = TCOD_parser_new(); TCOD_parser_struct_t item_type_struct = TCOD_parser_new_struct(parser, “item_type”);

parser=libtcod.parser_new() item_type_struct = libtcod.parser_new_struct(parser, “item_type”)

Parameters
  • parser – In the C version, the parser handler, returned by TCOD_parser_new.

  • name – The name of the structure type (in the example, this would be “item_type”).

TCOD_value_type_t newCustomType(TCOD_parser_custom_t custom_type_parser)
void run(const char *filename, ITCODParserListener *listener = NULL)

Once you defined all the structure types and created your listener, you can start the actual parsing of the file :

Parameters
  • parser – In the C version, the parser handler, returned by TCOD_parser_new.

  • filename – The name of the text file to parse, absolute or relative to current directory.

  • listener – The listener containing the callbacks. Use NULL for the default listener

~TCODParser()

Once you’ve done with the file parsing, you can release the resources used by the parser :

Parameters

parser – In the C version, the parser handler, returned by TCOD_parser_new.

void error(const char *msg, ...)
bool hasProperty(const char *name) const
bool getBoolProperty(const char *name) const
int getIntProperty(const char *name) const
int getCharProperty(const char *name) const
float getFloatProperty(const char *name) const
TCODColor getColorProperty(const char *name) const
TCOD_dice_t getDiceProperty(const char *name) const
const char *getStringProperty(const char *name) const
void *getCustomProperty(const char *name) const
TCOD_list_t getListProperty(const char *name, TCOD_value_type_t type) const