ADTF
Loading...
Searching...
No Matches
adtf_a_util_result.h
Go to the documentation of this file.
1
7#pragma once
8
9#include <a_util/result.h>
10#include <adtf_utils.h>
11#include <functional>
12
13namespace adtf_util
14{
15
16inline tResult getConvertedResult(std::function<a_util::result::Result()> callExpression)
17{
18 auto res = callExpression();
19 if (static_cast<bool>(res))
20 {
21 return tResult(ERR_NOERROR);
22 }
23 else
24 {
25 return tResult(res.getErrorCode(), res.getDescription(), res.getLine(), res.getFile(), res.getFunction());
26 }
27}
28} // namespace adtf_util
29
30#define TO_ADTF_RESULT(_expr_) adtf_util::getConvertedResult([&]() -> a_util::result::Result { return _expr_; })
31
32namespace adtf_util
33{
34
35inline bool operator==(const tResult& oLeft, const a_util::result::Result& oRight)
36{
37 return oLeft.GetErrorCode().value == oRight.getErrorCode();
38}
39
40inline bool operator!=(const tResult& oLeft, const a_util::result::Result& oRight)
41{
42 return oLeft.GetErrorCode().value != oRight.getErrorCode();
43}
44
45inline bool operator==(const a_util::result::Result& oLeft, const tResult& oRight)
46{
47 return operator==(oRight, oLeft);
48}
49
50inline bool operator!=(const a_util::result::Result& oLeft, const tResult& oRight)
51{
52 return operator!=(oRight, oLeft);
53}
54
55
56
57}
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
tErrorCode GetErrorCode() const noexcept
Get error code.
std::int32_t getErrorCode() const
Definition result_type_impl.h:136