15 #ifndef A_UTIL_UTIL_RESULT_RESULT_INFO_DECL_HEADER_INCLUDED
16 #define A_UTIL_UTIL_RESULT_RESULT_INFO_DECL_HEADER_INCLUDED
24 #ifndef DEV_ESSENTIAL_DISABLE_MAKE_RESULT_CHECK_RESERVED_ZERO
25 #define DEV_ESSENTIAL_INTERNAL_MAKE_RESULT_CHECK_NOT_ZERO(_no) _no != 0
27 #define DEV_ESSENTIAL_INTERNAL_MAKE_RESULT_CHECK_NOT_ZERO(...) true
36 #define _MAKE_RESULT(_no, _label) \
38 struct ResultType_##_label : public ::a_util::result::ResultInfo<ResultType_##_label> { \
39 static std::int32_t getCode() \
41 static_assert(std::is_same<decltype((_no)), std::int32_t>::value, \
42 #_no " is not in range of std::int32_t."); \
45 static const char* getLabel() \
50 const ::a_util::result::ResultInfo<ResultType_##_label> _label = ResultType_##_label(); \
52 static_assert(DEV_ESSENTIAL_INTERNAL_MAKE_RESULT_CHECK_NOT_ZERO(_no), \
53 "'0' is not allowed, because it is reserved for results indicating no error. " \
54 "Please use a_util::result::SUCCESS instead. To disable this check, define " \
55 "'DEV_ESSENTIAL_DISABLE_MAKE_RESULT_CHECK_RESERVED_ZERO'")
66 template <
typename ResultType>
68 bool isOk(
const ResultType& result);
77 template <
typename ResultType>
79 bool isFailed(
const ResultType& result);
129 template <
typename ResultTypeLHS,
typename ResultTypeRHS>
130 bool operator==(
const ResultInfo<ResultTypeLHS>& lhs,
const ResultInfo<ResultTypeRHS>& rhs);
140 template <
typename ResultTypeLHS,
typename ResultTypeRHS>
141 bool operator!=(
const ResultInfo<ResultTypeLHS>& lhs,
const ResultInfo<ResultTypeRHS>& rhs);
151 template <
typename ResultTypeLHS,
typename ResultTypeRHS>
152 bool operator<(
const ResultInfo<ResultTypeLHS>& lhs,
const ResultInfo<ResultTypeRHS>& rhs);
162 template <
typename ResultTypeLHS,
typename ResultTypeRHS>
163 bool operator>(
const ResultInfo<ResultTypeLHS>& lhs,
const ResultInfo<ResultTypeRHS>& rhs);
173 template <
typename ResultTypeLHS,
typename ResultTypeRHS>
174 bool operator<=(
const ResultInfo<ResultTypeLHS>& lhs,
const ResultInfo<ResultTypeRHS>& rhs);
184 template <
typename ResultTypeLHS,
typename ResultTypeRHS>
185 bool operator>=(
const ResultInfo<ResultTypeLHS>& lhs,
const ResultInfo<ResultTypeRHS>& rhs);
Definition of preprocessor macro DEV_ESSENTIAL_DEPRECATED.
#define DEV_ESSENTIAL_DEPRECATED(msg)
Adds [[deprecated("msg")]] to allowed declarations.
bool operator>(const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
Greater-than operator for two specialized result information objects.
bool operator<=(const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
Less-than-or-equal operator for two specialized result information objects.
bool operator==(const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
Compare two specialized result information objects for equality.
bool isOk(const ResultType &result)
Check whether a return value indicates a successful function execution.
bool isFailed(const ResultType &result)
Check whether a return value indicates an unsuccessful function execution.
bool operator<(const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
Less-than operator for two specialized result information objects.
bool operator!=(const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
Compare two specialized result information objects for inequality.
bool operator>=(const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
Greater-than-or-equal operator for two specialized result information objects.
Serves as the root component, with common functionality documented in core functionality.
Private implementation for ResultInfo 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.
static const char * getLabel()
Get the string representation of an error code distributed by value of type T.