mitteLib
Loading...
Searching...
No Matches
result_macro.hpp File Reference
#include <mlab/log.hpp>
Include dependency graph for result_macro.hpp:

Go to the source code of this file.

Macros

#define MLAB_RESULT_LOG_PREFIX   "MLAB"
 
#define MLAB_FAIL_MSG(CMD_STR, RESULT)
 
#define MLAB_FAIL_CMD(CMD_STR, RESULT)
 
#define MLAB_FAIL_CAST_CMD(CMD_STR, RESULT)
 
#define MLAB_CMD_WITH_NAMED_RESULT(CMD, RESULT_NAME)
 
#define MLAB_CAST_CMD_WITH_NAMED_RESULT(CMD, RESULT_NAME)
 
#define MLAB_CMD_WITH_NAMED_RESULT_SILENT(CMD, RESULT_NAME)
 
#define TRY(CMD)   MLAB_CMD_WITH_NAMED_RESULT(CMD, _r)
 
#define TRY_SILENT(CMD)   MLAB_CMD_WITH_NAMED_RESULT_SILENT(CMD, _r)
 
#define TRY_RESULT(CMD)
 
#define TRY_RESULT_SILENT(CMD)
 
#define TRY_RESULT_AS(CMD, RES_VAR)
 
#define TRY_RESULT_AS_SILENT(CMD, RES_VAR)
 
#define TRY_CAST(CMD)   MLAB_CAST_CMD_WITH_NAMED_RESULT(CMD, _r)
 
#define TRY_CAST_SILENT(CMD)   MLAB_CAST_CMD_WITH_NAMED_RESULT_SILENT(CMD, _r)
 
#define TRY_CAST_RESULT(CMD)
 
#define TRY_CAST_RESULT_SILENT(CMD)
 
#define TRY_CAST_RESULT_AS(CMD, RES_VAR)
 
#define TRY_CAST_RESULT_AS_SILENT(CMD, RES_VAR)
 

Macro Definition Documentation

◆ MLAB_CAST_CMD_WITH_NAMED_RESULT

#define MLAB_CAST_CMD_WITH_NAMED_RESULT ( CMD,
RESULT_NAME )
Value:
if (auto RESULT_NAME = (CMD); not RESULT_NAME) { \
MLAB_FAIL_CAST_CMD(#CMD, RESULT_NAME) \
}

◆ MLAB_CMD_WITH_NAMED_RESULT

#define MLAB_CMD_WITH_NAMED_RESULT ( CMD,
RESULT_NAME )
Value:
if (auto RESULT_NAME = (CMD); not RESULT_NAME) { \
MLAB_FAIL_CMD(#CMD, RESULT_NAME) \
}

◆ MLAB_CMD_WITH_NAMED_RESULT_SILENT

#define MLAB_CMD_WITH_NAMED_RESULT_SILENT ( CMD,
RESULT_NAME )
Value:
if (auto RESULT_NAME = (CMD); not RESULT_NAME) { \
return RESULT_NAME.error(); \
}

◆ MLAB_FAIL_CAST_CMD

#define MLAB_FAIL_CAST_CMD ( CMD_STR,
RESULT )
Value:
MLAB_FAIL_MSG(CMD_STR, RESULT) \
return cast_error((RESULT).error());
#define MLAB_FAIL_MSG(CMD_STR, RESULT)
Definition result_macro.hpp:16

◆ MLAB_FAIL_CMD

#define MLAB_FAIL_CMD ( CMD_STR,
RESULT )
Value:
MLAB_FAIL_MSG(CMD_STR, RESULT) \
return (RESULT).error();

◆ MLAB_FAIL_MSG

#define MLAB_FAIL_MSG ( CMD_STR,
RESULT )
Value:
LOGW(MLAB_RESULT_LOG_PREFIX, "%s:%d failed %s with %s", \
__FILE__, __LINE__, CMD_STR, to_string((RESULT).error()));
#define LOGW(tag, format,...)
Definition log.hpp:37
#define MLAB_RESULT_LOG_PREFIX
Definition result_macro.hpp:13

◆ MLAB_RESULT_LOG_PREFIX

#define MLAB_RESULT_LOG_PREFIX   "MLAB"

◆ TRY

#define TRY ( CMD)    MLAB_CMD_WITH_NAMED_RESULT(CMD, _r)

◆ TRY_CAST

#define TRY_CAST ( CMD)    MLAB_CAST_CMD_WITH_NAMED_RESULT(CMD, _r)

◆ TRY_CAST_RESULT

#define TRY_CAST_RESULT ( CMD)
Value:
else
#define MLAB_CAST_CMD_WITH_NAMED_RESULT(CMD, RESULT_NAME)
Definition result_macro.hpp:33

◆ TRY_CAST_RESULT_AS

#define TRY_CAST_RESULT_AS ( CMD,
RES_VAR )
Value:
else

◆ TRY_CAST_RESULT_AS_SILENT

#define TRY_CAST_RESULT_AS_SILENT ( CMD,
RES_VAR )
Value:
MLAB_CAST_CMD_WITH_NAMED_RESULT_SILENT(CMD, RES_VAR) \
else

◆ TRY_CAST_RESULT_SILENT

#define TRY_CAST_RESULT_SILENT ( CMD)
Value:
MLAB_CAST_CMD_WITH_NAMED_RESULT_SILENT(CMD, r) \
else

◆ TRY_CAST_SILENT

#define TRY_CAST_SILENT ( CMD)    MLAB_CAST_CMD_WITH_NAMED_RESULT_SILENT(CMD, _r)

◆ TRY_RESULT

#define TRY_RESULT ( CMD)
Value:
else
#define MLAB_CMD_WITH_NAMED_RESULT(CMD, RESULT_NAME)
Definition result_macro.hpp:28

◆ TRY_RESULT_AS

#define TRY_RESULT_AS ( CMD,
RES_VAR )
Value:
else

◆ TRY_RESULT_AS_SILENT

#define TRY_RESULT_AS_SILENT ( CMD,
RES_VAR )
Value:
else
#define MLAB_CMD_WITH_NAMED_RESULT_SILENT(CMD, RESULT_NAME)
Definition result_macro.hpp:38

◆ TRY_RESULT_SILENT

#define TRY_RESULT_SILENT ( CMD)
Value:

◆ TRY_SILENT

#define TRY_SILENT ( CMD)    MLAB_CMD_WITH_NAMED_RESULT_SILENT(CMD, _r)