|
| Result (types::Ok< T > ok) |
| Construct a new Result instance that contains OK.
|
|
| Result (types::Err< E > err, const API_Token &token) |
| Construct a new Result instance that contains the specified error.
|
|
| Result (Result &&other) |
| Move constructor of Result.
|
|
| Result (const Result &other) |
| Copy constructor of Result.
|
|
template<typename U , typename P = T, typename = std::enable_if_t<std::is_void_v<P>>> |
| Result (Result< U, E > &&other) |
| Move constructor specialization.
|
|
template<typename U , typename P = T, typename = std::enable_if_t<std::is_void_v<P>>> |
| Result (const Result< U, E > &other) |
| Copy constructor specialization.
|
|
bool | IsOk () const |
|
bool | IsErr () const |
|
T | Expect (std::string_view message) const |
| This function will yield the value of an Ok(T).
|
|
template<typename Func , typename Ret = Result< typename details::ResultOkType< std::invoke_result_t<Func, T> >::type, E>> |
Ret | Map (Func func) const |
| This function will apply a function to a contained value and will return the result of the transformation. In case the Result contains an Error, Map does nothing. Note that the passed function should return a simple value and not a Result. If you want to transform the error result of a function, use MapError.
|
|
template<typename Func , typename Ret = Result<T, typename details::ResultErrType< std::invoke_result_t<Func, E> >::type >> |
Ret | MapError (Func func) const |
| This function will apply a function to a contained error value and will return the result of the transformation.
|
|
template<typename Func > |
Result< T, E > | Then (Func func) const |
| This function executes the passed function if the Result contains an Ok value. In case the Result contains an Error value, Then does nothing.
|
|
template<typename Func > |
Result< T, E > | Otherwise (Func func) const |
| This function will execute a function if the Result contains an Error value.
|
|
template<typename Func , typename Ret = Result<T, typename details::ResultErrType< std::invoke_result_t<Func, E> >::type >> |
Ret | OrElse (Func func) const |
| This function will return the result of a transformation executed on the Error value of the Result, only if the Result contains an Error value.
|
|
const API_Token & | Token () const |
| A simple getter for the Token of the AddOn which called the function that returned the Result. Mainly for internal use.
|
|
template<typename U = T> |
const std::enable_if_t<!std::is_same_v< U, void >, U > & | UnwrapOr (const U &defaultValue) const & |
| Unwraps the value contained in the Result. In case the Result contains an Error value, it returns a default value passed in as a parameter.
|
|
template<typename U = T> |
std::enable_if_t<!std::is_same_v< U, void >, U > && | Unwrap () && |
| Unwraps the value contained in the Result. Trying to Unwrap the value while it contains an error will result in crash and should be avoided. Crashing Archicad may result in disabling the AddOn during the next Archicad startup.
|
|
template<typename U = T> |
const std::enable_if_t<!std::is_same_v< U, void >, U > & | Unwrap () const & |
| Unwraps the value contained in the Result. Trying to Unwrap the value while it contains an error will result in crash and should be avoided. Crashing Archicad may result in disabling the AddOn during the next Archicad startup.
|
|
template<typename U = T> |
std::enable_if_t<!std::is_same_v< U, void >, U > & | Unwrap () & |
| Unwraps the value contained in the Result. Trying to Unwrap the value while it contains an error will result in crash and should be avoided. Crashing Archicad may result in disabling the AddOn during the next Archicad startup.
|
|
E | UnwrapErr () const |
| Unwraps the error value contained in the Result. Trying to UnwrapErr the value while it contains an Ok value will result in crash and should be avoided. Crashing Archicad may result in disabling the AddOn during the next Archicad startup.
|
|
template<typename U = T> |
std::enable_if_t<!std::is_same_v< U, void >, U > & | operator* () & |
| Unwraps the value contained in the Result. Trying to Unwrap the value while it contains an error will result in crash and should be avoided. Crashing Archicad may result in disabling the AddOn during the next Archicad startup.
|
|
template<typename U = T> |
std::enable_if_t<!std::is_same_v< U, void >, U > && | operator* () && |
| Unwraps the value contained in the Result. Trying to Unwrap the value while it contains an error will result in crash and should be avoided. Crashing Archicad may result in disabling the AddOn during the next Archicad startup.
|
|
template<typename U = T> |
const std::enable_if_t<!std::is_same_v< U, void >, U > & | operator* () const & |
| Unwraps the value contained in the Result. Trying to Unwrap the value while it contains an error will result in crash and should be avoided. Crashing Archicad may result in disabling the AddOn during the next Archicad startup.
|
|
template<typename U = T> |
std::enable_if<!std::is_same< U, void >::value, U >::type * | operator-> () |
| Unwraps the value contained in the Result and return with a pointer to it. Trying to Unwrap the value while it contains an error will result in crash and should be avoided. Crashing Archicad may result in disabling the AddOn during the next Archicad startup.
|
|
template<typename U = T> |
const std::enable_if<!std::is_same< U, void >::value, U >::type * | operator-> () const |
| Unwraps the value contained in the Result and return with a pointer to it. Trying to Unwrap the value while it contains an error will result in crash and should be avoided. Crashing Archicad may result in disabling the AddOn during the next Archicad startup.
|
|
const storage_type & | Storage () const |
| For internal use only.
|
|
storage_type & | Storage () |
| For internal use only.
|
|
template<typename T, typename E = Error>
class ACAPI::Result< T, E >
Result is the standard return type of API functions.
Result is a value wrapper that can contain an error message and error code if the function failed, or a return value if the function succeeded. It supports advanced functional operations such as Map or Otherwise or can be used as a simple Optional by dereferencing the contained value. Trying to dereference the value while it contains an error will result in crash and should be avoided.