Kodi Docs 20.0
Kodi is an open source media player and entertainment hub.
1. Setting control

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

Functions

bool ATTR_DLL_LOCAL kodi::IsSettingUsingDefault (const std::string &settingName)
 Check the given setting name is set to default value. More...
 
bool ATTR_DLL_LOCAL kodi::CheckSettingString (const std::string &settingName, std::string &settingValue)
 Check and get a string setting value. More...
 
std::string ATTR_DLL_LOCAL kodi::GetSettingString (const std::string &settingName, const std::string &defaultValue="")
 Get string setting value. More...
 
void ATTR_DLL_LOCAL kodi::SetSettingString (const std::string &settingName, const std::string &settingValue)
 Set string setting of addon. More...
 
bool ATTR_DLL_LOCAL kodi::CheckSettingInt (const std::string &settingName, int &settingValue)
 Check and get a integer setting value. More...
 
int ATTR_DLL_LOCAL kodi::GetSettingInt (const std::string &settingName, int defaultValue=0)
 Get integer setting value. More...
 
void ATTR_DLL_LOCAL kodi::SetSettingInt (const std::string &settingName, int settingValue)
 Set integer setting of addon. More...
 
bool ATTR_DLL_LOCAL kodi::CheckSettingBoolean (const std::string &settingName, bool &settingValue)
 Check and get a boolean setting value. More...
 
bool ATTR_DLL_LOCAL kodi::GetSettingBoolean (const std::string &settingName, bool defaultValue=false)
 Get boolean setting value. More...
 
void ATTR_DLL_LOCAL kodi::SetSettingBoolean (const std::string &settingName, bool settingValue)
 Set boolean setting of addon. More...
 
bool ATTR_DLL_LOCAL kodi::CheckSettingFloat (const std::string &settingName, float &settingValue)
 Check and get a floating point setting value. More...
 
float ATTR_DLL_LOCAL kodi::GetSettingFloat (const std::string &settingName, float defaultValue=0.0f)
 Get floating point setting value. More...
 
void ATTR_DLL_LOCAL kodi::SetSettingFloat (const std::string &settingName, float settingValue)
 Set floating point setting of addon. More...
 
template<typename enumType >
bool ATTR_DLL_LOCAL kodi::CheckSettingEnum (const std::string &settingName, enumType &settingValue)
 Check and get a enum setting value. More...
 
template<typename enumType >
enumType ATTR_DLL_LOCAL kodi::GetSettingEnum (const std::string &settingName, enumType defaultValue=static_cast< enumType >(0))
 Get enum setting value. More...
 
template<typename enumType >
void ATTR_DLL_LOCAL kodi::SetSettingEnum (const std::string &settingName, enumType settingValue)
 Set enum setting of addon. More...
 

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

◆ CheckSettingBoolean()

bool ATTR_DLL_LOCAL 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 ATTR_DLL_LOCAL CheckSettingBoolean(const std::string &settingName, bool &settingValue)
Check and get a boolean setting value.
Definition: kodi-dev-kit/include/kodi/AddonBase.h:1010

◆ CheckSettingEnum()

template<typename enumType >
bool ATTR_DLL_LOCAL 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

◆ CheckSettingFloat()

bool ATTR_DLL_LOCAL 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

◆ CheckSettingInt()

bool ATTR_DLL_LOCAL 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 ATTR_DLL_LOCAL CheckSettingInt(const std::string &settingName, int &settingValue)
Check and get a integer setting value.
Definition: kodi-dev-kit/include/kodi/AddonBase.h:923

◆ CheckSettingString()

bool ATTR_DLL_LOCAL 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 ATTR_DLL_LOCAL CheckSettingString(const std::string &settingName, std::string &settingValue)
Check and get a string setting value.
Definition: kodi-dev-kit/include/kodi/AddonBase.h:824

◆ GetSettingBoolean()

bool ATTR_DLL_LOCAL 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 ATTR_DLL_LOCAL GetSettingBoolean(const std::string &settingName, bool defaultValue=false)
Get boolean setting value.
Definition: kodi-dev-kit/include/kodi/AddonBase.h:1038

◆ GetSettingEnum()

template<typename enumType >
enumType ATTR_DLL_LOCAL 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");

◆ GetSettingFloat()

float ATTR_DLL_LOCAL 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 ATTR_DLL_LOCAL GetSettingFloat(const std::string &settingName, float defaultValue=0.0f)
Get floating point setting value.
Definition: kodi-dev-kit/include/kodi/AddonBase.h:1126

◆ GetSettingInt()

int ATTR_DLL_LOCAL 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 ATTR_DLL_LOCAL GetSettingInt(const std::string &settingName, int defaultValue=0)
Get integer setting value.
Definition: kodi-dev-kit/include/kodi/AddonBase.h:951

◆ GetSettingString()

std::string ATTR_DLL_LOCAL 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 ATTR_DLL_LOCAL GetSettingString(const std::string &settingName, const std::string &defaultValue="")
Get string setting value.
Definition: kodi-dev-kit/include/kodi/AddonBase.h:862

◆ IsSettingUsingDefault()

bool ATTR_DLL_LOCAL 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

◆ SetSettingBoolean()

void ATTR_DLL_LOCAL 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 ATTR_DLL_LOCAL SetSettingBoolean(const std::string &settingName, bool settingValue)
Set boolean setting of addon.
Definition: kodi-dev-kit/include/kodi/AddonBase.h:1066

◆ SetSettingEnum()

template<typename enumType >
void ATTR_DLL_LOCAL 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);

◆ SetSettingFloat()

void ATTR_DLL_LOCAL 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 ATTR_DLL_LOCAL SetSettingFloat(const std::string &settingName, float settingValue)
Set floating point setting of addon.
Definition: kodi-dev-kit/include/kodi/AddonBase.h:1154

◆ SetSettingInt()

void ATTR_DLL_LOCAL 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 ATTR_DLL_LOCAL SetSettingInt(const std::string &settingName, int settingValue)
Set integer setting of addon.
Definition: kodi-dev-kit/include/kodi/AddonBase.h:978

◆ SetSettingString()

void ATTR_DLL_LOCAL 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 ATTR_DLL_LOCAL SetSettingString(const std::string &settingName, const std::string &settingValue)
Set string setting of addon.
Definition: kodi-dev-kit/include/kodi/AddonBase.h:890