3 ms·
Show HN: Example C++ app using Hjson, CMake and Qt 5
- ftrobro 5y agoI 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.
- kwdc 5y agoI like this sort of thing. "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.
- ftrobro 5y agoI agree, and this way it's easy to use locally built custom variants of dependencies, by just pointing to the relevant build output.