ADTF
Loading...
Searching...
No Matches
result_description_decl.h
Go to the documentation of this file.
1
15
16#ifndef A_UTIL_UTIL_RESULT_DETAIL_DESCRIPTION_DECL_HEADER_INCLUDED
17#define A_UTIL_UTIL_RESULT_DETAIL_DESCRIPTION_DECL_HEADER_INCLUDED
18
21
22#include <cstdint>
23
24namespace a_util {
25namespace result {
26namespace detail {
31template <typename DescriptionIntf /*e.g. a_util::result::detail::IErrorDescription*/>
36 static const std::uint64_t error_code_bit = 1ull << 63;
38 static const std::uint64_t error_code_bitmask = ~error_code_bit;
40 static const std::uint64_t error_code_serialize_bitmask = 0x00000000FFFFFFFF;
42 static const std::uint64_t error_code_deserialize_bitmask = 0xFFFFFFFF00000000;
43
47 ResultDescriptionTraits& operator=(const ResultDescriptionTraits&) = delete;
50
57 static bool isDetailedDescriptionSet(std::uint64_t value);
58
65 static bool isErrorCodeSet(std::uint64_t value);
66
72 constexpr static std::uint64_t toInternalErrorCode(std::int32_t error_code) noexcept;
73
79 constexpr static std::int32_t toExternalErrorCode(std::uint64_t error_code) noexcept;
80
87 std::uint64_t error_code) noexcept;
88
89private:
92}; // struct ResultDescriptionTraits
93
95
110template <typename DescriptionIntf /*e.g. a_util::result::detail::IErrorDescription*/>
113
114public:
116
117public:
143
146
167 template <typename DescriptionImpl, typename... Args>
168 static SelfType makeResultDescription(std::int32_t error_code, Args&&... args);
169
178 template <typename T>
180 const ::a_util::result::ResultInfo<T>& result_info) noexcept;
181
187 static SelfType makeResultDescription(std::int32_t error_code);
188
195 DescriptionIntf const* getDetailedDescription() const;
196
203 std::int32_t getErrorCode() const;
204
205private:
206 // On all systems, a 64Bit variable for storage
207 // the most significant bits are used for user flags
208 // size of pointer part is system dependent, lower bits
209 std::uint64_t _pointer_to_result_or_error_code;
210
215 constexpr ResultDescription(std::int32_t error_code) noexcept;
216
222 constexpr ResultDescription(
223 const ReferenceCountedObjectInterface<DescriptionIntf>& error_object) noexcept;
224}; // struct ResultDescription
225
233template <typename T>
234bool operator==(const ResultDescription<T>& lhs, const ResultDescription<T>& rhs);
235
243template <typename T>
244bool operator!=(const ResultDescription<T>& lhs, const ResultDescription<T>& rhs);
245
246} // namespace detail
247} // namespace result
248} // namespace a_util
249
253
254#endif // A_UTIL_UTIL_RESULT_DETAIL_DESCRIPTION_DECL_HEADER_INCLUDED
Definition reference_counted_object_intf.h:29
Wrapper for either a pointer to a detailed description object or simply a numeric error code.
Definition result_description_decl.h:111
std::int32_t getErrorCode() const
Definition result_description_impl.h:247
ResultDescription & operator=(const ResultDescription &other)
Definition result_description_impl.h:131
ResultDescription(ResultDescription &&other)
Definition result_description_impl.h:148
static SelfType makeResultDescription(std::int32_t error_code, Args &&... args)
Definition result_description_impl.h:183
ResultDescription(const ResultDescription &other)
Definition result_description_impl.h:124
ResultDescription & operator=(ResultDescription &&other)
Definition result_description_impl.h:155
ResultDescription()
CTOR.
Definition result_description_impl.h:119
static SelfType makeResultDescription(const ::a_util::result::ResultInfo< T > &result_info) noexcept
Definition result_description_impl.h:213
static SelfType makeResultDescription(std::int32_t error_code)
Definition result_description_impl.h:228
~ResultDescription()
DTOR.
Definition result_description_impl.h:170
DescriptionIntf const * getDetailedDescription() const
Definition result_description_impl.h:237
ResultDescription< DescriptionIntf > SelfType
Self type.
Definition result_description_decl.h:115
Serves as namespace for result implementation details.
Definition result.h:22
bool operator==(const ResultDescription< T > &lhs, const ResultDescription< T > &rhs)
Definition result_description_impl.h:277
bool operator!=(const ResultDescription< T > &lhs, const ResultDescription< T > &rhs)
Definition result_description_impl.h:287
Serves as component for functionality handling error and return types.
Definition result.h:20
Serves as the root component, with common functionality documented in core functionality.
Definition base.h:24
Definition result_description_decl.h:32
static bool isDetailedDescriptionSet(std::uint64_t value)
Definition result_description_impl.h:32
static const std::uint64_t error_code_bit
The error code bit indicating whether only the error code (1) was set or not (0)
Definition result_description_decl.h:36
static constexpr std::uint64_t toInternalErrorCode(std::int32_t error_code) noexcept
Definition result_description_impl.h:48
static const std::uint64_t error_code_bitmask
The error code bitmask to mask out the error code bit.
Definition result_description_decl.h:38
static constexpr const ReferenceCountedDescriptionType * toInternalErrorPointer(std::uint64_t error_code) noexcept
Definition result_description_impl.h:72
ReferenceCountedObjectInterface< DescriptionIntf > ReferenceCountedDescriptionType
Reference counted error description type.
Definition result_description_decl.h:34
static constexpr std::int32_t toExternalErrorCode(std::uint64_t error_code) noexcept
Definition result_description_impl.h:60
ResultDescriptionTraits()=delete
Must not be constructed/copied/moved.
static const std::uint64_t error_code_serialize_bitmask
The bitmask to serialize the error code to its internal representation.
Definition result_description_decl.h:40
static const std::uint64_t error_code_deserialize_bitmask
The bitmask to deserialize the internal error representation to its original value.
Definition result_description_decl.h:42
static bool isErrorCodeSet(std::uint64_t value)
Definition result_description_impl.h:41