ADTF
|
A common result class usable as return value throughout. More...
Public Member Functions | |
Result () | |
Construct empty which basically means no error occurred. More... | |
Result (bool val) | |
Construct from bool. More... | |
Result (const ResultInfo< void > &) | |
Construct with a_util::result::SUCCESS. More... | |
template<typename ErrorType > | |
Result (const ResultInfo< ErrorType > &error) | |
Assign error code to result object. More... | |
template<typename ErrorType > | |
Result (ResultInfo< ErrorType > error, const char *error_description, std::int32_t line, const char *file, const char *function) | |
Construct result object with complete set of error information. More... | |
Result (std::int32_t error_code) | |
Create result object with just the error code type. More... | |
Result (std::int32_t error_code, const char *error_description, std::int32_t line, const char *file, const char *function) | |
Create result object with complete set of error information from just an error code. More... | |
Result (const Result &other_result, const char *error_description, std::int32_t line, const char *file, const char *function) | |
Create result object from another result, creating new detailed information. More... | |
~Result () | |
Destructor. | |
Result (const Result &other) | |
Copy constructor. More... | |
Result & | operator= (const ResultInfo< void > &) |
Assign with a_util::result::SUCCESS. More... | |
Result & | operator= (Result other) |
Assignment operator. More... | |
Result & | operator= (bool val) |
Assignment from bool. More... | |
Result & | operator= (std::int32_t val) |
Assignment from numeric. More... | |
Result (Result &&other) | |
Move operator. More... | |
std::int32_t | getErrorCode () const |
Get error code. More... | |
const char * | getErrorLabel () const |
Get error label as string representation. More... | |
const char * | getDescription () const |
Get user provided error description. More... | |
std::int32_t | getLine () const |
Get line in source file where the error was reported. More... | |
const char * | getFile () const |
Get name of the file the error was reported in. More... | |
const char * | getFunction () const |
Get name of the function the error was reported in. More... | |
operator bool () const noexcept | |
Convert result to bool. More... | |
Private Types | |
typedef detail::ResultDescription< detail::IErrorDescription > | DescriptionType |
Error description type. | |
Private Member Functions | |
Result (std::int32_t error_code, const char *error_description, std::int32_t line, const char *file, const char *function, const char *label) | |
Construct result object with complete set of error information. More... | |
Static Private Member Functions | |
static Result | createFrom (std::int32_t error_code, const char *error_description, std::int32_t line, const char *file, const char *function) |
Create a detailed object of type Result on the heap from an error code. More... | |
Private Attributes | |
DescriptionType | _result_handle |
The result handler wrapper. | |
A common result class usable as return value throughout.
Definition at line 34 of file result_type_decl.h.
|
inline |
Construct empty which basically means no error occurred.
Definition at line 30 of file result_type_impl.h.
Referenced by Result::Result(), Result::createFrom(), and Result::operator=().
|
inline |
Construct from bool.
[in] | val | Bool value to construct with |
true == a_util::result::Result(true);
false == a_util::result::Result(false);
Definition at line 34 of file result_type_impl.h.
|
inline |
Construct with a_util::result::SUCCESS.
This constructors sole intention is to provide the best match during compilation time if a function call returns with a_util::result::SUCCESS. With decltype(a_util::result::SUCCESS) being another type than all other error codes the compiler deduces this constructor as best fit.
Definition at line 39 of file result_type_impl.h.
|
inline |
Assign error code to result object.
[in] | error | The error code |
Definition at line 44 of file result_type_impl.h.
References a_util::maybe_unused().
|
inlineexplicit |
Construct result object with complete set of error information.
ErrorCode | Error code (to deduce specialized template to stringify the error code) |
[in] | error | The The concrete error object |
[in] | error_description | Complete description of the error (default: "") |
[in] | line | Line in source file the error was reported (default: -1) |
[in] | file | Source file the error was reported in (default: "") |
[in] | function | Function the error was reported in (default: "") |
Definition at line 51 of file result_type_impl.h.
References Result::Result(), ResultInfo< T >::getCode(), and a_util::maybe_unused().
|
inline |
Create result object with just the error code type.
[in] | error_code | The error code |
Definition at line 67 of file result_type_impl.h.
|
inlineexplicit |
Create result object with complete set of error information from just an error code.
[in] | error_code | The error code |
[in] | error_description | Complete description of the error (default: "") |
[in] | line | Line in source file the error was reported (default: -1) |
[in] | file | Source file the error was reported in (default: "") |
[in] | function | Function the error was reported in (default: "") |
Definition at line 72 of file result_type_impl.h.
References Result::createFrom().
|
inlineexplicit |
Create result object from another result, creating new detailed information.
[in] | other_result | Result to copy the error code and error code string information from. |
[in] | error_description | Complete description of the error. |
[in] | line | Line in source file the error was reported. |
[in] | file | Source file the error was reported in. |
[in] | function | Function the error was reported in. |
Definition at line 82 of file result_type_impl.h.
References Result::Result(), Result::getErrorCode(), and Result::getErrorLabel().
Copy constructor.
[in] | other | Where this gets copied from. |
other
are safely referenced in the new created object of type Result
. Definition at line 103 of file result_type_impl.h.
Move operator.
[in] | other | rvalue of type Result moved to *this. Left in an empty but valid state. |
Definition at line 128 of file result_type_impl.h.
References Result::Result(), and Result::swap.
|
inlineexplicitprivate |
Construct result object with complete set of error information.
[in] | error_code | The error code |
[in] | error_description | Complete description of the error (default: "") |
[in] | line | Line in source file the error was reported (default: -1) |
[in] | file | Source file the error was reported in (default: "") |
[in] | function | Function the error was reported in (default: "") |
[in] | label | String representation of error code (default: "") |
Definition at line 200 of file result_type_impl.h.
|
inlinestaticprivate |
Create a detailed object of type Result
on the heap from an error code.
[in] | error_code | The error code to create the result object from. |
[in] | error_description | Complete description of the error (default: "") |
[in] | line | Line in source file the error was reported (default: -1) |
[in] | file | Source file the error was reported in (default: "") |
[in] | function | Function the error was reported in (default: "") |
Result
containing detailed error information. Definition at line 211 of file result_type_impl.h.
References Result::Result().
Referenced by Result::Result().
|
inline |
Get user provided error description.
Definition at line 154 of file result_type_impl.h.
References Result::_result_handle, ResultDescription< DescriptionIntf >::getDetailedDescription(), ResultDescription< DescriptionIntf >::getErrorCode(), and IErrorDescription::getErrorDescription().
|
inline |
Get error code.
Definition at line 136 of file result_type_impl.h.
References Result::_result_handle, ResultDescription< DescriptionIntf >::getDetailedDescription(), ResultDescription< DescriptionIntf >::getErrorCode(), and IErrorDescription::getErrorCode().
Referenced by Result::Result(), a_util::result::isOk< Result >(), and a_util::result::operator==().
|
inline |
Get error label as string representation.
Definition at line 144 of file result_type_impl.h.
References Result::_result_handle, ResultDescription< DescriptionIntf >::getDetailedDescription(), and IErrorDescription::getErrorCodeLabel().
Referenced by Result::Result().
|
inline |
Get name of the file the error was reported in.
Definition at line 177 of file result_type_impl.h.
References Result::_result_handle, ResultDescription< DescriptionIntf >::getDetailedDescription(), and IErrorDescription::getFileName().
|
inline |
Get name of the function the error was reported in.
Definition at line 186 of file result_type_impl.h.
References Result::_result_handle, ResultDescription< DescriptionIntf >::getDetailedDescription(), and IErrorDescription::getFunctionName().
|
inline |
Get line in source file where the error was reported.
Definition at line 168 of file result_type_impl.h.
References Result::_result_handle, ResultDescription< DescriptionIntf >::getDetailedDescription(), and IErrorDescription::getLine().
|
inlineexplicitnoexcept |
Convert result to bool.
true
, otherwise false
Definition at line 195 of file result_type_impl.h.
|
inline |
Assignment from bool.
[in] | val | Bool value to construct with |
Definition at line 113 of file result_type_impl.h.
References Result::Result(), and Result::operator=().
|
inline |
Assign with a_util::result::SUCCESS.
This assignments sole intention is to provide the best match during compilation time if a function call returns with a_util::result::SUCCESS. With decltype(a_util::result::SUCCESS) being another type than all other error codes the compiler deduces this assignment operator as best fit.
Definition at line 123 of file result_type_impl.h.
References Result::Result().
Referenced by Result::operator=().
Assignment operator.
[in] | other | Result type being assigned to the this object. |
other
by value is fully intentional here! Definition at line 107 of file result_type_impl.h.
References Result::swap.
|
inline |
Assignment from numeric.
[in] | val | Numeric value to construct with |
Definition at line 118 of file result_type_impl.h.
References Result::Result(), and Result::operator=().