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;
{
if (settingName == "my_string_value")
else if (settingName == "my_integer_value")
m_myIntegerValue = settingValue.
GetInt();
else if (settingName == "my_boolean_value")
else if (settingName == "my_float_value")
m_myFloatingPointValue = settingValue.
GetFloat();
else if (settingName == "my_enum_value")
m_myEnumValue = settingValue.
GetEnum<myEnumValue>();
}
Definition AddonBase.h:437
ADDON_STATUS
Definition addon_base.h:138
int GetInt() const
To get settings value as integer.
Definition AddonBase.h:463
bool GetBoolean() const
To get settings value as boolean.
Definition AddonBase.h:469
const std::string & GetString() const
To get settings value as string.
Definition AddonBase.h:460
float GetFloat() const
To get settings value as floating point.
Definition AddonBase.h:472
enumType GetEnum() const
To get settings value as enum.
Definition AddonBase.h:477
- Note
- The asked type should match the type used on settings.xml.
◆ GetString()
const std::string & GetString |
( |
| ) |
const |
|
inline |
To get settings value as string.
◆ GetInt()
To get settings value as integer.
◆ GetUInt()
unsigned int GetUInt |
( |
| ) |
const |
|
inline |
To get settings value as unsigned integer.
◆ GetBoolean()
bool GetBoolean |
( |
| ) |
const |
|
inline |
To get settings value as boolean.
◆ GetFloat()
To get settings value as floating point.
◆ GetEnum()
template<typename enumType >
enumType GetEnum |
( |
| ) |
const |
|
inline |
To get settings value as enum.
- Note
- Inside settings.xml them stored as integer.