FuncDoodle
Loading...
Searching...
No Matches
MacroUtils.h File Reference

Logging system, assertion macros, platform utilities, and build/config macros. More...

#include <algorithm>
#include <filesystem>
#include <print>
#include <string>
#include <vector>
#include "UI/Gui.h"

Go to the source code of this file.

Macros

#define FUNC_FORMAT_AVAILABLE   0
 Indicates whether std::format support is available.
#define FUNC_AOV(x)
 Stands for "Assert Or Verify.".
#define FUNC_AOV_EX(x, str)
 Stands for "Assert Or Verify Ex.".
#define FUNC_DASS(x)
 Stands for "Debug Assert".
#define PUSH_LOG(prefix, ...)
 Internal utility macro for pushing a string to s_Logs.
#define FUNC_DBG(...)
 Debug log, only present in debug builds.
#define FUNC_INF(...)
 Info log.
#define FUNC_WARN(...)
 Warning log.
#define FUNC_GRAY(...)
 Note log.
#define FUNC_ERR(...)
 A non-fatal, recoverable from error.
#define FUNC_FATAL(...)
 Same as FUNC_ERR, but exits directly after logging.

Functions

ImGuiCol InvertedImCol (uint8_t r, uint8_t g, uint8_t b)
void OpenFileExplorer (const std::filesystem::path &path)

Variables

std::vector< std::string > s_Logs

Detailed Description

Logging system, assertion macros, platform utilities, and build/config macros.

This header defines a collection of global utilities used across FuncDoodle, including:

  • Logging system (FUNC_DBG, FUNC_INF, FUNC_WARN, FUNC_ERR, FUNC_FATAL)
  • Assertion/verification macros (FUNC_AOV, FUNC_AOV_EX, FUNC_DASS)
  • Conditional compile-time utilities for C++20 std::format support
  • Platform-specific helpers (file explorer opening, string comparisons)
  • Global log storage (s_Logs)
  • Versioning macros (FUNCVER, FDPVERMAJOR, FDPVERMINOR)
  • Utility macros (e.g., color inversion helpers)
Warning
This file defines macros with side effects (logging, exiting, memory allocation).
s_Logs stores raw pointers and requires external cleanup.
Note
Many macros behave differently depending on DEBUG / NDEBUG builds.

Macro Definition Documentation

◆ FUNC_AOV

#define FUNC_AOV ( x)
Value:
do { \
if (!(x)) { \
std::println("ASSERTION FAILED(DEBUG) at line {} in file {}", \
__LINE__, __FILE__); \
} \
} while (0)

Stands for "Assert Or Verify.".

Behavior depends on build configuration:

  • DEBUG: assertion-style logging
  • NDEBUG: verification-style logging

◆ FUNC_AOV_EX

#define FUNC_AOV_EX ( x,
str )
Value:
do { \
if (!(x)) { \
std::println("VERIFICATION FAILED: "); \
FUNC_INF(str); \
} \
} while (0)

Stands for "Assert Or Verify Ex.".

Note
The difference between FUNC_AOV and FUNC_AOV_EX is that FUNC_AOV_EX allows you to provide a message

◆ FUNC_DASS

#define FUNC_DASS ( x)
Value:
do { \
if (!(x)) { \
std::println("STRIPPED ASSERTION FAILED at line {} in file {}", \
__LINE__, __FILE__); \
} \
} while (0)

Stands for "Debug Assert".

Only present in DEBUG builds. Has no effect in release builds.

◆ FUNC_DBG

#define FUNC_DBG ( ...)
Value:
do { \
std::println("\033[36m[Debug]: {}\033[0m", FUNC_FMT(__VA_ARGS__)); \
PUSH_LOG("[Debug]: ", __VA_ARGS__); \
} while (0)

Debug log, only present in debug builds.

◆ FUNC_ERR

#define FUNC_ERR ( ...)
Value:
do { \
std::println("\033[1;35m[Error]: {}\033[0m", FUNC_FMT(__VA_ARGS__)); \
PUSH_LOG("[Error]: ", __VA_ARGS__); \
} while (0)

A non-fatal, recoverable from error.

◆ FUNC_FATAL

#define FUNC_FATAL ( ...)
Value:
do { \
std::println("\033[1;31m[FATAL]: {}\033[0m", FUNC_FMT(__VA_ARGS__)); \
PUSH_LOG("[FATAL]: ", __VA_ARGS__); \
std::exit(-1); \
} while (0)

Same as FUNC_ERR, but exits directly after logging.

◆ FUNC_FORMAT_AVAILABLE

#define FUNC_FORMAT_AVAILABLE   0

Indicates whether std::format support is available.

◆ FUNC_GRAY

#define FUNC_GRAY ( ...)
Value:
do { \
std::println("\033[90m[Note]: {}\033[0m", FUNC_FMT(__VA_ARGS__)); \
PUSH_LOG("[Note]: ", __VA_ARGS__); \
} while (0)

Note log.

◆ FUNC_INF

#define FUNC_INF ( ...)
Value:
do { \
std::println("\033[34m[Info]: {}\033[0m", FUNC_FMT(__VA_ARGS__)); \
PUSH_LOG("[Info]: ", __VA_ARGS__); \
} while (0)

Info log.

◆ FUNC_WARN

#define FUNC_WARN ( ...)
Value:
do { \
std::println("\033[33m[Warn]: {}\033[0m", FUNC_FMT(__VA_ARGS__)); \
PUSH_LOG("[Warn]: ", __VA_ARGS__); \
} while (0)

Warning log.

◆ PUSH_LOG

#define PUSH_LOG ( prefix,
... )
Value:
do { \
s_Logs.emplace_back(std::string(prefix) + FUNC_FMT(__VA_ARGS__)); \
} while (0)
std::vector< std::string > s_Logs
Definition MacroUtils.cc:4

Internal utility macro for pushing a string to s_Logs.

Function Documentation

◆ InvertedImCol()

ImGuiCol InvertedImCol ( uint8_t r,
uint8_t g,
uint8_t b )
inline

◆ OpenFileExplorer()

void OpenFileExplorer ( const std::filesystem::path & path)
inline

Variable Documentation

◆ s_Logs

std::vector<std::string> s_Logs
extern

Global log storage.

Stores log messages produced by logging macros.