Dev Essential
Loading...
Searching...
No Matches
result_type_decl.h
Go to the documentation of this file.
1
14
15#ifndef A_UTIL_UTIL_RESULT_RESULT_TYPE_DECL_HEADER_INCLUDED
16#define A_UTIL_UTIL_RESULT_RESULT_TYPE_DECL_HEADER_INCLUDED
17
20
21#include <utility> //std::swap
22
23namespace a_util {
24namespace result {
25namespace detail {
26// forward declaration
28
29} // namespace detail
30
34class Result {
35public: // construction
45 Result();
46
54 Result(bool val);
55
65
70 template <typename ErrorType>
71 Result(const ResultInfo<ErrorType>& error);
72
82 template <typename ErrorType>
83 explicit Result(ResultInfo<ErrorType> error,
84 const char* error_description,
85 std::int32_t line,
86 const char* file,
87 const char* function);
88
93 Result(std::int32_t error_code);
94
103 explicit Result(std::int32_t error_code,
104 const char* error_description,
105 std::int32_t line,
106 const char* file,
107 const char* function);
108
117 explicit Result(const Result& other_result,
118 const char* error_description,
119 std::int32_t line,
120 const char* file,
121 const char* function);
122
126 ~Result();
127
134 Result(const Result& other);
135
146
153 Result& operator=(Result other);
154
161 Result& operator=(bool val);
162
169 Result& operator=(std::int32_t val);
170
175 Result(Result&& other);
176
177public: // access
182 std::int32_t getErrorCode() const;
183
188 const char* getErrorLabel() const;
189
194 const char* getDescription() const;
195
200 std::int32_t getLine() const;
201
206 const char* getFile() const;
207
212 const char* getFunction() const;
213
218 explicit operator bool() const noexcept;
219
225 friend void swap(Result& lhs, Result& rhs);
226
233 friend bool operator==(const Result& lhs, const Result& rhs);
234
235private: // private constructor
245 explicit Result(std::int32_t error_code,
246 const char* error_description,
247 std::int32_t line,
248 const char* file,
249 const char* function,
250 const char* label);
251
261 static Result createFrom(std::int32_t error_code,
262 const char* error_description,
263 std::int32_t line,
264 const char* file,
265 const char* function);
266
267private: // private member data
270 DescriptionType _result_handle;
271}; // class Result
272
279bool operator!=(const Result& lhs, const Result& rhs);
280
288template <typename T>
289bool operator==(const Result& result, const ResultInfo<T>& error_code);
290
298template <typename T>
299bool operator!=(const Result& result, const ResultInfo<T>& error_code);
300
308template <typename T>
309bool operator==(const ResultInfo<T>& error_code, const Result& result);
310
318template <typename T>
319bool operator!=(const ResultInfo<T>& error_code, const Result& result);
320
327template <>
328DEV_ESSENTIAL_DEPRECATED("Please use the conversion Result::operator bool().")
329bool isOk<Result>(const Result& result);
330
331} // namespace result
332} // namespace a_util
333
335namespace std {
341template <>
343} // namespace std
344
347
348#endif // A_UTIL_UTIL_RESULT_RESULT_TYPE_DECL_HEADER_INCLUDED
Definition result_type_decl.h:34
const char * getFile() const
Definition result_type_impl.h:177
const char * getErrorLabel() const
Definition result_type_impl.h:144
std::int32_t getLine() const
Definition result_type_impl.h:168
Result()
Definition result_type_impl.h:30
const char * getFunction() const
Definition result_type_impl.h:186
std::int32_t getErrorCode() const
Definition result_type_impl.h:136
friend bool operator==(const Result &lhs, const Result &rhs)
Definition result_type_impl.h:225
const char * getDescription() const
Definition result_type_impl.h:154
friend void swap(Result &lhs, Result &rhs)
Definition result_type_impl.h:259
Result & operator=(const ResultInfo< void > &)
Definition result_type_impl.h:123
~Result()
Definition result_type_impl.h:97
Definition error_description_intf.h:28
Wrapper for either a pointer to a detailed description object or simply a numeric error code.
Definition result_description_decl.h:111
#define DEV_ESSENTIAL_DEPRECATED(msg)
Definition deprecated.h:44
Serves as namespace for result implementation details.
Definition result.h:22
Serves as component for functionality handling error and return types.
Definition result.h:20
void swap(Result &lhs, Result &rhs)
Definition result_type_impl.h:259
bool operator!=(const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
Definition result_info_impl.h:66
bool operator==(const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
Definition result_info_impl.h:58
bool isOk(const ResultType &result)
Definition result_info_impl.h:24
Serves as the root component, with common functionality documented in core functionality.
Definition base.h:24
Definition result_info_decl.h:86