carb::settings::setDefaultAndGetSetting

Defined in omni/extras/SettingsHelpers.h

template<typename T>
T carb::settings::setDefaultAndGetSetting(const char *path, T defaultValue = {})

Sets a default value for a setting key and returns the current value.

Setting a default value will only have an effect if the setting key is not already present. The distinction between this function and getSettingOrDefault() is that this function will set the default value with the carb::settings::ISettings API. Any attempts to query the key directly will return the default value if it has not been modified.

Template Parameters

T – the type of the return value and default value

Parameters
  • path – The setting key path

  • defaultValue – The default value to set for the setting key if it does not exist

Returns

The current value read from path, which will be defaultValue if the setting key did not exist before this function was called.