DYTSrouce/src/config.h
2025-01-04 12:12:51 +08:00

44 lines
1017 B
C++

#pragma once
#include <cmath>
#include <limits>
extern const char* CONFIG_PATH;
#define Q_REGISTER_METATYPE(T) \
static struct T##MetaTypeRegister { \
T##MetaTypeRegister() { \
qRegisterMetaType<T>(); \
} \
} g_##T##MetaTypeRegister; \
#if defined(_MSC_VER)
#define FORCE_INLINE __forceinline
#elif defined(__GNUC__) || defined(__clang__)
#define FORCE_INLINE inline __attribute__((always_inline))
#else
#define FORCE_INLINE inline
#endif
#define dyt_check(condition) \
do { \
if (!(condition)) { \
LOG_ERROR("Check failed: {}", #condition); \
abort(); \
} \
} while (0)
FORCE_INLINE bool IsValid(double value) {
constexpr double epsilon = std::numeric_limits<double>::epsilon();
return std::abs(value) > epsilon;
}
FORCE_INLINE bool IsDecimalValid(double value) {
double intPart;
double fractionalPart = std::modf(value, &intPart);
return IsValid(fractionalPart);
}