ADTF
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 
13 namespace adtf_util
14 {
15 
16 inline 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 
32 namespace adtf_util
33 {
34 
35 inline bool operator==(const tResult& oLeft, const a_util::result::Result& oRight)
36 {
37  return oLeft.GetErrorCode().value == oRight.getErrorCode();
38 }
39 
40 inline bool operator!=(const tResult& oLeft, const a_util::result::Result& oRight)
41 {
42  return oLeft.GetErrorCode().value != oRight.getErrorCode();
43 }
44 
45 inline bool operator==(const a_util::result::Result& oLeft, const tResult& oRight)
46 {
47  return operator==(oRight, oLeft);
48 }
49 
50 inline bool operator!=(const a_util::result::Result& oLeft, const tResult& oRight)
51 {
52  return operator!=(oRight, oLeft);
53 }
54 
55 
56 
57 }
Copyright © Audi Electronics Venture GmbH.
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
tBool operator!=(const tErrorCode &lhs, const tErrorCode &rhs)
Compare two POD error code types for inequality.
tBool operator==(const tErrorCode &lhs, const tErrorCode &rhs)
Compare two POD error code types for equality.
tErrorCode GetErrorCode() const
Get error code.
A common result class usable as return value throughout.
std::int32_t getErrorCode() const
Get error code.
ADTF adtf_util Namespace - Within adtf this is used as adtf::util or adtf_util and also defined as A_...
Common include for component a_util::result.