ADTF  3.14.3
a_util::result Namespace Reference

Serves as component for functionality handling error and return types. More...

Namespaces

 detail
 Serves as namespace for result implementation details.
 

Classes

struct  ResultInfo
 Basic result information template, used by a_util::result::Result. More...
 
struct  ResultInfo< void >
 Implements basic success result information for usage with a_util::result::Result. More...
 
class  Result
 A common result class usable as return value throughout. More...
 

Enumerations

enum  ResultFormatFlags {
  DisableNone = 0x00 , DisableCode = 0x01 , DisableName = 0x02 , DisableMessage = 0x04 ,
  DisableFile = 0x08 , DisableLine = 0x10 , DisableFunction = 0x20
}
 Define flags. More...
 

Functions

template<typename ResultType >
bool isOk (const ResultType &result)
 Check whether a return value indicates a successful function execution. More...
 
template<typename ResultType >
bool isFailed (const ResultType &result)
 Check whether a return value indicates an unsuccessful function execution. More...
 
template<typename ResultTypeLHS , typename ResultTypeRHS >
bool operator== (const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
 Compare two specialized result information objects for equality. More...
 
template<typename ResultTypeLHS , typename ResultTypeRHS >
bool operator!= (const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
 Compare two specialized result information objects for inequality. More...
 
template<typename ResultTypeLHS , typename ResultTypeRHS >
bool operator< (const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
 Less-than operator for two specialized result information objects. More...
 
template<typename ResultTypeLHS , typename ResultTypeRHS >
bool operator> (const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
 Greater-than operator for two specialized result information objects. More...
 
template<typename ResultTypeLHS , typename ResultTypeRHS >
bool operator<= (const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
 Less-than-or-equal operator for two specialized result information objects. More...
 
template<typename ResultTypeLHS , typename ResultTypeRHS >
bool operator>= (const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
 Greater-than-or-equal operator for two specialized result information objects. More...
 
bool operator== (const Result &lhs, const Result &rhs)
 
bool operator!= (const Result &lhs, const Result &rhs)
 Negated comparison operator (shallow comparison) More...
 
template<typename T >
bool operator== (const Result &result, const ResultInfo< T > &error_code)
 Comparison operator (equality) for objects of type Result and ResultInfo. More...
 
template<typename T >
bool operator!= (const Result &result, const ResultInfo< T > &error_code)
 Comparison operator (inequality) for objects of type Result and ResultInfo. More...
 
template<typename T >
bool operator== (const ResultInfo< T > &error_code, const Result &result)
 Comparison operator (equality) for objects of type Result and ResultInfo. More...
 
template<typename T >
bool operator!= (const ResultInfo< T > &error_code, const Result &result)
 Comparison operator (inequality) for objects of type Result and ResultInfo. More...
 
void swap (Result &lhs, Result &rhs)
 
template<>
bool isOk< Result > (const Result &result)
 Specialization of a_util::result::isOk<typename ResultType>() for correct lookup. More...
 
std::string toString (const Result &result, ResultFormatFlags formatting_flags=DisableNone, const char *format=nullptr)
 Copy all information of an assigned result object to a (formatted) string. More...
 

Detailed Description

Serves as component for functionality handling error and return types.

Enumeration Type Documentation

◆ ResultFormatFlags

Define flags.

Enumerator
DisableNone 

Disable nothing, stringify everything.

DisableCode 

Do not use the string representation of the error code.

DisableName 

Do not use the string representation of the error string.

DisableMessage 

Do not use the string representation of the error message.

DisableFile 

Do not use the string representation of the file name.

DisableLine 

Do not use the string representation of the line.

DisableFunction 

Do not use the string representation of the function.

Definition at line 34 of file result_util.h.

Function Documentation

◆ isFailed()

bool isFailed ( const ResultType &  result)
inline

Check whether a return value indicates an unsuccessful function execution.

Template Parameters
ResultTypeType of the result value
Parameters
[in]resultValue of the result type
Returns
true if result indicates failure, false otherwise.

Definition at line 36 of file result_info_impl.h.

References isOk().

Referenced by ddl::access_element::findArrayEndIndex(), ddl::access_element::getArray(), ddl::access_element::getArrayValue(), ddl::access_element::getValue(), ddl::access_element::reset(), ddl::access_element::setValue(), and ddl::serialization::transform().

◆ isOk()

bool isOk ( const ResultType &  result)
inline

Check whether a return value indicates a successful function execution.

Template Parameters
ResultTypeType of the result value
Parameters
[in]resultValue of the result type
Returns
true if result indicates success, false otherwise.

Definition at line 30 of file result_info_impl.h.

Referenced by ddl::access_element::findIndex(), ddl::access_element::getArrayAddress(), Result::getErrorLabel(), ddl::access_element::getStructAddress(), ddl::access_element::getValue(), ddl::access_element::getValueAddress(), ddl::access_element::getValueAsString(), and isFailed().

◆ isOk< Result >()

bool isOk< Result > ( const Result result)
inline

Specialization of a_util::result::isOk<typename ResultType>() for correct lookup.

Parameters
[in]resultResult instance to check for error
Returns
If error code equals 0, true, otherwise false

Definition at line 268 of file result_type_impl.h.

References Result::getErrorCode().

◆ operator!=() [1/4]

bool operator!= ( const Result lhs,
const Result rhs 
)
inline

Negated comparison operator (shallow comparison)

Parameters
[in,out]lhsLeft hand side result object.
[in,out]rhsRight hand side result object.
Returns
true if both result objects do not match, false otherwise.

Definition at line 231 of file result_type_impl.h.

◆ operator!=() [2/4]

bool operator!= ( const Result result,
const ResultInfo< T > &  error_code 
)
inline

Comparison operator (inequality) for objects of type Result and ResultInfo.

Template Parameters
TError code type handled by ResultInfo<>
Parameters
[in]resultLeft hand side result object
[in]error_codeRight hand side error object
Returns
true if both objects contain different error codes, false otherwise

Definition at line 243 of file result_type_impl.h.

◆ operator!=() [3/4]

bool operator!= ( const ResultInfo< ResultTypeLHS > &  lhs,
const ResultInfo< ResultTypeRHS > &  rhs 
)
inline

Compare two specialized result information objects for inequality.

Template Parameters
ResultTypeLHSLeft hand side result type
ResultTypeRHSRight hand side result type
Parameters
[in]lhsLeft hand side result information
[in]rhsRight hand side result information
Returns
false if rhs and lhs are equal, true otherwise.

Definition at line 72 of file result_info_impl.h.

References operator==().

◆ operator!=() [4/4]

bool operator!= ( const ResultInfo< T > &  error_code,
const Result result 
)
inline

Comparison operator (inequality) for objects of type Result and ResultInfo.

Template Parameters
TError code type handled by ResultInfo<>
Parameters
[in]error_codeLeft hand side error object
[in]resultRight hand side result object
Returns
true if both objects contain different error codes, false otherwise

Definition at line 255 of file result_type_impl.h.

◆ operator<()

bool operator< ( const ResultInfo< ResultTypeLHS > &  lhs,
const ResultInfo< ResultTypeRHS > &  rhs 
)
inline

Less-than operator for two specialized result information objects.

Template Parameters
ResultTypeLHSLeft hand side result type
ResultTypeRHSRight hand side result type
Parameters
[in]lhsLeft hand side result information
[in]rhsRight hand side result information
Returns
true if lhs is less than rhs, false otherwise.

Definition at line 78 of file result_info_impl.h.

References ResultInfo< T >::getCode().

Referenced by operator>(), and operator>=().

◆ operator<=()

bool operator<= ( const ResultInfo< ResultTypeLHS > &  lhs,
const ResultInfo< ResultTypeRHS > &  rhs 
)
inline

Less-than-or-equal operator for two specialized result information objects.

Template Parameters
ResultTypeLHSLeft hand side result type
ResultTypeRHSRight hand side result type
Parameters
[in]lhsLeft hand side result information
[in]rhsRight hand side result information
Returns
true if lhs is less than or equal rhs, false otherwise.

Definition at line 90 of file result_info_impl.h.

References operator>().

◆ operator==() [1/4]

bool a_util::result::operator== ( const Result lhs,
const Result rhs 
)
inline
Parameters
[in,out]lhsLeft hand side result object.
[in,out]rhsRight hand side result object.
Returns
true if both result objects match, false otherwise.

Definition at line 226 of file result_type_impl.h.

◆ operator==() [2/4]

bool operator== ( const Result result,
const ResultInfo< T > &  error_code 
)
inline

Comparison operator (equality) for objects of type Result and ResultInfo.

Template Parameters
TError code type handled by ResultInfo<>
Parameters
[in]resultLeft hand side result object
[in]error_codeRight hand side error object
Returns
true if both objects contain the same error code, false otherwise

Definition at line 237 of file result_type_impl.h.

References ResultInfo< T >::getCode(), and Result::getErrorCode().

◆ operator==() [3/4]

bool operator== ( const ResultInfo< ResultTypeLHS > &  lhs,
const ResultInfo< ResultTypeRHS > &  rhs 
)
inline

Compare two specialized result information objects for equality.

Template Parameters
ResultTypeLHSLeft hand side result type
ResultTypeRHSRight hand side result type
Parameters
[in]lhsLeft hand side result information
[in]rhsRight hand side result information
Returns
true if rhs and lhs are equal, false otherwise.

Definition at line 64 of file result_info_impl.h.

References ResultInfo< T >::getCode(), ResultInfo< T >::getLabel(), and a_util::maybe_unused().

Referenced by operator!=().

◆ operator==() [4/4]

bool operator== ( const ResultInfo< T > &  error_code,
const Result result 
)
inline

Comparison operator (equality) for objects of type Result and ResultInfo.

Template Parameters
TError code type handled by ResultInfo<>
Parameters
[in]error_codeLeft hand side error object
[in]resultRight hand side result object
Returns
true if both objects contain the same error code, false otherwise

Definition at line 249 of file result_type_impl.h.

◆ operator>()

bool operator> ( const ResultInfo< ResultTypeLHS > &  lhs,
const ResultInfo< ResultTypeRHS > &  rhs 
)
inline

Greater-than operator for two specialized result information objects.

Template Parameters
ResultTypeLHSLeft hand side result type
ResultTypeRHSRight hand side result type
Parameters
[in]lhsLeft hand side result information
[in]rhsRight hand side result information
Returns
false if lhs is less than or equal rhs, true otherwise.

Definition at line 84 of file result_info_impl.h.

References operator<().

Referenced by operator<=().

◆ operator>=()

bool operator>= ( const ResultInfo< ResultTypeLHS > &  lhs,
const ResultInfo< ResultTypeRHS > &  rhs 
)
inline

Greater-than-or-equal operator for two specialized result information objects.

Template Parameters
ResultTypeLHSLeft hand side result type
ResultTypeRHSRight hand side result type
Parameters
[in]lhsLeft hand side result information
[in]rhsRight hand side result information
Returns
false if lhs is less than rhs, true otherwise.

Definition at line 96 of file result_info_impl.h.

References operator<().

◆ swap()

void a_util::result::swap ( Result lhs,
Result rhs 
)
inline
Parameters
[in,out]lhsLeft hand side result object.
[in,out]rhsRight hand side result object.

Definition at line 260 of file result_type_impl.h.

◆ toString()

std::string a_util::result::toString ( const Result result,
ResultFormatFlags  formatting_flags = DisableNone,
const char *  format = nullptr 
)

Copy all information of an assigned result object to a (formatted) string.

Parameters
[in]resultThe result instance getting stringified
[in]formatting_flagsFlags to disable stringification of specific information offered by Result
[in]formatOptional format specifier - if left empty, the default format is used. Currently not implemented.
Returns
String representation of all needed information from the result object

Copyright © Audi Electronics Venture GmbH. All rights reserved. (Generated on Thu Jun 9 2022 by doxygen 1.9.1)