15 #ifndef A_UTIL_UTIL_RESULT_DETAIL_RESULT_TYPE_IMPL_HEADER_INCLUDED
16 #define A_UTIL_UTIL_RESULT_DETAIL_RESULT_TYPE_IMPL_HEADER_INCLUDED
35 : _result_handle(
DescriptionType::makeResultDescription(static_cast<std::int32_t>(!val) * -1))
43 template <
typename ErrorType>
50 template <
typename ErrorType>
52 const char* error_description,
73 const char* error_description,
79 *
this =
createFrom(error_code, error_description, line, file,
function);
83 const char* error_description,
99 static_assert(
sizeof(*
this) == 8,
"sizeof(*this) != 8");
100 static_assert(std::is_standard_layout<Result>::value,
"Result must be standard layout type");
131 if (SUCCESS != other) {
151 return *
this ?
"SUCCESS" :
"(unknown)";
165 return "No error occurred";
195 inline Result::operator bool() const noexcept
197 return getErrorCode() == 0;
201 const char* error_description,
204 const char*
function,
207 error_code, error_description, line, file, function, label))
212 const char* error_description,
215 const char*
function)
222 0 == error_code ?
"SUCCESS" :
"(unknown)");
232 return !(lhs == rhs);
235 template <
typename T>
241 template <
typename T>
244 return !(result == error_code);
247 template <
typename T>
250 return result == error_code;
253 template <
typename T>
256 return result != error_code;
A common result class usable as return value throughout.
const char * getFunction() const
Get name of the function the error was reported in.
const char * getFile() const
Get name of the file the error was reported in.
Result & operator=(const ResultInfo< void > &)
Assign with a_util::result::SUCCESS.
std::int32_t getLine() const
Get line in source file where the error was reported.
Result()
Construct empty which basically means no error occurred.
const char * getDescription() const
Get user provided error description.
friend void swap(Result &lhs, Result &rhs)
Specialized friend swap function to enable ADL in std::swap later.
std::int32_t getErrorCode() const
Get error code.
const char * getErrorLabel() const
Get error label as string representation.
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.
DescriptionType _result_handle
The result handler wrapper.
virtual const char * getFunctionName() const =0
Interface method to get the name of the function the error was reported in.
virtual std::int32_t getLine() const =0
Interface method to get the line of the source file where the error was reported.
virtual const char * getErrorDescription() const =0
Interface method to get the error code as string representation.
virtual const char * getErrorCodeLabel() const =0
Interface method to get the error code label.
virtual std::int32_t getErrorCode() const =0
Interface method to get the error code.
virtual const char * getFileName() const =0
Interface method to get the name of the file the error was reported in.
std::int32_t getErrorCode() const
Get the error code if only the error code was set.
DescriptionIntf const * getDetailedDescription() const
Get the detailed description if any was allocated.
Declare the default error description class for Result return values.
void maybe_unused(T &&)
Mimics C++17 attribute maybe_unused to silence compiler warnings on potentially unused enitities.
ErrorDescription ErrorDescriptionType
Alias type needed for reference counting.
void swap(Result &lhs, Result &rhs)
bool operator==(const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
Compare two specialized result information objects for equality.
bool isOk< Result >(const Result &result)
Specialization of a_util::result::isOk<typename ResultType>() for correct lookup.
bool operator!=(const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
Compare two specialized result information objects for inequality.
Serves as the root component, with common functionality documented in core functionality.
Private API for ResultDescription type and functions.
Private implementation for ResultDescription type and functions.
Common include for ResultInfo functionality.
Public API for Result type and functions.
Implements basic success result information for usage with a_util::result::Result.
Basic result information template, used by a_util::result::Result.
static std::int32_t getCode()
Get the result code distributed with value of type T.
Public types and functions defining a_util core functionality.