getStringOpt#

Fully qualified name: carb::settings::getStringOpt

Defined in carb/settings/SettingsUtils.h

template<typename StringT = omni::string>
cpp::optional<StringT> carb::settings::getStringOpt(
const ISettings *settings,
cpp::string_view path,
)#

Retrieves a string from a string-type setting for simplicity.

Equivalent to:

ScopedLock lock(settings);
if (auto value = settings->getStringView(path))
    return StringT(*value);
return cpp::nullopt;

See also

ISettings::getStringBufferS, getStringAt()

Template Parameters:

StringT – The string type to return. Must be constructible from cpp::string_view. Defaults to omni::string.

Parameters:
  • settings – The acquired ISettings interface.

  • path – The setting key path to retrieve (must be a string or defaultValue will be returned).

Returns:

A cpp::optional object that both indicates whether the requested value could be retrieved and the string representation of the item value itself if the value could be retrieved.