Overte C++ Documentation
Setting::Handle< T > Class Template Reference

Handle to a setting of type T. More...

#include <SettingHandle.h>

Inherits Interface.

Public Member Functions

 Handle (const QString &key)
 Construct handle to a setting. More...
 
 Handle (const QStringList &path)
 Construct a handle to a setting. More...
 
 Handle (const QString &key, const T &defaultValue)
 Construct handle to a setting with a default value. More...
 
 Handle (const QStringList &path, const T &defaultValue)
 Construct a handle to a setting with a default value. More...
 
get () const
 Returns the value of the setting, or the default value if not found. More...
 
get (const T &other) const
 Returns the value of the setting, or 'other' if not found. More...
 
bool isSet () const
 Returns whether the setting is set to a value. More...
 
const T & getDefault () const
 Returns the default value for this setting. More...
 
void reset ()
 Sets the value to the default.
 
void set (const T &value)
 Set the setting to the specified value. More...
 
void remove ()
 Remove the value from the setting. More...
 

Static Public Member Functions

static Handle Deprecated (const QString &key)
 Construct a handle to a deprecated setting. More...
 
static Handle Deprecated (const QStringList &path)
 Construct a handle to a deprecated setting. More...
 
static Handle Deprecated (const QString &key, const T &defaultValue)
 Construct a handle to a deprecated setting with a default value. More...
 
static Handle Deprecated (const QStringList &path, const T &defaultValue)
 Construct a handle to a deprecated setting with a default value. More...
 

Detailed Description

template<typename T>
class Setting::Handle< T >

Handle to a setting of type T.

This creates an object that manipulates a setting in the settings system. Changes will be written to the configuration file at some point controlled by Setting::Manager.

Template Parameters
TType of the setting.

Constructor & Destructor Documentation

◆ Handle() [1/4]

template<typename T >
Setting::Handle< T >::Handle ( const QString &  key)
inline

Construct handle to a setting.

Parameters
keyThe key corresponding to the setting in the settings file. Eg, 'shadowsEnabled'

◆ Handle() [2/4]

template<typename T >
Setting::Handle< T >::Handle ( const QStringList &  path)
inline

Construct a handle to a setting.

Parameters
pathPath to the key corresponding to the setting in the settings file. Eg, QStringList() << group << key

◆ Handle() [3/4]

template<typename T >
Setting::Handle< T >::Handle ( const QString &  key,
const T &  defaultValue 
)
inline

Construct handle to a setting with a default value.

Parameters
keyThe key corresponding to the setting in the settings file. Eg, 'shadowsEnabled'
defaultValueDefault value for this setting

◆ Handle() [4/4]

template<typename T >
Setting::Handle< T >::Handle ( const QStringList &  path,
const T &  defaultValue 
)
inline

Construct a handle to a setting with a default value.

Parameters
pathPath to the key corresponding to the setting in the settings file. Eg, QStringList() << group << key
defaultValueDefault value for this setting

Member Function Documentation

◆ Deprecated() [1/4]

template<typename T >
static Handle Setting::Handle< T >::Deprecated ( const QString &  key)
inlinestatic

Construct a handle to a deprecated setting.

If used, a warning will written to the log.

Parameters
keyThe key corresponding to the setting in the settings file. Eg, 'shadowsEnabled'
Returns
Handle The handle object

◆ Deprecated() [2/4]

template<typename T >
static Handle Setting::Handle< T >::Deprecated ( const QString &  key,
const T &  defaultValue 
)
inlinestatic

Construct a handle to a deprecated setting with a default value.

If used, a warning will written to the log.

Parameters
keyThe key corresponding to the setting in the settings file. Eg, 'shadowsEnabled'
defaultValueDefault value for this setting
Returns
Handle The handle object

◆ Deprecated() [3/4]

template<typename T >
static Handle Setting::Handle< T >::Deprecated ( const QStringList &  path)
inlinestatic

Construct a handle to a deprecated setting.

If used, a warning will written to the log.

Parameters
pathPath to the key corresponding to the setting in the settings file. Eg, QStringList() << group << key
Returns
Handle The handle object

◆ Deprecated() [4/4]

template<typename T >
static Handle Setting::Handle< T >::Deprecated ( const QStringList &  path,
const T &  defaultValue 
)
inlinestatic

Construct a handle to a deprecated setting with a default value.

If used, a warning will written to the log.

Parameters
pathPath to the key corresponding to the setting in the settings file. Eg, QStringList() << group << key
defaultValueDefault value for this setting
Returns
Handle The handle object

◆ get() [1/2]

template<typename T >
T Setting::Handle< T >::get ( ) const
inline

Returns the value of the setting, or the default value if not found.

Returns
T Value of the associated setting

◆ get() [2/2]

template<typename T >
T Setting::Handle< T >::get ( const T &  other) const
inline

Returns the value of the setting, or 'other' if not found.

Parameters
otherValue to return if the setting is not set
Returns
T Value of the associated setting

◆ getDefault()

template<typename T >
const T& Setting::Handle< T >::getDefault ( ) const
inline

Returns the default value for this setting.

Returns
const T& Default value for this setting

◆ isSet()

template<typename T >
bool Setting::Handle< T >::isSet ( ) const
inline

Returns whether the setting is set to a value.

Returns
true The setting has a value
false The setting has no value

◆ remove()

template<typename T >
void Setting::Handle< T >::remove ( )
inline

Remove the value from the setting.

This returns the setting to an unset state. If read, it will be read as the default value.

◆ set()

template<typename T >
void Setting::Handle< T >::set ( const T &  value)
inline

Set the setting to the specified value.

The value will be stored in the configuration file.

Parameters
valueValue to set the setting to.

The documentation for this class was generated from the following file: