24#ifndef LIBHELPER_MACROS_HPP
25#define LIBHELPER_MACROS_HPP
40inline constexpr int YES = 1;
43inline constexpr int NO = 0;
46enum sizeCastTypes {
B =
static_cast<int>(
'B'),
KB =
static_cast<int>(
'K'),
MB =
static_cast<int>(
'M'),
GB =
static_cast<int>(
'G') };
71template <
typename Func,
typename Ret,
typename... Args>
90template <
typename T>
struct DeepConst<T *> {
91 using type =
const T *;
124 using type =
const char *;
128template <>
struct ConstIfCharPointer<const char *> {
129 using type =
const char *;
148#define HELPER "libhelper"
159#define B(x) (static_cast<uint64_t(x)> * 8)
170#define KB(x) (static_cast<uint64_t>(x) * 1024)
181#define MB(x) (KB(x) * 1024)
192#define GB(x) (MB(x) * 1024)
203#define TO_KB(x) (x / 1024)
214#define TO_MB(x) (TO_KB(x) / 1024)
225#define TO_GB(x) (TO_MB(x) / 1024)
232#define STYLE_RESET "\033[0m"
233#define BOLD "\033[1m"
234#define FAINT "\033[2m"
235#define ITALIC "\033[3m"
236#define UNDERLINE "\033[4m"
237#define BLINC "\033[5m"
238#define FAST_BLINC "\033[6m"
239#define STRIKE_THROUGHT "\033[9m"
240#define NO_UNDERLINE "\033[24m"
241#define NO_BLINC "\033[25m"
251#define BLACK "\033[30m"
252#define RED "\033[31m"
253#define GREEN "\033[32m"
254#define YELLOW "\033[33m"
255#define BLUE "\033[34m"
256#define MAGENTA "\033[35m"
257#define CYAN "\033[36m"
258#define WHITE "\033[37m"
261#define BRIGHT_BLACK "\033[90m"
262#define BRIGHT_RED "\033[91m"
263#define BRIGHT_GREEN "\033[92m"
264#define BRIGHT_YELLOW "\033[93m"
265#define BRIGHT_BLUE "\033[94m"
266#define BRIGHT_MAGENTA "\033[95m"
267#define BRIGHT_CYAN "\033[96m"
268#define BRIGHT_WHITE "\033[97m"
271#define BG_BLACK "\033[40m"
272#define BG_RED "\033[41m"
273#define BG_GREEN "\033[42m"
274#define BG_YELLOW "\033[43m"
275#define BG_BLUE "\033[44m"
276#define BG_MAGENTA "\033[45m"
277#define BG_CYAN "\033[46m"
278#define BG_WHITE "\033[47m"
281#ifndef HELPER_NO_C_TYPE_HANDLERS
285 fprintf(stderr, "%s%sCRITICAL ERROR%s: %s\nAborting...\n", BOLD, RED, STYLE_RESET, msg); \
290#define ERROR(msg, code) \
292 fprintf(stderr, "%s%sERROR%s: %s", BOLD, RED, STYLE_RESET, msg); \
297#define WARNING(msg) fprintf(stderr, "%s%sWARNING%s: %s", BOLD, YELLOW, STYLE_RESET, msg);
300#define INFO(msg) fprintf(stdout, "%s%sINFO%s: %s", BOLD, GREEN, STYLE_RESET, msg);
313#define MKVERSION(name) \
316 "%s %s-%s [%s %s]\nBuild type: %s\nCMake version: %s\nCompiler version: " \
317 "%s\nCompiler flags: %s", \
318 name, BUILD_VERSION, COMMIT_ID, BUILD_DATE, BUILD_TIME, BUILD_TYPE, BUILD_CMAKE_VERSION, BUILD_COMPILER_VERSION, \
320 return std::string(vinfo)
Checks whether the input type provides a c_str() member function.
Definition definations.hpp:60
Checks whether the input is invocable and returns requested type.
Definition definations.hpp:72
constexpr mode_t DEFAULT_FILE_PERMS
Default file permissions.
Definition definations.hpp:31
#define MB(x)
Take x megabyte as bytes.
Definition definations.hpp:181
constexpr int YES
Alternative of true.
Definition definations.hpp:40
#define KB(x)
Take x kilobyte as bytes.
Definition definations.hpp:170
constexpr mode_t DEFAULT_EXTENDED_FILE_PERMS
Extended file permissions (using by executables etc).
Definition definations.hpp:34
#define B(x)
Take x byte as bits.
Definition definations.hpp:159
constexpr int NO
Alternative of false.
Definition definations.hpp:43
constexpr mode_t DEFAULT_DIR_PERMS
Default directory permissions.
Definition definations.hpp:37
sizeCastTypes
Short names used in dimension type conversions.
Definition definations.hpp:46
#define GB(x)
Take x gigabyte as bytes.
Definition definations.hpp:192
Main namespace of libhelper library.
Definition capsule.hpp:27
Add the const qualifier if input type is char*.
Definition definations.hpp:117
ConstIfCharPointer< T >::type ConstIfCharPointer_t
Shorcut of ConstIfCharPointer<T>::type.
Definition definations.hpp:143
Add the const qualifier to the input type.
Definition definations.hpp:85