RE: [GD-General] A portable preferences library
Brought to you by:
vexxed72
From: Ivan-Assen I. <as...@ha...> - 2003-12-05 12:36:10
|
> Okay, so back to the actual file format.... > > Originally I was thinking it would be a binary file format, strictly > because I wanted the ability to serialize raw binary data "just in > case". Now you could make a valid argument that you could always > convert to text, i.e. 3.14 becomes "3.14", but maybe you > don't want to > suffer a data conversion loss or something, I dunno. > > Point being that I'd rather not dictate policy if I don't have to. > > So instead of doing a UUEncode, I could do an inefficient translation > to ASCII by simply converting directly to ASCII. It would double in > size if I used hex, but it would still be editable in a text editor. > > So if you need to write out 0x12 0x9A 0xBC 0x55 to the key "foo" then > the file foo.pref would have: > > foo=129ABC55 > > Not efficient, but it works. If you are really opposed to using XML - after all, why would a "simple" preferences library need a big bad XML parser (answer: you'll likely need an XML parser in the game anyway...), you can play the revolutionary by using YAML: http://www.yaml.org quote from the site: YAML(tm) (rhymes with "camel") is a straightforward machine parsable data serialization format designed for human readability and interaction with scripting languages such as Perl and Python. YAML is optimized for data serialization, configuration settings, log files, Internet messaging and filtering. YAML(tm) is a balance of the following design goals: YAML documents are very readable by humans. YAML interacts well with scripting languages. YAML uses host languages' native data structures. YAML has a consistent information model. YAML enables stream-based processing. YAML is expressive and extensible. YAML is easy to implement. |