Choice of file format


In most applications, you need to store the user’s data in some way.

For example a project, or document.
I need to choose the best format for doing this.
The file will contain all settings of the app, so there will be text, numbers (small and large)
and raw binary data.
As far as I can see, there are two options. XML or a custom binary format.
I have created chunk-based binary formats in the past, but I feel they are hard to maintain, and hard to make backward compatible and future proof.
XML is tempting, but I am a bit worried that there is something I have not thought about here.

What do you guys use in your applications?


My preferred option these days is to use a ValueTree, and then either save it as XML or binary, depending on whether or not it needs to be human-readable.


Thanks for the tip Jules!

I have worked a bit with the ValueTree and it is very handy indeed.
There are is couple of things I am unsure about though regarding how to design with the ValueTree in mind.

I’ll try to ask the question via an simple example.

Lets say you where creating a mixer with a flexible number of channels.
Each channel would of course be a class having parameters like Mute and volume.
Would you store these in a value tree owned by the channel class?
I have read somewhere on the forum that accessing the values in, for example, the audio process calls is a bad idea, with regards to speed and locking.

Is a better idea to have each parameter as a normal variable in the class and then have a method in each class that populates a ValueTree? This way when I need to save I can just call “saveToValueTree(ValueTree tree)”
Or do you keep the valuetree and the variables synced all the time?

As you see I’m a bit confused as to how best use it


Values and ValueTree aren't thread-safe, but we're working on some utlity classes for tracktion that should help with things like that, so they'll be released when we're happy that we've got the design right..