ADTF
Loading...
Searching...
No Matches
A_UTILS_NS::cResult Class Reference

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

#include <result.h>

Classes

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

Public Member Functions

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

Friends

void swap (cResult &i_oLHS, cResult &i_oRHS)
 Specialized friend swap function to enable ADL in std::swap later.
 
tBool operator== (const cResult &i_oLHS, const cResult &i_oRHS)
 Comparison operator (shallow comparison)
 

Detailed Description

A common result class usable as return value throughout.

Constructor & Destructor Documentation

◆ cResult() [1/10]

A_UTILS_NS::cResult::cResult ( )
inlineconstexprnoexcept

Construct empty which basically means no error occurred.

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

◆ cResult() [2/10]

A_UTILS_NS::cResult::cResult ( decltype(ERR_NOERROR) )
inlineconstexprnoexcept

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()

◆ cResult() [3/10]

template<tErrorCode::error_code_type ErrorCode>
A_UTILS_NS::cResult::cResult ( const tError< ErrorCode > & i_oError)
inlineconstexprnoexcept

Assign error code to result object.

Parameters
[in]i_oErrorThe error code

◆ cResult() [4/10]

A_UTILS_NS::cResult::cResult ( tErrorCode i_oError)
inlineconstexprnoexcept

Assign error code to result object.

Parameters
[in]i_oErrorThe error code

◆ cResult() [5/10]

template<tErrorCode::error_code_type ErrorCode>
A_UTILS_NS::cResult::cResult ( tError< ErrorCode > i_oError,
const tChar * i_strErrorDescription,
tInt32 i_nLine,
const tChar * i_strFile,
const tChar * i_strFunction )
inlineexplicitnoexcept

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: "")

◆ cResult() [6/10]

A_UTILS_NS::cResult::cResult ( tErrorCode::error_code_type i_nErrorCode)
inlineexplicitconstexprnoexcept

Create result object with just the error code type.

Parameters
[in]i_nErrorCodeThe error code

◆ cResult() [7/10]

A_UTILS_NS::cResult::cResult ( tErrorCode::error_code_type i_nErrorCode,
const tChar * i_strErrorDescription,
tInt32 i_nLine,
const tChar * i_strFile,
const tChar * i_strFunction )
inlineexplicitnoexcept

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: "")

◆ cResult() [8/10]

A_UTILS_NS::cResult::cResult ( const cResult & i_oResult,
const tChar * i_strErrorDescription,
tInt32 i_nLine,
const tChar * i_strFile,
const tChar * i_strFunction )
inlineexplicitnoexcept

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.

◆ cResult() [9/10]

A_UTILS_NS::cResult::cResult ( const cResult & i_oOther)
noexcept

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/10]

A_UTILS_NS::cResult::cResult ( cResult && i_oOther)
inlineconstexprnoexcept

Move operator.

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

Member Function Documentation

◆ GetDescription()

const tChar * A_UTILS_NS::cResult::GetDescription ( ) const
noexcept

Get user provided error description.

Returns
Error description as string.

◆ GetErrorCode()

tErrorCode A_UTILS_NS::cResult::GetErrorCode ( ) const
noexcept

Get error code.

Returns
Error code.

◆ GetErrorString()

const tChar * A_UTILS_NS::cResult::GetErrorString ( ) const
noexcept

Get error code as string representation.

Returns
Error code represented as string.

◆ GetFile()

const tChar * A_UTILS_NS::cResult::GetFile ( ) const
noexcept

Get name of the file the error was reported in.

Returns
File name as string.

◆ GetFunction()

const tChar * A_UTILS_NS::cResult::GetFunction ( ) const
noexcept

Get name of the function the error was reported in.

Returns
Function name as string.

◆ GetLine()

tInt32 A_UTILS_NS::cResult::GetLine ( ) const
noexcept

Get line in source file where the error was reported.

Returns
Line number.

◆ IsEqual() [1/2]

template<typename... ErrorTypes>
tBool A_UTILS_NS::cResult::IsEqual ( const ErrorTypes &... i_oErrorVals) const
inlinenoexcept

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.

◆ IsEqual() [2/2]

template<tErrorCode::error_code_type ErrorCode>
tBool A_UTILS_NS::cResult::IsEqual ( const tError< ErrorCode > & i_oErrorVal) const
inlinenoexcept

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.

◆ IsFailed()

tBool A_UTILS_NS::cResult::IsFailed ( ) const
inlinenoexcept

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

Returns
tTrue if an error is contained, tFalse otherwise.

◆ IsOk()

tBool A_UTILS_NS::cResult::IsOk ( ) const
inlinenoexcept

Check whether this result object contains ERR_NOERROR.

Returns
tTrue if no error is contained, tFalse otherwise.

◆ operator=() [1/2]

cResult & A_UTILS_NS::cResult::operator= ( cResult i_oOther)
inlinenoexcept

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

◆ operator=() [2/2]

cResult & A_UTILS_NS::cResult::operator= ( decltype(ERR_NOERROR) )
inlinenoexcept

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

Friends And Related Symbol Documentation

◆ operator==

tBool operator== ( const cResult & i_oLHS,
const cResult & i_oRHS )
friend

Comparison operator (shallow comparison)

Parameters
[in,out]i_oLHSLeft hand side result object.
[in,out]i_oRHSRight hand side result object.
Returns
tTrue if both result objects match, tFalse otherwise.

◆ swap

void swap ( cResult & i_oLHS,
cResult & i_oRHS )
friend

Specialized friend swap function to enable ADL in std::swap later.

Parameters
[in,out]i_oLHSLeft hand side result object.
[in,out]i_oRHSRight hand side result object.

The documentation for this class was generated from the following file: