< index < 7. File parser < 7.5 Using custom data types |
===================================== |
C++ : myParser.run(filename,NULL); C : TCOD_parser_run(my_parser,filename,NULL);
C++ : bool TCODParser::getBoolProperty(const char *name) const; int TCODParser::getIntProperty(const char *name) const; float TCODParser::getFloatProperty(const char *name) const; TCODColor TCODParser::getColorProperty(const char *name) const; TCOD_dice_t TCODParser::getDiceProperty(const char *name) const; const char * TCODParser::getStringProperty(const char *name) const; void * TCODParser::getCustomProperty(const char *name) const; TCOD_list_t TCODParser::getListProperty(const char *name, TCOD_value_type_t type) const; C : bool TCOD_parser_get_bool_property(TCOD_parser_t parser, const char *name); int TCOD_parser_get_int_property(TCOD_parser_t parser, const char *name); float TCOD_parser_get_float_property(TCOD_parser_t parser, const char *name); const char * TCOD_parser_get_string_property(TCOD_parser_t parser, const char *name); TCOD_color_t TCOD_parser_get_color_property(TCOD_parser_t parser, const char *name); TCOD_dice_t TCOD_parser_get_dice_property(TCOD_parser_t parser, const char *name); void * TCOD_parser_get_custom_property(TCOD_parser_t parser, const char *name); TCOD_list_t TCOD_parser_get_list_property(TCOD_parser_t parser, const char *name, TCOD_value_type_t type);
Parameter | Description |
---|---|
parser | In the C version, the parser handler, returned by TCOD_parser_new. |
name | The full name of the property in the form <structure>.<structure>.<propertyName>. |
type | For the list properties, the type of the list's elements |
video { mode = "800x600" availableModes = [ "800x600", "1024x768", "1280x1024" ] fullscreen = false } input { mouse { sensitivity = 0.5 } }You can read those properties with following code :
C++ : char *mode=parser.getStringProperty("video.mode"); TCODList<char *> availablesModes(parser.getListProperty("video.mode",TCOD_TYPE_STRING)); bool fullscreen = parser.getBoolProperty("video.fullscreen"); float mouseSensitivity = parser.getFloatProperty("input.mouse.sensitivity"); C : char *mode=TCOD_parser_get_string_property(parser,"video.mode"); TCOD_list_t availablesModes = TCOD_parser_get_list_property(parser,"video.mode",TCOD_TYPE_STRING)); bool fullscreen = TCOD_parser_get_bool_property(parser,"video.fullscreen"); float mouseSensitivity = TCOD_parser_get_float_property(parser,"input.mouse.sensitivity");