Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches

Setting value handler
Inside addon main instance used helper class to give settings value. More...

Topics

 Value Help
 

Classes

class  kodi::addon::CSettingValue
 

Functions

const std::string & kodi::addon::CSettingValue::GetString () const
 To get settings value as string.
 
int kodi::addon::CSettingValue::GetInt () const
 To get settings value as integer.
 
unsigned int kodi::addon::CSettingValue::GetUInt () const
 To get settings value as unsigned integer.
 
bool kodi::addon::CSettingValue::GetBoolean () const
 To get settings value as boolean.
 
float kodi::addon::CSettingValue::GetFloat () const
 To get settings value as floating point.
 
template<typename enumType >
enumType kodi::addon::CSettingValue::GetEnum () const
 To get settings value as enum.
 

Detailed Description

Setting value handler
Inside addon main instance used helper class to give settings value.

This is used on addon::CAddonBase::SetSetting() to inform addon about settings change by used. This becomes then used to give the related value name.


The following table contains values that can be set with class CSettingValue :

Name Type Get call
Settings value as string std::string GetString
Settings value as integer int GetInt
Settings value as unsigned integer unsigned int GetUInt
Settings value as boolean bool GetBoolean
Settings value as floating point float GetFloat
Settings value as enum enum GetEnum

Here is a code example how this is used:

#include <kodi/AddonBase.h>
enum myEnumValue
{
valueA,
valueB,
valueC
};
std::string m_myStringValue;
int m_myIntegerValue;
bool m_myBooleanValue;
float m_myFloatingPointValue;
myEnumValue m_myEnumValue;
ADDON_STATUS CMyAddon::SetSetting(const std::string& settingName, const kodi::addon::CSettingValue& settingValue)
{
if (settingName == "my_string_value")
m_myStringValue = settingValue.GetString();
else if (settingName == "my_integer_value")
m_myIntegerValue = settingValue.GetInt();
else if (settingName == "my_boolean_value")
m_myBooleanValue = settingValue.GetBoolean();
else if (settingName == "my_float_value")
m_myFloatingPointValue = settingValue.GetFloat();
else if (settingName == "my_enum_value")
m_myEnumValue = settingValue.GetEnum<myEnumValue>();
}
Definition kodi-dev-kit/include/kodi/AddonBase.h:437
ADDON_STATUS
Definition addon_base.h:138
const std::string & GetString() const
To get settings value as string.
Definition kodi-dev-kit/include/kodi/AddonBase.h:460
bool GetBoolean() const
To get settings value as boolean.
Definition kodi-dev-kit/include/kodi/AddonBase.h:469
float GetFloat() const
To get settings value as floating point.
Definition kodi-dev-kit/include/kodi/AddonBase.h:472
enumType GetEnum() const
To get settings value as enum.
Definition kodi-dev-kit/include/kodi/AddonBase.h:477
int GetInt() const
To get settings value as integer.
Definition kodi-dev-kit/include/kodi/AddonBase.h:463
Note
The asked type should match the type used on settings.xml.

Function Documentation

◆ GetBoolean()

bool kodi::addon::CSettingValue::GetBoolean ( ) const
inline

To get settings value as boolean.

◆ GetEnum()

template<typename enumType >
enumType kodi::addon::CSettingValue::GetEnum ( ) const
inline

To get settings value as enum.

Note
Inside settings.xml them stored as integer.

◆ GetFloat()

float kodi::addon::CSettingValue::GetFloat ( ) const
inline

To get settings value as floating point.

◆ GetInt()

int kodi::addon::CSettingValue::GetInt ( ) const
inline

To get settings value as integer.

◆ GetString()

const std::string & kodi::addon::CSettingValue::GetString ( ) const
inline

To get settings value as string.

◆ GetUInt()

unsigned int kodi::addon::CSettingValue::GetUInt ( ) const
inline

To get settings value as unsigned integer.