19 #if !defined(NX_KIT_API) 31 NX_KIT_API
char pathSeparator();
33 NX_KIT_API
size_t commonPrefixSize(
const std::string& s1,
const std::string& s2);
39 NX_KIT_API
const char* relativeSrcFilename(
const char* file);
41 NX_KIT_API std::string fileBaseNameWithoutExt(
const char* file);
47 #if defined(NX_PRINT_TO_QDEBUG) 48 #define NX_DEBUG_STREAM qDebug().nospace().noquote() 50 static inline QDebug operator<<(QDebug d,
const std::string& s)
52 return d << QString::fromStdString(s);
56 #if !defined(NX_DEBUG_INI) 58 #define NX_DEBUG_INI ini(). 61 #if !defined(NX_DEBUG_ENABLE_OUTPUT) 63 #define NX_DEBUG_ENABLE_OUTPUT NX_DEBUG_INI enableOutput 66 #if !defined(NX_PRINT_PREFIX) 68 #define NX_PRINT_PREFIX nx::kit::debug::detail::printPrefix(__FILE__) 71 #if !defined(NX_DEBUG_STREAM) 73 #define NX_DEBUG_STREAM *nx::kit::debug::stream() 76 #if !defined(NX_DEBUG_ENDL) 78 #define NX_DEBUG_ENDL << std::endl 85 NX_KIT_API std::ostream*& stream();
87 #if !defined(NX_PRINT) 94 ( []() { struct Endl { ~Endl() { NX_DEBUG_STREAM NX_DEBUG_ENDL; } }; \ 95 return std::make_shared<Endl>(); }() ) , \ 96 NX_DEBUG_STREAM << NX_PRINT_PREFIX 103 if (!(NX_DEBUG_ENABLE_OUTPUT)) {} else NX_PRINT 115 #define NX_KIT_ASSERT(...) \ 116 NX_KIT_DEBUG_DETAIL_MSVC_EXPAND(NX_KIT_DEBUG_DETAIL_GET_3RD_ARG( \ 117 __VA_ARGS__, NX_KIT_DEBUG_DETAIL_ASSERT2, NX_KIT_DEBUG_DETAIL_ASSERT1, \ 118 args_required)(__VA_ARGS__)) 127 NX_PRINT << "####### LL line " << __LINE__ \ 128 << NX_KIT_DEBUG_DETAIL_THREAD_ID() \ 129 << ", file " << nx::kit::debug::relativeSrcFilename(__FILE__); 134 #define NX_PRINT_VALUE(VALUE) \ 135 NX_PRINT << "####### " #VALUE ": " << nx::kit::utils::toString((VALUE)) 140 #define NX_PRINT_HEX_DUMP(CAPTION, BYTES, SIZE) \ 141 nx::kit::debug::detail::printHexDump( \ 142 NX_KIT_DEBUG_DETAIL_PRINT_FUNC, (CAPTION), (const char*) (BYTES), (int) (SIZE)) 147 #if !defined(NX_DEBUG_ENABLE_TIME) 149 #define NX_DEBUG_ENABLE_TIME NX_DEBUG_INI enableTime 155 #define NX_TIME_BEGIN(TAG) \ 156 nx::kit::debug::detail::Timer nxTimer_##TAG( \ 157 (NX_DEBUG_ENABLE_TIME), NX_KIT_DEBUG_DETAIL_PRINT_FUNC, #TAG) 163 #define NX_TIME_MARK(TAG, MARK) do \ 165 if (NX_DEBUG_ENABLE_TIME) \ 166 nxTimer_##TAG.mark((MARK)); \ 172 #define NX_TIME_END(TAG) do \ 174 if (NX_DEBUG_ENABLE_TIME) \ 175 nxTimer_##TAG.finish(); \ 181 #if !defined(NX_DEBUG_ENABLE_FPS) 183 #define NX_DEBUG_ENABLE_FPS NX_DEBUG_INI enableFps 190 #define NX_FPS(TAG, ...) do \ 192 if (NX_KIT_DEBUG_DETAIL_CONCAT(NX_DEBUG_ENABLE_FPS, TAG)) \ 194 static nx::kit::debug::detail::Fps fps( \ 195 NX_KIT_DEBUG_DETAIL_PRINT_FUNC, #TAG); \ 196 fps.mark(__VA_ARGS__); \ 207 #define NX_KIT_DEBUG_DETAIL_MSVC_EXPAND(ARG) ARG 210 #define NX_KIT_DEBUG_DETAIL_GET_3RD_ARG(ARG1, ARG2, ARG3, ...) ARG3 212 #define NX_KIT_DEBUG_DETAIL_ASSERT1(CONDITION) \ 213 NX_KIT_DEBUG_DETAIL_ASSERT(CONDITION, "") 215 #define NX_KIT_DEBUG_DETAIL_ASSERT2(CONDITION, MESSAGE) \ 216 NX_KIT_DEBUG_DETAIL_ASSERT(CONDITION, MESSAGE) 218 #define NX_KIT_DEBUG_DETAIL_ASSERT(CONDITION, MESSAGE) do \ 222 nx::kit::debug::detail::assertionFailed( \ 223 NX_KIT_DEBUG_DETAIL_PRINT_FUNC, #CONDITION, (MESSAGE), __FILE__, __LINE__); \ 227 #define NX_KIT_DEBUG_DETAIL_CONCAT(X, Y) NX_KIT_DEBUG_DETAIL_CONCAT2(X, Y) 228 #define NX_KIT_DEBUG_DETAIL_CONCAT2(X, Y) X##Y 232 typedef std::function<void(const char*)> PrintFunc;
234 #define NX_KIT_DEBUG_DETAIL_PRINT_FUNC [&](const char* message) { NX_PRINT << message; } 237 NX_KIT_API std::string printPrefix(
const char* file);
239 NX_KIT_API
void assertionFailed(
240 PrintFunc printFunc,
const char* conditionStr,
const std::string& message,
241 const char* file,
int line);
246 Timer(
bool enabled, PrintFunc printFunc,
const char* tag);
248 void mark(
const char* markStr);
259 Fps(PrintFunc printFunc,
const char* tag);
261 void mark(
const char* markStr =
nullptr);
268 NX_KIT_API
void printHexDump(
269 PrintFunc printFunc,
const char* caption,
const char* bytes,
int size);
277 #if defined(__linux__) 279 #define NX_KIT_DEBUG_DETAIL_THREAD_ID() \ 280 nx::kit::utils::format(", thread %llx", (long long) pthread_self()) 281 #elif defined(QT_CORE_LIB) 282 #include <QtCore/QThread> 283 #define NX_KIT_DEBUG_DETAIL_THREAD_ID() \ 284 nx::kit::utils::format(", thread %llx", (long long) QThread::currentThreadId()) 287 #define NX_KIT_DEBUG_DETAIL_THREAD_ID() ""
Definition: debug.cpp:286
Definition: debug.cpp:211