< index < 7. File parser < 7.3 Running the parser | ===================================== 7.4 Standard data types ===================================== | > 7.5 Using custom data types

The parser can parse natively several data types. It stores them in a generic union :

    typedef struct {
    	int nb_dices;
    	int nb_faces;
    	float multiplier;
    	float addsub;
    } TCOD_dice_t;

    typedef union {
    	bool b;
    	char c;
    	int32 i;
    	float f;
    	char *s;
    	TCOD_color_t col;
    	TCOD_dice_t dice;
    	TCOD_list_t list;
    	void *custom;
    } TCOD_value_t;

Possible types are defined by the TCOD_value_type_t enumeration :
For python, remove TCOD_ : libtcod.TYPE_BOOL

TCOD_value_type_t | Value in file | TCOD_value_t
--- | --- | ---
TCOD_TYPE_BOOL | true false | value.b == true/false
TCOD_TYPE_CHAR | decimal notation : 0 .. 255 hexadecimal notation : 0x00 .. 0xff char notation : 'a' ';' ... Special characters : '\n' : carriage return (ascii 13) '\t' : tabulation (ascii 9) '\r' : line feed (ascii 10) '\\' : antislash (ascii 92) '\"' : double-quote (ascii 34) '\'' : simple quote (ascii 39) '\xHH' : hexadecimal value, same as 0xHH, HH between 0 and FF '\NNN' : octal value, NNN between 0 and 377 | value.c == The corresponding ascii code
TCOD_TYPE_INT | decimal notation : -2147483648 .. 2147483647 hexadecimal notation : 0x0 .. 0xFFFFFFFF | value.i == the integer value
TCOD_TYPE_FLOAT | Any format parsable by atof. Examples: 3.14159 1.25E-3 | value.f == the float value
TCOD_TYPE_STRING | A double-quote delimited string : "This is a string" Support the same special characters as TCOD_TYPE_CHAR. | value.s == the corresponding string. Warning ! If you want to store this string, you have to duplicate it (with strdup) as it will be overwritten by the parser
TCOD_TYPE_COLOR | decimal notation : "16,32,64" hexadecimal notation : "#102040" | value.col == the color.
TCOD_TYPE_DICE | [multiplier x] nb_dices d nb_faces [(+|-) addsub] : "3d6" "3d6+2" "0.5x3d6-2" | value.dice == the dice components
TCOD_TYPE_VALUELISTxx | Same as TCOD_TYPE_STRING | value.s == the string value from the value list
TCOD_TYPE_LIST | [ <value1>,<value2>,... ] | value.list == the TCOD_list_t containing the elements

To define a list type, use the appropriate function (TCODParserStruct::addListProperty / TCOD_parser_add_list_property) and specify the type of the elements in the list. Lists of list are not supported.