Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
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::addon::OpenSettings ()
 Opens this Add-Ons settings dialog.
 
bool ATTR_DLL_LOCAL kodi::addon::IsSettingUsingDefault (const std::string &settingName)
 Check the given setting name is set to default value.
 
bool ATTR_DLL_LOCAL kodi::addon::CheckSettingString (const std::string &settingName, std::string &settingValue)
 Check and get a string setting value.
 
std::string ATTR_DLL_LOCAL kodi::addon::GetSettingString (const std::string &settingName, const std::string &defaultValue="")
 Get string setting value.
 
void ATTR_DLL_LOCAL kodi::addon::SetSettingString (const std::string &settingName, const std::string &settingValue)
 Set string setting of addon.
 
bool ATTR_DLL_LOCAL kodi::addon::CheckSettingInt (const std::string &settingName, int &settingValue)
 Check and get a integer setting value.
 
int ATTR_DLL_LOCAL kodi::addon::GetSettingInt (const std::string &settingName, int defaultValue=0)
 Get integer setting value.
 
void ATTR_DLL_LOCAL kodi::addon::SetSettingInt (const std::string &settingName, int settingValue)
 Set integer setting of addon.
 
bool ATTR_DLL_LOCAL kodi::addon::CheckSettingBoolean (const std::string &settingName, bool &settingValue)
 Check and get a boolean setting value.
 
bool ATTR_DLL_LOCAL kodi::addon::GetSettingBoolean (const std::string &settingName, bool defaultValue=false)
 Get boolean setting value.
 
void ATTR_DLL_LOCAL kodi::addon::SetSettingBoolean (const std::string &settingName, bool settingValue)
 Set boolean setting of addon.
 
bool ATTR_DLL_LOCAL kodi::addon::CheckSettingFloat (const std::string &settingName, float &settingValue)
 Check and get a floating point setting value.
 
float ATTR_DLL_LOCAL kodi::addon::GetSettingFloat (const std::string &settingName, float defaultValue=0.0f)
 Get floating point setting value.
 
void ATTR_DLL_LOCAL kodi::addon::SetSettingFloat (const std::string &settingName, float settingValue)
 Set floating point setting of addon.
 
template<typename enumType >
bool ATTR_DLL_LOCAL kodi::addon::CheckSettingEnum (const std::string &settingName, enumType &settingValue)
 Check and get a enum setting value.
 
template<typename enumType >
enumType ATTR_DLL_LOCAL kodi::addon::GetSettingEnum (const std::string &settingName, enumType defaultValue=static_cast< enumType >(0))
 Get enum setting value.
 
template<typename enumType >
void ATTR_DLL_LOCAL kodi::addon::SetSettingEnum (const std::string &settingName, enumType settingValue)
 Set enum setting of addon.
 

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::addon::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
enum const char const char * value
Definition addon_base.h:203

◆ CheckSettingEnum()

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

◆ CheckSettingString()

bool ATTR_DLL_LOCAL kodi::addon::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";

◆ GetSettingBoolean()

bool ATTR_DLL_LOCAL kodi::addon::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");

◆ GetSettingEnum()

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

◆ GetSettingInt()

int ATTR_DLL_LOCAL kodi::addon::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");

◆ GetSettingString()

std::string ATTR_DLL_LOCAL kodi::addon::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");

◆ IsSettingUsingDefault()

bool ATTR_DLL_LOCAL kodi::addon::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

◆ OpenSettings()

bool ATTR_DLL_LOCAL kodi::addon::OpenSettings ( )
inline

Opens this Add-Ons settings dialog.

Returns
true if settings were changed and the dialog confirmed, false otherwise.

Example:

#include <kodi/General.h>
..
kodi::OpenSettings();
..

◆ SetSettingBoolean()

void ATTR_DLL_LOCAL kodi::addon::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);

◆ SetSettingEnum()

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

◆ SetSettingInt()

void ATTR_DLL_LOCAL kodi::addon::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);

◆ SetSettingString()

void ATTR_DLL_LOCAL kodi::addon::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);