# What do you think of this format?

This topic is 4524 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've been thinking up a good file format for storing data. It's kind of like a text/XML combo. Tell me what you think.
# This is a comment

# This is some info about the file
! Preference File Version 1.0.0

# Now some tags
window @size=800,600 #bpp=32 $title='Test Framework' windowed=false audio sound on=false music on=true volume=0.8  #### Share this post ##### Link to post ##### Share on other sites Advertisement I think that looks messy and hard to write: I made up this style for mine, which i think you'll agree is clearer. shader_list{ shader { _name : shader1; _path : "../Shaders/shader.fx"; _params : float4x4(M_WVP, "matWorldViewProj" ); }} Dave #### Share this post ##### Link to post ##### Share on other sites I have a question fo you both: why do you invent a text format for your specific use? There is already a lof of existing one (you cited XML, I can cite INI files (rather easy to use under Windows, a bit more tricky under linux but nothing too difficult). (I am very tired, so please don't blame me if I'm not polite enough: it is not intented at all) Regards, #### Share this post ##### Link to post ##### Share on other sites Quote:  Original post by Emmanuel DelogetI have a question fo you both: why do you invent a text format for your specific use? There is already a lof of existing one (you cited XML, I can cite INI files (rather easy to use under Windows, a bit more tricky under linux but nothing too difficult). (I am very tired, so please don't blame me if I'm not polite enough: it is not intented at all)Regards, Depending on needs, I guess. INI is rather limiting in the face it can only have a section and a key. What about sub sections? I still use INI to this day because it's simple, but sometimes people want something more and XML can be overkill. I also find it fun to do little things here and there. #### Share this post ##### Link to post ##### Share on other sites Quote:  Original post by Emmanuel DelogetI have a question fo you both: why do you invent a text format for your specific use? For the pure joy of opening up a file and seeing your own format lol...maybe it's because I'm a newbie in game programming, but its just nice I guess. On another note, I don't think you actually need to use formats such as xml for small projects where you're the only one reading the data and have no intent of expanding it in the future. #### Share this post ##### Link to post ##### Share on other sites I wrote something similer a year ago. It looked something like this # A Keyword declaration. Keywords are basically datatypes$Character:   Name,    Race,       Class;$Monster: Name, Species, Palette;# Actual rowsCharacter: Bob, Elf, Ranger;Character: Bill, Dorf, Paladin;Monster: Koopa, Turtle, Green;Monster: Goomba, Mushroom, Brown;Character: Luigi, Italian, Plumber; Getting data out of it is basically Config.GetString("Character", 2, "Name") would return Luigi. Or, if needed, you can declare your keywords in one file, and in a seperate file just put rows of data without a keyword in the start of the row, like $Monster:   Name,    Species,    Palette--------AND IN A DIFF FILE-----------------Koopa,    Turtle,    Green;Goomba,   Mushroom,  Brown;Beetle,   Beetle,    Gray;Birdo,    Freak,     Pink;

That feature existed mainly to read existing files that were made without consideration for my required keywords. Its one downside is a keywordless file has to only contain one type of data rows. If it mixes different types of data rows together it won't work.

It has another feature that makes it really flexible for existing files, is the marking characters between fields, and keywords, and end of lines, are all configurable. In the above examples it uses ':', ',', and ';'. But you can just as easily set it to use '_', '#', and '\n', and it will look for those characters. You can also set any to null, and it will look for any whitespace instead. I havn't tried it, but I think setting the markers all to null, and using a keyword like

\$MountObject MountPoint DevPoint FileSystem Flags UID GID

would read a /etc/fstab as a keywordless file too. That was sort of the goal. To make something that would read as many existing files as possible. (It reads INI's too somehow...)

XML is definatly frequently overkill, and you have to just find another library to help you use the XML anyway. And you need to bother with dtd's and whatnot too. And INI has no crossplatform support.

##### Share on other sites
Quote:
 Original post by Emmanuel DelogetI have a question fo you both: why do you invent a text format for your specific use? There is already a lof of existing one (you cited XML, I can cite INI files (rather easy to use under Windows, a bit more tricky under linux but nothing too difficult). (I am very tired, so please don't blame me if I'm not polite enough: it is not intented at all)Regards,

I have just ported it all to XML actually :D.

##### Share on other sites
There are a lot of good ideas around. Tinyn I like the idea you had about datatypes and separating characters.

XML is good and but it can be overkill. INI can be underkill. XML also is not nearly as easy to read or parse as INI.

But I have been wondering, is there a way to use PhysFS with TinyXML?

##### Share on other sites
XML look overkill, but in fact it is not, for at least two reasons:

• it is rather simple
• you dont have to write the parser :) (tinyxml is simple enough to be included in your projects)

Moreover, you designed your file format to look like XML - I believe that writing a parser to redo something that already exists is more overkill than using the existing XML parser :)

Quote:
 Original post by BoderBut I have been wondering, is there a way to use PhysFS with TinyXML?

What do you mean? TinyXML can read the file from the hard drive or from memory - using a asciiz buffer.

Regards,

##### Share on other sites
You make good points. I will probably end up using XML. I found something called xmllint, that made me laugh. Are DTD's and XSD's the overkill part for games? TinyXML is lightweight but Xerces is not so much. There are two types of XML parsers and I never know which one to use (SAX or DOM). See I start talking about XML and before I know it I'm over my head with TLA's! [grin]

XML does have a lot of markup, and is not that easy to write. Here is the first file in XML format.

<!-- This is a comment --><!-- This is some info about the file --><preference_file version="1.0.0" /><!-- Now some tags --><window width="800" height="600" bpp="32" title="Test Framework" windowed="0" /><audio> <sound on="0" /> <music on="1" volume="0.8" /></audio>

It's the little things like pushing shift to make <>, enclosing every attribute in quotes, and closing every tag.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631781
• Total Posts
3002314
×