ADTF
cResult

A common result class usable as return value throughout. More...

Inheritance diagram for cResult:
[legend]

Classes

struct  sErrorEval
 Used as entry point for comparison on the error codes used in IsEqual() More...
 
struct  sErrorEval< ErrorType >
 Used as exit point for comparison on the error codes used in IsEqual() More...
 

Public Member Functions

 cResult ()
 Construct empty which basically means no error occurred. More...
 
 cResult (decltype(ERR_NOERROR))
 Construct with ERR_NOERROR. More...
 
template<tErrorCode::error_code_type ErrorCode>
 cResult (const tError< ErrorCode > &i_oError)
 Assign error code to result object. More...
 
 cResult (tErrorCode i_oError)
 Assign error code to result object. More...
 
template<tErrorCode::error_code_type ErrorCode>
 cResult (tError< ErrorCode > i_oError, const tChar *i_strErrorDescription, tInt32 i_nLine, const tChar *i_strFile, const tChar *i_strFunction)
 Construct result object with complete set of error information. More...
 
 cResult (tErrorCode::error_code_type i_nErrorCode)
 Create result object with just the error code type. More...
 
 cResult (tErrorCode::error_code_type i_nErrorCode, const tChar *i_strErrorDescription, tInt32 i_nLine, const tChar *i_strFile, const tChar *i_strFunction)
 Create result object with complete set of error information from just an error code. More...
 
 cResult (const cResult &i_oResult, const tChar *i_strErrorDescription, tInt32 i_nLine, const tChar *i_strFile, const tChar *i_strFunction)
 Create result object from another result, creating new detailed information. More...
 
 ~cResult ()
 Destructor.
 
 cResult (const cResult &i_oOther)
 Copy constructor. More...
 
cResultoperator= (decltype(ERR_NOERROR))
 Assign with ERR_NOERROR. More...
 
cResultoperator= (cResult i_oOther)
 Assignment operator. More...
 
 cResult (cResult &&i_oOther)
 Move operator. More...
 
tErrorCode GetErrorCode () const
 Get error code. More...
 
const tCharGetErrorString () const
 Get error code as string representation. More...
 
const tCharGetDescription () const
 Get user provided error description. More...
 
tInt32 GetLine () const
 Get line in source file where the error was reported. More...
 
const tCharGetFile () const
 Get name of the file the error was reported in. More...
 
const tCharGetFunction () const
 Get name of the function the error was reported in. More...
 
template<tErrorCode::error_code_type ErrorCode>
tBool IsEqual (const tError< ErrorCode > &i_oErrorVal) const
 Check whether an error code is equal to the contained one. More...
 
template<typename ... ErrorTypes>
tBool IsEqual (const ErrorTypes &... i_oErrorVals) const
 Check whether one of several error codes is equal to the contained one. More...
 
tBool IsOk () const
 Check whether this result object contains ERR_NOERROR. More...
 
tBool IsFailed () const
 Check whether this result object contains an error != ERR_NOERROR. More...
 

Private Types

typedef detail::result_description< detail::IErrorDescriptiondescription_type
 Abbreviation typedef.
 

Private Member Functions

 cResult (tErrorCode i_nErrorCode, const tChar *i_strErrorDescription, tInt32 i_nLine, const tChar *i_strFile, const tChar *i_strFunction, const tChar *i_strErrorCode)
 Construct result object with complete set of error information. More...
 

Static Private Member Functions

static cResult CreateFrom (tErrorCode::error_code_type i_nErrorCode, const tChar *i_strErrorDescription, tInt32 i_nLine, const tChar *i_strFile, const tChar *i_strFunction)
 Create a detailed object of type cResult on the heap from an error code. More...
 
static tErrorString GetErrorString (const tErrorCode &i_oErrorCode)
 Query the string representation of an error code. More...
 

Private Attributes

description_type m_oResultHandler
 The result handler wrapper.
 

Detailed Description

A common result class usable as return value throughout.

Definition at line 17 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/result.h.

Constructor & Destructor Documentation

◆ cResult() [1/11]

cResult ( )
inline

Construct empty which basically means no error occurred.

Postcondition
ERR_NOERROR == GetErrorCode() &&
-1 == GetLine() &&
"No error occurred" == GetDescription() &&
"" == GetFile() &&
"" == GetFunction() &&
"" == GetErrorString()

Definition at line 287 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/result.h.

Referenced by cResult::cResult(), and cResult::operator=().

◆ cResult() [2/11]

cResult ( decltype(ERR_NOERROR)  )
inline

Construct with ERR_NOERROR.

This constructors sole intention is to provide the best match during compilation time if a function call returns with ERR_NOERROR. With decltype(ERR_NOERROR) being another type than all other error codes the compiler deduces this constructor as best fit.

Postcondition
See also
cResult()

Definition at line 291 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/result.h.

◆ cResult() [3/11]

cResult ( const tError< ErrorCode > &  i_oError)
inline

Assign error code to result object.

Parameters
[in]i_oErrorThe error code

Definition at line 296 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/result.h.

◆ cResult() [4/11]

cResult ( tErrorCode  i_oError)
inline

Assign error code to result object.

Parameters
[in]i_oErrorThe error code

Definition at line 301 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/result.h.

◆ cResult() [5/11]

cResult ( tError< ErrorCode >  i_oError,
const tChar i_strErrorDescription,
tInt32  i_nLine,
const tChar i_strFile,
const tChar i_strFunction 
)
inlineexplicit

Construct result object with complete set of error information.

Template Parameters
ErrorCodeError code (to deduce specialized template to stringify the error code)
Parameters
[in]i_oErrorThe The concrete error object
[in]i_strErrorDescriptionComplete description of the error (default: "")
[in]i_nLineLine in source file the error was reported (default: -1)
[in]i_strFileSource file the error was reported in (default: "")
[in]i_strFunctionFunction the error was reported in (default: "")

Definition at line 307 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/result.h.

◆ cResult() [6/11]

cResult ( tErrorCode::error_code_type  i_nErrorCode)
inlineexplicit

Create result object with just the error code type.

Parameters
[in]i_nErrorCodeThe error code

Definition at line 321 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/result.h.

◆ cResult() [7/11]

cResult ( tErrorCode::error_code_type  i_nErrorCode,
const tChar i_strErrorDescription,
tInt32  i_nLine,
const tChar i_strFile,
const tChar i_strFunction 
)
inlineexplicit

Create result object with complete set of error information from just an error code.

Parameters
[in]i_nErrorCodeThe error code
[in]i_strErrorDescriptionComplete description of the error (default: "")
[in]i_nLineLine in source file the error was reported (default: -1)
[in]i_strFileSource file the error was reported in (default: "")
[in]i_strFunctionFunction the error was reported in (default: "")

Definition at line 326 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/result.h.

◆ cResult() [8/11]

cResult ( const cResult i_oResult,
const tChar i_strErrorDescription,
tInt32  i_nLine,
const tChar i_strFile,
const tChar i_strFunction 
)
inlineexplicit

Create result object from another result, creating new detailed information.

Parameters
[in]i_oResultResult to copy the error code and error code string information from.
[in]i_strErrorDescriptionComplete description of the error.
[in]i_nLineLine in source file the error was reported.
[in]i_strFileSource file the error was reported in.
[in]i_strFunctionFunction the error was reported in.

Definition at line 335 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/result.h.

◆ cResult() [9/11]

cResult ( const cResult i_oOther)

Copy constructor.

Parameters
[in]i_oOtherWhere this gets copied from.
Note
No new memory is allocated, the error information from i_oOther are safely referenced in the new created object of type cResult.

◆ cResult() [10/11]

cResult ( cResult &&  i_oOther)
inline

Move operator.

Parameters
[in]i_oOtherrvalue of type cResult moved to *this. Left in an empty but valid state.

Definition at line 360 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/result.h.

References cResult::cResult(), and cResult::swap.

◆ cResult() [11/11]

cResult ( tErrorCode  i_nErrorCode,
const tChar i_strErrorDescription,
tInt32  i_nLine,
const tChar i_strFile,
const tChar i_strFunction,
const tChar i_strErrorCode 
)
explicitprivate

Construct result object with complete set of error information.

Parameters
[in]i_nErrorCodeThe error code
[in]i_strErrorDescriptionComplete description of the error (default: "")
[in]i_nLineLine in source file the error was reported (default: -1)
[in]i_strFileSource file the error was reported in (default: "")
[in]i_strFunctionFunction the error was reported in (default: "")
[in]i_strErrorCodeString representation of error code (default: "")

Member Function Documentation

◆ CreateFrom()

static cResult CreateFrom ( tErrorCode::error_code_type  i_nErrorCode,
const tChar i_strErrorDescription,
tInt32  i_nLine,
const tChar i_strFile,
const tChar i_strFunction 
)
staticprivate

Create a detailed object of type cResult on the heap from an error code.

Parameters
[in]i_nErrorCodeThe error code to create the result object from.
[in]i_strErrorDescriptionComplete description of the error (default: "")
[in]i_nLineLine in source file the error was reported (default: -1)
[in]i_strFileSource file the error was reported in (default: "")
[in]i_strFunctionFunction the error was reported in (default: "")
Returns
Object of type cResult containing detailed error information.

◆ GetDescription()

const tChar* GetDescription ( ) const

Get user provided error description.

Returns
Error description as string.

◆ GetErrorCode()

tErrorCode GetErrorCode ( ) const

Get error code.

Returns
Error code.

Referenced by cResult::IsEqual(), and cResult::IsOk().

◆ GetErrorString() [1/2]

const tChar* GetErrorString ( ) const

Get error code as string representation.

Returns
Error code represented as string.

◆ GetErrorString() [2/2]

static tErrorString GetErrorString ( const tErrorCode i_oErrorCode)
staticprivate

Query the string representation of an error code.

Parameters
[in]i_oErrorCodeThe error code to retrieve the string representation of. This only works for known error types listed in file error.h
Returns
String representation of the error code. If error code is unknown "\0" is returned.

◆ GetFile()

const tChar* GetFile ( ) const

Get name of the file the error was reported in.

Returns
File name as string.

◆ GetFunction()

const tChar* GetFunction ( ) const

Get name of the function the error was reported in.

Returns
Function name as string.

◆ GetLine()

tInt32 GetLine ( ) const

Get line in source file where the error was reported.

Returns
Line number.

◆ IsEqual() [1/2]

tBool IsEqual ( const ErrorTypes &...  i_oErrorVals) const
inline

Check whether one of several error codes is equal to the contained one.

Template Parameters
ErrorTypesCompile time constant error code values
Parameters
[in]i_oErrorValsThe error values to compare with.
Returns
tTrue if one error code is the same as the currently held one, tFalse otherwise.

Definition at line 396 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/result.h.

References cResult::sErrorEval< ErrorType, ErrorTypes >::dispatch(), and cResult::GetErrorCode().

◆ IsEqual() [2/2]

tBool IsEqual ( const tError< ErrorCode > &  i_oErrorVal) const
inline

Check whether an error code is equal to the contained one.

Template Parameters
ErrorCodeCompile time constant error code value
Parameters
[in]i_oErrorValThe error value to compare with.
Returns
tTrue if the error code is the same as the currently held one, tFalse otherwise.

Definition at line 390 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/result.h.

References cResult::GetErrorCode().

Referenced by A_UTILS_NS::operator!=(), A_UTILS_NS::operator==(), and adtf::streaming::ant::operator==().

◆ IsFailed()

tBool IsFailed ( ) const
inline

Check whether this result object contains an error != ERR_NOERROR.

Returns
tTrue if an error is contained, tFalse otherwise.

Definition at line 384 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/result.h.

References cResult::IsOk().

Referenced by cBitSerializer::Read(), and cBitSerializer::Write().

◆ IsOk()

tBool IsOk ( ) const
inline

Check whether this result object contains ERR_NOERROR.

Returns
tTrue if no error is contained, tFalse otherwise.

Definition at line 379 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/result.h.

References cResult::GetErrorCode().

Referenced by cResult::IsFailed().

◆ operator=() [1/2]

cResult & operator= ( cResult  i_oOther)
inline

Assignment operator.

Parameters
[in]i_oOtherResult type being assigned to the this object.
Note
Passing i_oOther by value is fully intentional here!
Returns
*this

Definition at line 349 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/result.h.

References cResult::swap.

◆ operator=() [2/2]

cResult & operator= ( decltype(ERR_NOERROR)  )
inline

Assign with ERR_NOERROR.

This assignments sole intention is to provide the best match during compilation time if a function call returns with ERR_NOERROR. With decltype(ERR_NOERROR) being another type than all other error codes the compiler deduces this assignment operator as best fit.

Postcondition
See also
cResult()
Returns
*this

Definition at line 355 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/result.h.

References cResult::cResult().