I have a configuration file system written in C++ which uses the yaml-cpp library to parse and write to YAML files. I have this as part of my static library.
I would like the ability to return a default value for a field that is requested by a user of the library (calling from their code), but which has not been defined in the user's YAML file.
For example say the user wants to use the field
int bar = config_reader.read<int>( "config.yaml", "foo" );
I would provide the defaults in a YAML file in a global (i.e. non-user specific place) and allow to override the values with user-specific ones. Consider just throwing an error if the global defaults are missing an entry, this will not happen by accident.
The global defaults you can put in
/etc/default/YOUBLIBNAME.yaml. The user's configuration nowadays mostly follows the XDG base directory specification. For that use
XDG_CONFIG_HOME is set in the environment, if not set use
If your library has to work under Windows, I would put the user specific data under
%APPDATA% in a subdir