I am starting work on a new piece of software that will end up needing some robust and expandable file IO. There are a lot of formats out there. XML, JSON, INI, etc. However, there are always plusses and minuses so I thought I would ask for some community input.
Here are some rough requirements:
- The format is a “standard”…I don’t want to reinvent the wheel if I don’t have to. It doesn’t have to be a formal IEEE standard, but something you could Google and get some information on as a new user, may have some support tools (editors) beyond vi. (Though the software users will generally be computer savvy and happy to use vi.)
- Easily integrates with C++. I don’t want to have to pull along a 100mb library and three different compilers to get it up and running.
- Supports tabular input (2d, n-dimensional)
- Supports POD types
- Can expand as more inputs are required, binds well to variables, etc.
- Parsing speed is not terribly important
- Ideally, as easy to write (reflect) as it is to read
- Works well on Windows and Linux
- Supports compositing (one file referencing another file to read, and so on.)
- Human Readable
In a perfect world, I would use a header-only library or some clean STL implementation, but I’m fine with leveraging Boost or some small external library if it works well.
So, what are your thoughts on various formats? Drawbacks? Advantages?
Edit
Options to consider? Anything else to add?
- XML
- YAML
- SQLite
- Google Protocol Buffers
- Boost Serialization
- INI
- JSON
For my purposes, I think the way to go is XML.
Thanks for all the great feedback! I think if we wanted a purely binary solution, Protocol Buffers or boost::serialization is likely the way that we would go.