jubilant-funicular
|
#include <Errors.h>
Public Member Functions | |
Result (const Result &other) | |
Public copy constructor. | |
~Result () | |
Public destructor. | |
bool | is_err () const |
Is this an Error. | |
bool | is_ok () const |
Is this normal data. | |
T | get_data () const |
Get the data (only use if is_ok() returns true) | |
T | unwrap () const |
Same as get_data. | |
Error | get_err () const |
Get the Error (only use if is_err() returns true) | |
T | get_data_or (T optb) const |
Tries getting data, returning a default value if this is an error. | |
T | unwrap_or (T optb) const |
Same as get_data_or. | |
template<typename S > | |
Result< S > | map (std::function< S(T)> func) |
Applies a function if no error has occured, else returns the same error. | |
utils::Option< Error > | map (std::function< void(T)> func) |
template<typename S > | |
Result< S > | convert_error () |
Converts an error variant of Result<T> to an error variant of Result | |
Static Public Member Functions | |
static Result | new_ok (const T &data) |
static Result | new_err (const Error &err) |
Private Member Functions | |
Result () | |
Private constructor (use new_ok or new_err) | |
Private Attributes | |
union { | |
T | data |
Error | err |
}; | |
The data or error held by this Result. | |
bool | is_err_variant |
Whether or not an error occured. | |
Used for returning data when an error could potentially occur
|
inlinestatic |
Create new Result holding an Error
This takes ownership of the err passed in
Definition at line 110 of file Errors.h.
Referenced by nta::Result< T >::convert_error(), nta::ContextData::getTextureFile(), and nta::Result< T >::map().
|
inlinestatic |
Create new Result holding normal data
This takes ownership of the data passed in
Definition at line 101 of file Errors.h.
Referenced by nta::ContextData::getSpriteFont(), nta::ResourceManager::getTexture(), nta::ContextData::getTexture(), nta::ContextData::getTextureFile(), and nta::Result< T >::map().