ADTF  3.18.2
result_info_impl.h
Go to the documentation of this file.
1 
15 #ifndef A_UTIL_UTIL_RESULT_DETAIL_RESULT_INFO_IMPL_HEADER_INCLUDED
16 #define A_UTIL_UTIL_RESULT_DETAIL_RESULT_INFO_IMPL_HEADER_INCLUDED
17 
18 #include <a_util/base/types.h>
20 
21 namespace a_util {
22 namespace result {
23 template <typename ResultType>
24 inline bool isOk(const ResultType& result)
25 { // zero initialization
26  return (ResultType() == result);
27 }
28 
29 template <typename ResultType>
30 inline bool isFailed(const ResultType& result)
31 {
32  return !(isOk(result));
33 }
34 
35 template <typename T>
36 inline const char* ResultInfo<T>::getLabel()
37 {
38  return T::getLabel();
39 }
40 
41 template <typename T>
42 inline std::int32_t ResultInfo<T>::getCode()
43 {
44  return T::getCode();
45 }
46 
47 inline std::int32_t ResultInfo<void>::getCode()
48 {
49  return 0;
50 }
51 
52 inline const char* ResultInfo<void>::getLabel()
53 {
54  return "SUCCESS";
55 }
56 
57 template <typename ResultTypeLHS, typename ResultTypeRHS>
59 {
62  return (lhs.getCode() == rhs.getCode()) && (lhs.getLabel() == rhs.getLabel());
63 }
64 
65 template <typename ResultTypeLHS, typename ResultTypeRHS>
67 {
68  return !operator==(lhs, rhs);
69 }
70 
71 template <typename ResultTypeLHS, typename ResultTypeRHS>
73 {
74  return lhs.getCode() < rhs.getCode();
75 }
76 
77 template <typename ResultTypeLHS, typename ResultTypeRHS>
79 {
80  return operator<(rhs, lhs);
81 }
82 
83 template <typename ResultTypeLHS, typename ResultTypeRHS>
85 {
86  return !operator>(lhs, rhs);
87 }
88 
89 template <typename ResultTypeLHS, typename ResultTypeRHS>
91 {
92  return !operator<(lhs, rhs);
93 }
94 
95 } // namespace result
96 } // namespace a_util
97 
98 #endif // A_UTIL_UTIL_RESULT_DETAIL_RESULT_INFO_IMPL_HEADER_INCLUDED
void maybe_unused(T &&)
Mimics C++17 attribute maybe_unused to silence compiler warnings on potentially unused enitities.
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.
Definition: base.h:24
Public API for ResultInfo type, functions and macros.
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.
Public types and functions defining a_util core functionality.