![]() |
TSDuck v3.36-3298
MPEG Transport Stream Toolkit
|
A template class which defines a variable which can be either initialized or uninitialized. More...
#include <tsVariable.h>
Public Member Functions | |
Variable () noexcept | |
Default constructor, the variable is uninitialized. | |
Variable (const T &obj) | |
Constructor from a T instance, the variable is initialized. | |
Variable (const Variable< T > &other) | |
Copy constructor. | |
Variable (Variable< T > &&other) | |
Move constructor. | |
virtual | ~Variable () |
Virtual destructor. | |
void | clear () |
Clear the value. | |
bool | identical (const Variable< T > &other) const |
Identity. | |
bool | operator!= (const T &obj) const |
Unequality operator with a T instance. | |
bool | operator!= (const Variable< T > &other) const |
Unequality operator. | |
Variable< T > & | operator= (const T &obj) |
Assignment operator from a T object. | |
Variable< T > & | operator= (const Variable< T > &other) |
Assignment operator. | |
Variable< T > & | operator= (Variable< T > &&other) |
Move assignment operator. | |
bool | operator== (const T &obj) const |
Equality operator with a T instance. | |
bool | operator== (const Variable< T > &other) const |
Equality operator. | |
bool | set () const |
Check the presence of a value. | |
bool | setDefault (const T &def) |
Set a value if the variable is currently unset. | |
T & | value () |
Access the T value inside the variable. | |
const T & | value () const |
Access the constant T value inside the variable. | |
T | value (const T &def) const |
Get a copy of the T value inside the variable or a default value. | |
A template class which defines a variable which can be either initialized or uninitialized.
T | A type or class which describes the content of the variable. The basic requirement on T is the availability of a copy constructor and operators for assignment and equality. |
Copy constructor.
This object is in the same state as other. If other is initialized, this object becomes initialized with the same T value.
[in] | other | Another instance from which to build this object. |
Move constructor.
[in,out] | other | Another instance from which to build this object. |
Constructor from a T instance, the variable is initialized.
[in] | obj | The initial value for the variable. |
ts::Variable< T > & ts::Variable< T >::operator= | ( | const Variable< T > & | other | ) |
Assignment operator.
This object is in the same state as other. If other is initialized, this object becomes initialized with the same T value.
[in] | other | Another instance from which to assign this object. |
ts::Variable< T > & ts::Variable< T >::operator= | ( | Variable< T > && | other | ) |
Move assignment operator.
[in,out] | other | Another instance from which to assign this object. |
ts::Variable< T > & ts::Variable< T >::operator= | ( | const T & | obj | ) |
Assignment operator from a T object.
This object becomes initialized if it was not already.
[in] | obj | Value from which to assign this object. |
|
inline |
Check the presence of a value.
Set a value if the variable is currently unset.
Do nothing if the variable is already initialized.
[in] | def | A default T value if the variable is uninitialized. |
void ts::Variable< T >::clear | ( | ) |
Clear the value.
This object becomes uninitialized if it was not already.
Access the constant T value inside the variable.
UninitializedVariable | If the variable is uninitialized. |
T & ts::Variable< T >::value | ( | ) |
Access the T value inside the variable.
UninitializedVariable | If the variable is uninitialized. |
Get a copy of the T value inside the variable or a default value.
[in] | def | A default T value if the variable is uninitialized. |
bool ts::Variable< T >::operator== | ( | const Variable< T > & | other | ) | const |
Equality operator.
[in] | other | An other instance to compare with. |
bool ts::Variable< T >::operator!= | ( | const Variable< T > & | other | ) | const |
Unequality operator.
[in] | other | An other instance to compare with. |
bool ts::Variable< T >::operator== | ( | const T & | obj | ) | const |
Equality operator with a T instance.
[in] | obj | An object to compare with. |
bool ts::Variable< T >::operator!= | ( | const T & | obj | ) | const |
Unequality operator with a T instance.
[in] | obj | An object to compare with. |
Identity.
[in] | other | An other instance to compare with. |