I started using Hjson for configuration files because I think it's just the right blend of JSON and YAML. Not too simple, not too complex. I have contributed to the project by creating the C++ implementation of Hjson, and now also a template repository that showcases best practices for a C++ GUI application using Hjson configuration files, Qt 5 Widgets and CMake.
One of the main features of the example application is that configuration values can be manipulated by the app and then written back to the configuration file at application exit. Comments, key order and indentation are all preserved when the configuration file is rewritten.
The example application is tested on Windows, Mac and Ubuntu. Will myself use it as starting point for any new C++ GUI application I create.
Do you have a contact email? I'd like to see if you'd be interested in writing a simple example app for a business I run (in bio). Feel free to hit me up on Keybase if you're interested (also in bio).
"The general idea is that the application code contains default values for all configuration keys, defaults that can be overruled by a config file read from disk at application startup. "
This should be expected of any application but many don't get this right.
"The CMake file for this example project does not automatically download Hjson or Qt 5. The headers and libs for Hjson and Qt 5 are expected to already exist on the local machine. "
Good call. Just flag dependencies as required, detect when not present and let developer sort it out. Control over dependencies is not to be overestimated. Plenty of developers need to lock the version used of many dependencies for stability reasons.
5 comments
[ 3.7 ms ] story [ 23.1 ms ] threadOne of the main features of the example application is that configuration values can be manipulated by the app and then written back to the configuration file at application exit. Comments, key order and indentation are all preserved when the configuration file is rewritten.
The example application is tested on Windows, Mac and Ubuntu. Will myself use it as starting point for any new C++ GUI application I create.
"The general idea is that the application code contains default values for all configuration keys, defaults that can be overruled by a config file read from disk at application startup. "
This should be expected of any application but many don't get this right.
"The CMake file for this example project does not automatically download Hjson or Qt 5. The headers and libs for Hjson and Qt 5 are expected to already exist on the local machine. "
Good call. Just flag dependencies as required, detect when not present and let developer sort it out. Control over dependencies is not to be overestimated. Plenty of developers need to lock the version used of many dependencies for stability reasons.