Maps SDK for C++ 1.0.0
Loading...
Searching...
No Matches
gem::SettingsService Class Reference

Manages SDK and application settings. More...

Inheritance diagram for gem::SettingsService:
Collaboration diagram for gem::SettingsService:

Public Member Functions

 SettingsService (const String &path)
 SettingsService created over the given path.
String getPath () noexcept
 Get the path where settings written using this SettingsService object are stored.
void flush () const noexcept
 Write any unsaved changes to permanent storage.
void writeToColdStorage ()
 Write any unsaved changes to permanent storage.
SettingsServicebeginGroup (const String &prefix) noexcept
 Start a group with the specified name.
SettingsServiceendGroup () noexcept
 End the current group.
String getGroup () const noexcept
 Get current group name.
SettingsServicesetValue (const String &key, const String &value) noexcept
 Set the value of specified settings key to the given String value.
SettingsServicesetValue (const String &key, const char *value) noexcept
 Set the value of specified settings key to the given const char* value.
SettingsServicesetValue (const String &key, const char16_t *value) noexcept
 Set the value of specified settings key to the given const char16_t* value.
SettingsServicesetValue (const String &key, bool value) noexcept
 Set the value of specified settings key to the given bool value.
SettingsServicesetValue (const String &key, int value) noexcept
 Set the value of specified settings key to the given int value.
SettingsServicesetValue (const String &key, double value) noexcept
 Set the value of specified settings key to the given double value.
SettingsServicesetValue (const String &key, LargeInteger value) noexcept
 Set the value of specified settings key to the given double value.
String getValue (const String &key, const String &defaultValue) noexcept
 Get String value for specified settings key.
template<typename TCharPtr>
String getValue (const String &key, const TCharPtr *defaultValue) noexcept
 Get String value for specified settings key.
bool getValue (const String &key, bool defaultValue) noexcept
 Get bool value for the specified settings key.
int getValue (const String &key, int defaultValue=0) noexcept
 Get int value for the specified settings key.
double getValue (const String &key, double defaultValue=0.) noexcept
 Get double value for the specified settings key.
LargeInteger getValue (const String &key, LargeInteger defaultValue) noexcept
 Get double value for the specified settings key.
int remove (const String &key) noexcept
 Remove the specified setting key.
SettingsServiceclear () noexcept
 Clear all settings ( groups and values ).

Detailed Description

Manages SDK and application settings.

Implements share-read / write Api object over ISettingsService.

Provides persistent configuration storage and access for SDK-level and feature-specific options.

Constructor & Destructor Documentation

◆ SettingsService()

gem::SettingsService::SettingsService ( const String & path)
inline

SettingsService created over the given path.

Parameters
[in]pathThe settings file path. Can be absolute or relative to the paths provided on the SDK initialization

Member Function Documentation

◆ beginGroup()

SettingsService & gem::SettingsService::beginGroup ( const String & prefix)
inlinenoexcept

Start a group with the specified name.

Parameters
[in]prefixThe group name
Returns
A reference to the object

◆ clear()

SettingsService & gem::SettingsService::clear ( )
inlinenoexcept

Clear all settings ( groups and values ).

Returns
A reference to the object

◆ endGroup()

SettingsService & gem::SettingsService::endGroup ( )
inlinenoexcept

End the current group.

Returns
A reference to the object

◆ flush()

void gem::SettingsService::flush ( ) const
inlinenoexcept

Write any unsaved changes to permanent storage.

This function is automatically called with 1s delay after last call of setValue. Call flush() after a setValue to ensure immediate sync with storage

◆ getGroup()

String gem::SettingsService::getGroup ( ) const
inlinenoexcept

Get current group name.

Returns
Return current user group name or "DEFAULT" if no user group is active ( default group is selected )

◆ getPath()

String gem::SettingsService::getPath ( )
inlinenoexcept

Get the path where settings written using this SettingsService object are stored.

Returns
The path where settings written using this SettingsService object are stored.

◆ getValue() [1/6]

bool gem::SettingsService::getValue ( const String & key,
bool defaultValue )
inlinenoexcept

Get bool value for the specified settings key.

If the setting doesn't exist, return defaultValue.

Parameters
[in]keyThe settings key
[in]defaultValueThe default value
Returns
The value of the specified settings key

◆ getValue() [2/6]

String gem::SettingsService::getValue ( const String & key,
const String & defaultValue )
inlinenoexcept

Get String value for specified settings key.

If the setting doesn't exist, return defaultValue.

Parameters
[in]keyThe settings key
[in]defaultValueThe default value
Returns
The value of the specified settings key

◆ getValue() [3/6]

template<typename TCharPtr>
String gem::SettingsService::getValue ( const String & key,
const TCharPtr * defaultValue )
inlinenoexcept

Get String value for specified settings key.

If the setting doesn't exist, return defaultValue.

Template Parameters
TCharPtr
Parameters
keyThe settings key
defaultValueThe default value
Returns
The value of the specified settings key

◆ getValue() [4/6]

double gem::SettingsService::getValue ( const String & key,
double defaultValue = 0. )
inlinenoexcept

Get double value for the specified settings key.

If the setting doesn't exist, return defaultValue.

Parameters
[in]keyThe settings key
[in]defaultValueThe default value
Returns
The value of the specified settings key

◆ getValue() [5/6]

int gem::SettingsService::getValue ( const String & key,
int defaultValue = 0 )
inlinenoexcept

Get int value for the specified settings key.

If the setting doesn't exist, return defaultValue.

Parameters
[in]keyThe settings key
[in]defaultValueThe default value
Returns
The value of the specified settings key

◆ getValue() [6/6]

LargeInteger gem::SettingsService::getValue ( const String & key,
LargeInteger defaultValue )
inlinenoexcept

Get double value for the specified settings key.

If the setting doesn't exist, return defaultValue.

Parameters
[in]keyThe settings key
[in]defaultValueThe default value
Returns
The value of the specified settings key

◆ remove()

int gem::SettingsService::remove ( const String & key)
inlinenoexcept

Remove the specified setting key.

Use '*' wildcard to remove all keys matching a pattern

Returns
Return the number of erased keys
Parameters
[in]keyThe settings key

◆ setValue() [1/7]

SettingsService & gem::SettingsService::setValue ( const String & key,
bool value )
inlinenoexcept

Set the value of specified settings key to the given bool value.

If the key already exists, the previous value is overwritten.

Parameters
[in]keyThe settings key
[in]valueThe settings value
Returns
A reference to the object

◆ setValue() [2/7]

SettingsService & gem::SettingsService::setValue ( const String & key,
const char * value )
inlinenoexcept

Set the value of specified settings key to the given const char* value.

If the key already exists, the previous value is overwritten.

Parameters
[in]keyThe settings key
[in]valueThe settings value
Returns
A reference to the object

◆ setValue() [3/7]

SettingsService & gem::SettingsService::setValue ( const String & key,
const char16_t * value )
inlinenoexcept

Set the value of specified settings key to the given const char16_t* value.

If the key already exists, the previous value is overwritten.

Parameters
[in]keyThe settings key
[in]valueThe settings value
Returns
A reference to the object

◆ setValue() [4/7]

SettingsService & gem::SettingsService::setValue ( const String & key,
const String & value )
inlinenoexcept

Set the value of specified settings key to the given String value.

If the key already exists, the previous value is overwritten.

Parameters
[in]keyThe settings key
[in]valueThe settings value
Returns
A reference to the object

◆ setValue() [5/7]

SettingsService & gem::SettingsService::setValue ( const String & key,
double value )
inlinenoexcept

Set the value of specified settings key to the given double value.

If the key already exists, the previous value is overwritten.

Parameters
[in]keyThe settings key
[in]valueThe settings value
Returns
A reference to the object

◆ setValue() [6/7]

SettingsService & gem::SettingsService::setValue ( const String & key,
int value )
inlinenoexcept

Set the value of specified settings key to the given int value.

If the key already exists, the previous value is overwritten.

Parameters
[in]keyThe settings key
[in]valueThe settings value
Returns
A reference to the object

◆ setValue() [7/7]

SettingsService & gem::SettingsService::setValue ( const String & key,
LargeInteger value )
inlinenoexcept

Set the value of specified settings key to the given double value.

If the key already exists, the previous value is overwritten.

Parameters
[in]keyThe settings key
[in]valueThe settings value
Returns
A reference to the object