R: [AD] Allegro 5 new config routines, alpha 1 |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> > The system seems to work fine, but I need more testing. So far I've
> > implemented al_set_bool, al_set_int, al_set_hex,
>
> ^^^^ ^^^^^
> Could I ask what's the difference in between the two?
That is purely for convenience: having an hex type different from a
plain int helps in situations like for example when you convert an hex
to string:
al_set_hex("test", 32);
printf("test = %s", al_get_string("test", NULL));
This will return "Test = 0x20"
An hex number may be also kept as hexadecimal in config files, though I
still haven't thought about how to handle these... The problem is that
on textual config files all the variables can be interpreted as
belonging to different types, so "1" could be interpreted as bool, int,
hex or even string. Prefixing/postfixing all variable names with a type
identifier into the file isn't pretty, but may solve the issue. We could
also make the config loading/saving routines to automatically add a
comment next to each variable, specifying the type; if Allegro doesn't
find such a comment or a bad one, it'll guess, otherwise the variable
will be stored with that type. For example:
Test = 32 # hex
When saving a config file, if the file already exists, its structure
will be preserved as much as possible (i.e. leaving hand-written
comments and spacing where they are).
Suggestions are welcome!
--
Angelo Mottola
a.mottola@xxxxxxxxxx
http://www.ecplusplus.com