Kodi Development  20.0
for Binary and Script based Add-Ons
1. Setting control

Detailed Description

Functions to handle settings access
This can be used to get and set the addon related values inside his settings.xml.

The settings style is given with installed part on e.g. $HOME/.kodi/addons/myspecial.addon/resources/settings.xml. The related edit becomes then stored inside $HOME/.kodi/userdata/addon_data/myspecial.addon/settings.xml.

Function Documentation

◆ IsSettingUsingDefault()

bool ATTRIBUTE_HIDDEN kodi::IsSettingUsingDefault ( const std::string &  settingName)
inline

Check the given setting name is set to default value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
Returns
true if setting is the default

◆ CheckSettingString()

bool ATTRIBUTE_HIDDEN kodi::CheckSettingString ( const std::string &  settingName,
std::string &  settingValue 
)
inline

Check and get a string setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[out]settingValueThe given setting value
Returns
true if setting was successfully found and "settingValue" is set
Note
If returns false, the "settingValue" is not changed.

Example:

#include <kodi/General.h>
std::string value;
if (!kodi::CheckSettingString("my_string_value", value))
value = "my_default_if_setting_not_work";
bool ATTRIBUTE_HIDDEN CheckSettingString(const std::string &settingName, std::string &settingValue)
Check and get a string setting value.
Definition: AddonBase.h:815

◆ GetSettingString()

std::string ATTRIBUTE_HIDDEN kodi::GetSettingString ( const std::string &  settingName,
const std::string &  defaultValue = "" 
)
inline

Get string setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[in]defaultValue[opt] Default value if not found
Returns
The value of setting, empty if not found;

Example:

#include <kodi/General.h>
std::string value = kodi::GetSettingString("my_string_value");
std::string ATTRIBUTE_HIDDEN GetSettingString(const std::string &settingName, const std::string &defaultValue="")
Get string setting value.
Definition: AddonBase.h:852

◆ SetSettingString()

void ATTRIBUTE_HIDDEN kodi::SetSettingString ( const std::string &  settingName,
const std::string &  settingValue 
)
inline

Set string setting of addon.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of setting
[in]settingValueThe setting value to write

Example:

#include <kodi/General.h>
std::string value = "my_new_name for";
kodi::SetSettingString("my_string_value", value);
void ATTRIBUTE_HIDDEN SetSettingString(const std::string &settingName, const std::string &settingValue)
Set string setting of addon.
Definition: AddonBase.h:880

◆ CheckSettingInt()

bool ATTRIBUTE_HIDDEN kodi::CheckSettingInt ( const std::string &  settingName,
int &  settingValue 
)
inline

Check and get a integer setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[out]settingValueThe given setting value
Returns
true if setting was successfully found and "settingValue" is set
Note
If returns false, the "settingValue" is not changed.

Example:

#include <kodi/General.h>
int value = 0;
if (!kodi::CheckSettingInt("my_integer_value", value))
value = 123; // My default of them
bool ATTRIBUTE_HIDDEN CheckSettingInt(const std::string &settingName, int &settingValue)
Check and get a integer setting value.
Definition: AddonBase.h:913

◆ GetSettingInt()

int ATTRIBUTE_HIDDEN kodi::GetSettingInt ( const std::string &  settingName,
int  defaultValue = 0 
)
inline

Get integer setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[in]defaultValue[opt] Default value if not found
Returns
The value of setting, 0 or defaultValue if not found

Example:

#include <kodi/General.h>
int value = kodi::GetSettingInt("my_integer_value");
int ATTRIBUTE_HIDDEN GetSettingInt(const std::string &settingName, int defaultValue=0)
Get integer setting value.
Definition: AddonBase.h:941

◆ SetSettingInt()

void ATTRIBUTE_HIDDEN kodi::SetSettingInt ( const std::string &  settingName,
int  settingValue 
)
inline

Set integer setting of addon.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of setting
[in]settingValueThe setting value to write

Example:

#include <kodi/General.h>
int value = 123;
kodi::SetSettingInt("my_integer_value", value);
void ATTRIBUTE_HIDDEN SetSettingInt(const std::string &settingName, int settingValue)
Set integer setting of addon.
Definition: AddonBase.h:968

◆ CheckSettingBoolean()

bool ATTRIBUTE_HIDDEN kodi::CheckSettingBoolean ( const std::string &  settingName,
bool &  settingValue 
)
inline

Check and get a boolean setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[out]settingValueThe given setting value
Returns
true if setting was successfully found and "settingValue" is set
Note
If returns false, the "settingValue" is not changed.

Example:

#include <kodi/General.h>
bool value = false;
if (!kodi::CheckSettingBoolean("my_boolean_value", value))
value = true; // My default of them
bool ATTRIBUTE_HIDDEN CheckSettingBoolean(const std::string &settingName, bool &settingValue)
Check and get a boolean setting value.
Definition: AddonBase.h:1000

◆ GetSettingBoolean()

bool ATTRIBUTE_HIDDEN kodi::GetSettingBoolean ( const std::string &  settingName,
bool  defaultValue = false 
)
inline

Get boolean setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[in]defaultValue[opt] Default value if not found
Returns
The value of setting, false or defaultValue if not found

Example:

#include <kodi/General.h>
bool value = kodi::GetSettingBoolean("my_boolean_value");
bool ATTRIBUTE_HIDDEN GetSettingBoolean(const std::string &settingName, bool defaultValue=false)
Get boolean setting value.
Definition: AddonBase.h:1028

◆ SetSettingBoolean()

void ATTRIBUTE_HIDDEN kodi::SetSettingBoolean ( const std::string &  settingName,
bool  settingValue 
)
inline

Set boolean setting of addon.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of setting
[in]settingValueThe setting value to write

Example:

#include <kodi/General.h>
bool value = true;
kodi::SetSettingBoolean("my_boolean_value", value);
void ATTRIBUTE_HIDDEN SetSettingBoolean(const std::string &settingName, bool settingValue)
Set boolean setting of addon.
Definition: AddonBase.h:1056

◆ CheckSettingFloat()

bool ATTRIBUTE_HIDDEN kodi::CheckSettingFloat ( const std::string &  settingName,
float &  settingValue 
)
inline

Check and get a floating point setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[out]settingValueThe given setting value
Returns
true if setting was successfully found and "settingValue" is set
Note
If returns false, the "settingValue" is not changed.

Example:

#include <kodi/General.h>
float value = 0.0f;
if (!kodi::CheckSettingBoolean("my_float_value", value))
value = 1.0f; // My default of them

◆ GetSettingFloat()

float ATTRIBUTE_HIDDEN kodi::GetSettingFloat ( const std::string &  settingName,
float  defaultValue = 0.0f 
)
inline

Get floating point setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[in]defaultValue[opt] Default value if not found
Returns
The value of setting, 0.0 or defaultValue if not found

Example:

#include <kodi/General.h>
float value = kodi::GetSettingFloat("my_float_value");
float ATTRIBUTE_HIDDEN GetSettingFloat(const std::string &settingName, float defaultValue=0.0f)
Get floating point setting value.
Definition: AddonBase.h:1116

◆ SetSettingFloat()

void ATTRIBUTE_HIDDEN kodi::SetSettingFloat ( const std::string &  settingName,
float  settingValue 
)
inline

Set floating point setting of addon.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of setting
[in]settingValueThe setting value to write

Example:

#include <kodi/General.h>
float value = 1.0f;
kodi::SetSettingFloat("my_float_value", value);
void ATTRIBUTE_HIDDEN SetSettingFloat(const std::string &settingName, float settingValue)
Set floating point setting of addon.
Definition: AddonBase.h:1144

◆ CheckSettingEnum()

bool ATTRIBUTE_HIDDEN kodi::CheckSettingEnum ( const std::string &  settingName,
enumType &  settingValue 
)
inline

Check and get a enum setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[out]settingValueThe given setting value
Returns
true if setting was successfully found and "settingValue" is set
Remarks
The enums are used as integer inside settings.xml.
Note
If returns false, the "settingValue" is not changed.

Example:

#include <kodi/General.h>
enum myEnumValue
{
valueA,
valueB,
valueC
};
myEnumValue value;
if (!kodi::CheckSettingEnum<myEnumValue>("my_enum_value", value))
value = valueA; // My default of them

◆ GetSettingEnum()

enumType ATTRIBUTE_HIDDEN kodi::GetSettingEnum ( const std::string &  settingName,
enumType  defaultValue = static_cast<enumType>(0) 
)
inline

Get enum setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[in]defaultValue[opt] Default value if not found
Returns
The value of setting, forced to 0 or defaultValue if not found
Remarks
The enums are used as integer inside settings.xml.

Example:

#include <kodi/General.h>
enum myEnumValue
{
valueA,
valueB,
valueC
};
myEnumValue value = kodi::GetSettingEnum<myEnumValue>("my_enum_value");

◆ SetSettingEnum()

void ATTRIBUTE_HIDDEN kodi::SetSettingEnum ( const std::string &  settingName,
enumType  settingValue 
)
inline

Set enum setting of addon.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of setting
[in]settingValueThe setting value to write
Remarks
The enums are used as integer inside settings.xml.

Example:

#include <kodi/General.h>
enum myEnumValue
{
valueA,
valueB,
valueC
};
myEnumValue value = valueA;
kodi::SetSettingEnum<myEnumValue>("my_enum_value", value);