20 #if !defined(NX_KIT_API) 32 NX_KIT_API
char pathSeparator();
34 NX_KIT_API
size_t commonPrefixSize(
const std::string& s1,
const std::string& s2);
40 NX_KIT_API
const char* relativeSrcFilename(
const char* file);
42 NX_KIT_API std::string fileBaseNameWithoutExt(
const char* file);
48 #if defined(NX_PRINT_TO_QDEBUG) 49 #define NX_DEBUG_STREAM qDebug().nospace().noquote() 51 static inline QDebug operator<<(QDebug d,
const std::string& s)
53 return d << QString::fromStdString(s);
57 #if !defined(NX_DEBUG_INI) 59 #define NX_DEBUG_INI ini(). 62 #if !defined(NX_DEBUG_ENABLE_OUTPUT) 64 #define NX_DEBUG_ENABLE_OUTPUT NX_DEBUG_INI enableOutput 67 #if !defined(NX_PRINT_PREFIX) 69 #define NX_PRINT_PREFIX ::nx::kit::debug::detail::printPrefix(__FILE__) 72 #if !defined(NX_DEBUG_STREAM) 74 #define NX_DEBUG_STREAM *::nx::kit::debug::stream() 77 #if !defined(NX_DEBUG_ENDL) 79 #define NX_DEBUG_ENDL << std::endl 86 NX_KIT_API std::ostream*& stream();
88 #if !defined(NX_PRINT) 95 ( []() { struct Endl { ~Endl() { NX_DEBUG_STREAM NX_DEBUG_ENDL; } }; \ 96 return std::make_shared<Endl>(); }() ) , \ 97 NX_DEBUG_STREAM << NX_PRINT_PREFIX 105 int NX_KIT_DEBUG_DETAIL_CONCAT(nxOutput_, __line__) = 0; \ 106 NX_KIT_DEBUG_DETAIL_CONCAT(nxOutput_, __line__) != 1 && (NX_DEBUG_ENABLE_OUTPUT); \ 107 ++NX_KIT_DEBUG_DETAIL_CONCAT(nxOutput_, __line__) \ 128 #define NX_KIT_ASSERT( ...) \ 129 NX_KIT_DEBUG_DETAIL_MSVC_EXPAND(NX_KIT_DEBUG_DETAIL_GET_3RD_ARG( \ 130 __VA_ARGS__, NX_KIT_DEBUG_DETAIL_ASSERT2, NX_KIT_DEBUG_DETAIL_ASSERT1, \ 131 args_required)(__VA_ARGS__)) 137 NX_KIT_API
void intentionallyCrash(
const char* message);
146 NX_PRINT << "####### LL line " + ::nx::kit::utils::toString(__LINE__) \ 147 + NX_KIT_DEBUG_DETAIL_THREAD_ID() \ 148 + ", file " + ::nx::kit::debug::relativeSrcFilename(__FILE__); 153 #define NX_PRINT_VALUE(VALUE) \ 154 NX_PRINT << "####### " #VALUE ": " + ::nx::kit::utils::toString(VALUE) 159 #define NX_PRINT_HEX_DUMP(CAPTION, BYTES, SIZE) \ 160 ::nx::kit::debug::detail::printHexDump( \ 161 NX_KIT_DEBUG_DETAIL_PRINT_FUNC, (CAPTION), (const char*) (BYTES), (int) (SIZE)) 166 NX_KIT_API std::string hexDumpLine(
const char* bytes,
int size,
int bytesPerLine = 0);
168 #if !defined(NX_DEBUG_SAVE_DIR) 170 #define NX_DEBUG_SAVE_DIR ::nx::kit::IniConfig::iniFilesDir() 176 #define NX_SAVE_STR(FILENAME, STR) \ 177 ::nx::kit::debug::detail::saveStr( \ 178 NX_KIT_DEBUG_DETAIL_PRINT_FUNC, (NX_DEBUG_SAVE_DIR), (FILENAME), #STR, (STR)) 183 #if !defined(NX_DEBUG_ENABLE_TIME) 185 #define NX_DEBUG_ENABLE_TIME NX_DEBUG_INI enableTime 191 #define NX_TIME_BEGIN(TAG) \ 192 ::nx::kit::debug::detail::Timer nxTimer_##TAG( \ 193 (NX_DEBUG_ENABLE_TIME), NX_KIT_DEBUG_DETAIL_PRINT_FUNC, #TAG) 199 #define NX_TIME_MARK(TAG, MARK) do \ 201 if (NX_DEBUG_ENABLE_TIME) \ 202 nxTimer_##TAG.mark((MARK)); \ 208 #define NX_TIME_END(TAG) do \ 210 if (NX_DEBUG_ENABLE_TIME) \ 211 nxTimer_##TAG.finish(); \ 217 #if !defined(NX_DEBUG_ENABLE_FPS) 219 #define NX_DEBUG_ENABLE_FPS NX_DEBUG_INI enableFps 226 #define NX_FPS(TAG, ...) do \ 228 if (NX_KIT_DEBUG_DETAIL_CONCAT(NX_DEBUG_ENABLE_FPS, TAG)) \ 230 static ::nx::kit::debug::detail::Fps fps( \ 231 NX_KIT_DEBUG_DETAIL_PRINT_FUNC, #TAG); \ 232 fps.mark(__VA_ARGS__); \ 241 typedef std::function<void(const char*)> PrintFunc;
243 #define NX_KIT_DEBUG_DETAIL_PRINT_FUNC ([&](const char* message) { NX_PRINT << message; }) 249 #define NX_KIT_DEBUG_DETAIL_MSVC_EXPAND(ARG) ARG 252 #define NX_KIT_DEBUG_DETAIL_GET_3RD_ARG(ARG1, ARG2, ARG3, ...) ARG3 254 #define NX_KIT_DEBUG_DETAIL_ASSERT1(CONDITION) \ 255 ::nx::kit::debug::detail::doAssert( \ 256 !!(CONDITION), NX_KIT_DEBUG_DETAIL_PRINT_FUNC, #CONDITION, "", __FILE__, __LINE__) 258 #define NX_KIT_DEBUG_DETAIL_ASSERT2(CONDITION, MESSAGE) \ 259 ::nx::kit::debug::detail::doAssert( \ 260 !!(CONDITION), NX_KIT_DEBUG_DETAIL_PRINT_FUNC, #CONDITION, MESSAGE, __FILE__, __LINE__) 262 NX_KIT_API
void assertionFailed(
263 PrintFunc printFunc,
const char* conditionStr,
const std::string& message,
264 const char* file,
int line);
266 inline bool doAssert(
267 bool condition, PrintFunc printFunc,
const char* conditionStr,
const std::string& message,
268 const char* file,
int line)
271 assertionFailed(printFunc, conditionStr, message, file, line);
275 #define NX_KIT_DEBUG_DETAIL_CONCAT(X, Y) NX_KIT_DEBUG_DETAIL_CONCAT2(X, Y) 276 #define NX_KIT_DEBUG_DETAIL_CONCAT2(X, Y) X##Y 279 NX_KIT_API std::string printPrefix(
const char* file);
284 Timer(
bool enabled, PrintFunc printFunc,
const char* tag);
286 void mark(
const char* markStr);
297 Fps(PrintFunc printFunc,
const char* tag);
299 void mark(
const char* markStr =
nullptr);
306 NX_KIT_API
void printHexDump(
307 PrintFunc printFunc,
const char* caption,
const char* bytes,
int size);
309 NX_KIT_API
void saveStr(
311 const char* originDir,
312 const char* filename,
313 const char* strCaption,
314 const std::string& str);
322 #if defined(__linux__) 324 #define NX_KIT_DEBUG_DETAIL_THREAD_ID() \ 325 ::nx::kit::utils::format(", thread %llx", (long long) pthread_self()) 326 #elif defined(QT_CORE_LIB) 327 #include <QtCore/QThread> 328 #define NX_KIT_DEBUG_DETAIL_THREAD_ID() \ 329 ::nx::kit::utils::format(", thread %llx", (long long) QThread::currentThreadId()) 332 #define NX_KIT_DEBUG_DETAIL_THREAD_ID() ""
Definition: debug.cpp:314
Definition: debug.cpp:239
Definition: apple_utils.h:6