template<typename T>
QgsOptional class
QgsOptional is a container for other classes and adds an additional enabled/disabled flag.
Contents
Often it is used for configuration options which can be enabled or disabled but also have more internal configuration information that should not be lost when disabling and re-enabling.
Constructors, destructors, conversion operators
- QgsOptional() defaulted
- A QgsOptional is disabled by default if default constructed.
- QgsOptional(const T& data)
- A QgsOptional is enabled by default if constructed with payload.
- QgsOptional(const T& data, bool enabled)
- A QgsOptional constructed with enabled status and data.
- operator bool() const
- Boolean operator.
Public functions
- auto data() const -> T
- Access the payload data.
- auto enabled() const -> bool
- Check if this optional is enabled.
- auto operator->() const -> const T*
- Access the payload data.
- auto operator==(const QgsOptional<T>& other) const -> bool
- Compare this QgsOptional to another one.
- void setData(const T& data)
- Set the payload data.
- void setEnabled(bool enabled)
- Set if this optional is enabled.
Function documentation
template<typename T>
QgsOptional<T>:: operator bool() const
Boolean operator.
Will return true if this optional is enabled.
template<typename T>
T QgsOptional<T>:: data() const
Access the payload data.
template<typename T>
bool QgsOptional<T>:: enabled() const
Check if this optional is enabled.
template<typename T>
const T* QgsOptional<T>:: operator->() const
Access the payload data.
template<typename T>
bool QgsOptional<T>:: operator==(const QgsOptional<T>& other) const
Compare this QgsOptional to another one.
This will compare the enabled flag and call the == operator of the contained class.
template<typename T>
void QgsOptional<T>:: setData(const T& data)
Set the payload data.
template<typename T>
void QgsOptional<T>:: setEnabled(bool enabled)
Set if this optional is enabled.