cpp-ElementTree
Python ElementTree-alike XML API for C++
|
Lightweight wrapper to add nullable semantics to another type. More...
#include <element.hpp>
Public Member Functions | |
Nullable () | |
Construct an unset Nullable. | |
Nullable (const T &val) | |
Construct a set Nullable containing a value. More... | |
Nullable (const Nullable< T > &val) | |
Copy the value from another Nullable. More... | |
Nullable (T &&val) | |
C++11: construct a set Nullable by moving a value. More... | |
~Nullable () | |
Destroy the contained value if this Nullable is set. | |
ETREE_EXPLICIT | operator bool () const |
Evaluate to true if this Nullable is set. | |
T & | operator* () |
Return the contained value, or throw missing_value_error(). | |
const T & | operator* () const |
Return the contained value, or throw missing_value_error(). | |
const T * | operator-> () const |
Return the contained value, or throw missing_value_error(). | |
Nullable< T > & | operator= (const Nullable< T > &other) |
Copy the instance and its contained value, if any. | |
bool | operator== (const Nullable< T > &other) const |
Return true if both nullables are empty, or both nullables contain the same value. | |
bool | operator== (const T &other) const |
Return true if both nullables are empty, or both nullables contain the same value. | |
Lightweight wrapper to add nullable semantics to another type.
This template is presently only implemented for the Element type, attempting to instantiate it with other types will fail.
Nullable objects can be implicitly converted to boolean to test whether their contents exists, and dereferenced to access the stored value, if any:
etree::Nullable< T >::Nullable | ( | const T & | val | ) |
Construct a set Nullable containing a value.
val | Value to copy. |
etree::Nullable< T >::Nullable | ( | const Nullable< T > & | val | ) |
Copy the value from another Nullable.
val | Value to copy. |
etree::Nullable< T >::Nullable | ( | T && | val | ) |
C++11: construct a set Nullable by moving a value.
val | Value to copy. |