The title is pretty self-explanatory: does anyone know of a (good) properties file reader library for C or, if not, C++?
Edit: To be specific, I want a library which handles the .properties file format used in Java: http://en.wikipedia.org/wiki/.properties
STLSoft‘s 1.10 alpha contains a
platformstl::properties_fileclass. It can be used to read from a file:or from memory:
Looks like the latest 1.10 release has a bunch of comprehensive unit-tests, and that they’ve upgraded the class to handle all the rules and examples given in the Java documentation.
The only apparent rub is that the
value_typeis an instance ofstlsoft::basic_string_view(described in this Dr Dobb’s article), which is somewhat similar tostd::string, but doesn’t actually own its memory. Presumably they do this to avoid unneccessary allocations, presumably for performance reasons, which is something the STLSoft design holds dear. But it means that you can’t just writeYou can, however, do this:
and this:
I’m not sure I agree with this design decision, since how likely is it that reading properties – from file or from memory – is going to need the absolute last cycle. I think they should change it to use
std::stringby default, and then use the “string view” if explicitly required.Other than that, the
properties_fileclass looks like it does the trick.