Dev Essential  1.6.3
Loading...
Searching...
No Matches
a_util::result Namespace Reference

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

Namespaces

namespace  detail
 Serves as namespace for result implementation details.
 

Classes

class  Result
 
struct  ResultInfo
 
struct  ResultInfo< void >
 

Enumerations

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

Functions

template<typename ResultType>
bool isOk (const ResultType &result)
 
template<typename ResultType>
bool isFailed (const ResultType &result)
 
template<typename ResultTypeLHS, typename ResultTypeRHS>
bool operator== (const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
 
template<typename ResultTypeLHS, typename ResultTypeRHS>
bool operator!= (const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
 
template<typename ResultTypeLHS, typename ResultTypeRHS>
bool operator< (const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
 
template<typename ResultTypeLHS, typename ResultTypeRHS>
bool operator> (const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
 
template<typename ResultTypeLHS, typename ResultTypeRHS>
bool operator<= (const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
 
template<typename ResultTypeLHS, typename ResultTypeRHS>
bool operator>= (const ResultInfo< ResultTypeLHS > &lhs, const ResultInfo< ResultTypeRHS > &rhs)
 
bool operator== (const Result &lhs, const Result &rhs)
 
bool operator!= (const Result &lhs, const Result &rhs)
 
template<typename T>
bool operator== (const Result &result, const ResultInfo< T > &)
 
template<typename T>
bool operator!= (const Result &result, const ResultInfo< T > &error_code)
 
template<typename T>
bool operator== (const ResultInfo< T > &error_code, const Result &result)
 
template<typename T>
bool operator!= (const ResultInfo< T > &error_code, const Result &result)
 
void swap (Result &lhs, Result &rhs)
 
template<>
bool isOk< Result > (const Result &result)
 
template<>
bool isOk< Result > (const Result &result)
 
std::string toString (const Result &result, ResultFormatFlags formatting_flags=DisableNone, const char *format=nullptr)
 

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.

Function Documentation

◆ isFailed()

template<typename ResultType>
bool a_util::result::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
Deprecated
Usage of this function template is not type safe.
Returns
true if result indicates failure, false otherwise.

◆ isOk()

template<typename ResultType>
bool a_util::result::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
Deprecated
Usage of this function template is not type safe.
Returns
true if result indicates success, false otherwise.

◆ isOk< Result >() [1/2]

template<>
bool a_util::result::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
Deprecated
Please use Result::operator bool().
Returns
If error code equals 0, true, otherwise false

◆ isOk< Result >() [2/2]

template<>
bool a_util::result::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
Deprecated
Please use Result::operator bool().
Returns
If error code equals 0, true, otherwise false

◆ operator!=() [1/4]

bool a_util::result::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.

◆ operator!=() [2/4]

template<typename T>
bool a_util::result::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

◆ operator!=() [3/4]

template<typename ResultTypeLHS, typename ResultTypeRHS>
bool a_util::result::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.

◆ operator!=() [4/4]

template<typename T>
bool a_util::result::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

◆ operator<()

template<typename ResultTypeLHS, typename ResultTypeRHS>
bool a_util::result::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.

◆ operator<=()

template<typename ResultTypeLHS, typename ResultTypeRHS>
bool a_util::result::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.

◆ operator==() [1/4]

bool a_util::result::operator== ( const Result & lhs,
const Result & rhs )
inline

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 match, false otherwise.

◆ operator==() [2/4]

template<typename T>
bool a_util::result::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

◆ operator==() [3/4]

template<typename ResultTypeLHS, typename ResultTypeRHS>
bool a_util::result::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.

◆ operator==() [4/4]

template<typename T>
bool a_util::result::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

◆ operator>()

template<typename ResultTypeLHS, typename ResultTypeRHS>
bool a_util::result::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.

◆ operator>=()

template<typename ResultTypeLHS, typename ResultTypeRHS>
bool a_util::result::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.

◆ swap()

void a_util::result::swap ( Result & lhs,
Result & rhs )
inline

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

Parameters
[in,out]lhsLeft hand side result object.
[in,out]rhsRight hand side result object.

◆ 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