PResult.h File Reference

Detailed Description

Class PResult: a result returned by most of Papillon functions; this class is used to replace classic integer error code.

Definition in file PResult.h.

#include <PapillonCommon.h>
#include <PString.h>
Include dependency graph for PResult.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  PResult
 The PResult class represents the result returned by most of Papillon functions; this class is used to replace standard integer error code. More...
 

Macros

#define LogAndReturnIfFailed(expr)
 Macro used to simulate the following idiom: More...
 
#define LogAndReturnIfFalse(expr, message)
 Macro used to simulate the following idiom: More...
 
#define P_ON_FAILURE(result)   papillon::PResult __localErrorToStackIfFailure = result
 
#define P_RETURN(result)   return __localErrorToStackIfFailure.Push(result)
 
#define P_RETURN_IF_FAILURE(expr)   { papillon::PResult __ret = (expr); if (__ret.Failed()) return __localErrorToStackIfFailure.Push(__ret); }
 
#define ReturnIfFailed(expr)
 Macro used to simulate the following idiom: More...
 
#define ReturnIfOk(expr)
 Macro used to simulate the following idiom: More...
 

Macro Definition Documentation

◆ LogAndReturnIfFailed

#define LogAndReturnIfFailed (   expr)
Value:
{ \
papillon::PResult __ret = (expr); \
if (__ret.LogErrorIfAny(papillon::PString::Empty(), PAPILLON_SRC_POS).Failed()) \
return __ret; \
}

Macro used to simulate the following idiom:

{
PResult ret = MyFunction();
if (ret.LogErrorIfAny().Failed())
return ret;
}

Definition at line 71 of file PResult.h.

◆ LogAndReturnIfFalse

#define LogAndReturnIfFalse (   expr,
  message 
)
Value:
{ \
bool result = (expr); \
if (!result) { \
papillon::PResult __ret = papillon::PResult::Error(message); \
__ret.LogErrorIfAny(papillon::PString::Empty(), PAPILLON_SRC_POS); \
return __ret; \
} \
}

Macro used to simulate the following idiom:

{
bool result = MyFunction();
if (!result) {
ret = PResult::Error(message);
ret.LogErrorIfAny();
return ret;
}
}

Definition at line 92 of file PResult.h.

◆ P_ON_FAILURE

#define P_ON_FAILURE (   result)    papillon::PResult __localErrorToStackIfFailure = result

Definition at line 39 of file PResult.h.

◆ P_RETURN

#define P_RETURN (   result)    return __localErrorToStackIfFailure.Push(result)

Definition at line 40 of file PResult.h.

◆ P_RETURN_IF_FAILURE

#define P_RETURN_IF_FAILURE (   expr)    { papillon::PResult __ret = (expr); if (__ret.Failed()) return __localErrorToStackIfFailure.Push(__ret); }

Definition at line 41 of file PResult.h.

◆ ReturnIfFailed

#define ReturnIfFailed (   expr)
Value:
{ \
papillon::PResult __ret = (expr); \
if (__ret.Failed()) \
return __ret; \
}

Macro used to simulate the following idiom:

{
PResult ret = MyFunction();
if (ret.Failed())
return ret;
}

Definition at line 32 of file PResult.h.

◆ ReturnIfOk

#define ReturnIfOk (   expr)
Value:
{ \
papillon::PResult __ret = (expr); \
if (__ret.Ok()) \
return __ret; \
}

Macro used to simulate the following idiom:

{
PResult ret = MyFunction();
if (ret.Ok())
return ret;
}

Definition at line 54 of file PResult.h.