hyperrealm / libconfig

C/C++ library for processing configuration files
https://hyperrealm.github.io/libconfig/
GNU Lesser General Public License v2.1
1.1k stars 360 forks source link

Feature request: override variable #167

Closed pa345 closed 4 years ago

pa345 commented 4 years ago

I would like to have a default config file with a bunch of settings, which is included by other config files. But then I want to override some default settings in the individual files. For example:

@include "default.cfg"

/ this variable is already defined in default.cfg but I want to change it / var_already_defined = another_value;

Unfortunately, in this scenario, libconfig will raise an error about duplicate variables. Would it be possible to allow over-riding variables in this manner?

thomastrapp commented 4 years ago

This feature is available in current master, via CONFIG_OPTION_ALLOW_OVERRIDES/Config::OptionAllowOverrides:

This option controls whether duplicate settings override previous settings with the same name. If this option is turned off, duplicate settings are rejected. By default this option is turned off.

pa345 commented 4 years ago

Thank you!