FlatImage
A configurable Linux containerization system
Loading...
Searching...
No Matches
macro.hpp File Reference

Simplified macros for common control flow patterns with optional logging. More...

#include "lib/log.hpp"
Include dependency graph for macro.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define return_if(condition, value, ...)
 
#define break_if(condition, ...)
 
#define continue_if(condition, ...)
 
#define log_if(condition, ...)
 

Detailed Description

Simplified macros for common control flow patterns with optional logging.

Author
Ruan Formigoni

This file provides a minimal set of preprocessor macros designed to reduce boilerplate code by combining conditional statements with actions like return, break, and continue. All macros support optional logging by including a format string and arguments after the action.

The logging level is determined by the prefix in the format string itself (D::, I::, W::, E::, C::) which is processed by the logger at compile time.

Definition in file macro.hpp.

Macro Definition Documentation

◆ break_if

#define break_if ( condition,
... )
Value:
if (condition) { \
__VA_OPT__(logger(__VA_ARGS__);) \
break; \
}
#define logger(fmt,...)
Compile-time log level dispatch macro with automatic location capture.
Definition log.hpp:682

Definition at line 65 of file macro.hpp.

◆ continue_if

#define continue_if ( condition,
... )
Value:
if (condition) { \
__VA_OPT__(logger(__VA_ARGS__);) \
continue; \
}

Definition at line 87 of file macro.hpp.

◆ log_if

#define log_if ( condition,
... )
Value:
if (condition) { \
logger(__VA_ARGS__); \
}

Definition at line 115 of file macro.hpp.

◆ return_if

#define return_if ( condition,
value,
... )
Value:
if (condition) { \
__VA_OPT__(logger(__VA_ARGS__);) \
return value; \
}

Definition at line 43 of file macro.hpp.