18 #if !defined(NX_KIT_API) 30 NX_KIT_API
char pathSeparator();
32 NX_KIT_API
size_t commonPrefixSize(
const std::string& s1,
const std::string& s2);
38 NX_KIT_API
const char* relativeSrcFilename(
const char* file);
40 NX_KIT_API std::string fileBaseNameWithoutExt(
const char* file);
46 #if defined(NX_PRINT_TO_QDEBUG) 47 #define NX_DEBUG_STREAM qDebug().nospace().noquote() 49 static inline QDebug operator<<(QDebug d,
const std::string& s)
51 return d << QString::fromStdString(s);
55 #if !defined(NX_DEBUG_INI) 57 #define NX_DEBUG_INI ini(). 60 #if !defined(NX_DEBUG_ENABLE_OUTPUT) 62 #define NX_DEBUG_ENABLE_OUTPUT NX_DEBUG_INI enableOutput 65 #if !defined(NX_PRINT_PREFIX) 67 #define NX_PRINT_PREFIX ::nx::kit::debug::detail::printPrefix(__FILE__) 70 #if !defined(NX_DEBUG_STREAM) 72 #define NX_DEBUG_STREAM *::nx::kit::debug::stream() 75 #if !defined(NX_DEBUG_ENDL) 77 #define NX_DEBUG_ENDL << std::endl 84 NX_KIT_API std::ostream*& stream();
86 #if !defined(NX_PRINT) 93 ( []() { struct Endl { ~Endl() { NX_DEBUG_STREAM NX_DEBUG_ENDL; } }; \ 94 return std::make_shared<Endl>(); }() ) , \ 95 NX_DEBUG_STREAM << NX_PRINT_PREFIX 103 int NX_KIT_DEBUG_DETAIL_CONCAT(nxOutput_, __line__) = 0; \ 104 NX_KIT_DEBUG_DETAIL_CONCAT(nxOutput_, __line__) != 1 && (NX_DEBUG_ENABLE_OUTPUT); \ 105 ++NX_KIT_DEBUG_DETAIL_CONCAT(nxOutput_, __line__) \ 126 #define NX_KIT_ASSERT( ...) \ 127 NX_KIT_DEBUG_DETAIL_MSVC_EXPAND(NX_KIT_DEBUG_DETAIL_GET_3RD_ARG( \ 128 __VA_ARGS__, NX_KIT_DEBUG_DETAIL_ASSERT2, NX_KIT_DEBUG_DETAIL_ASSERT1, \ 129 args_required)(__VA_ARGS__)) 138 NX_PRINT << "####### LL line " << __LINE__ \ 139 << NX_KIT_DEBUG_DETAIL_THREAD_ID() \ 140 << ", file " << ::nx::kit::debug::relativeSrcFilename(__FILE__); 145 #define NX_PRINT_VALUE(VALUE) \ 146 NX_PRINT << "####### " #VALUE ": " << ::nx::kit::utils::toString((VALUE)) 151 #define NX_PRINT_HEX_DUMP(CAPTION, BYTES, SIZE) \ 152 ::nx::kit::debug::detail::printHexDump( \ 153 NX_KIT_DEBUG_DETAIL_PRINT_FUNC, (CAPTION), (const char*) (BYTES), (int) (SIZE)) 158 #if !defined(NX_DEBUG_ENABLE_TIME) 160 #define NX_DEBUG_ENABLE_TIME NX_DEBUG_INI enableTime 166 #define NX_TIME_BEGIN(TAG) \ 167 ::nx::kit::debug::detail::Timer nxTimer_##TAG( \ 168 (NX_DEBUG_ENABLE_TIME), NX_KIT_DEBUG_DETAIL_PRINT_FUNC, #TAG) 174 #define NX_TIME_MARK(TAG, MARK) do \ 176 if (NX_DEBUG_ENABLE_TIME) \ 177 nxTimer_##TAG.mark((MARK)); \ 183 #define NX_TIME_END(TAG) do \ 185 if (NX_DEBUG_ENABLE_TIME) \ 186 nxTimer_##TAG.finish(); \ 192 #if !defined(NX_DEBUG_ENABLE_FPS) 194 #define NX_DEBUG_ENABLE_FPS NX_DEBUG_INI enableFps 201 #define NX_FPS(TAG, ...) do \ 203 if (NX_KIT_DEBUG_DETAIL_CONCAT(NX_DEBUG_ENABLE_FPS, TAG)) \ 205 static ::nx::kit::debug::detail::Fps fps( \ 206 NX_KIT_DEBUG_DETAIL_PRINT_FUNC, #TAG); \ 207 fps.mark(__VA_ARGS__); \ 216 typedef std::function<void(const char*)> PrintFunc;
218 #define NX_KIT_DEBUG_DETAIL_PRINT_FUNC ([&](const char* message) { NX_PRINT << message; }) 224 #define NX_KIT_DEBUG_DETAIL_MSVC_EXPAND(ARG) ARG 227 #define NX_KIT_DEBUG_DETAIL_GET_3RD_ARG(ARG1, ARG2, ARG3, ...) ARG3 229 #define NX_KIT_DEBUG_DETAIL_ASSERT1(CONDITION) \ 230 ::nx::kit::debug::detail::doAssert( \ 231 !!(CONDITION), NX_KIT_DEBUG_DETAIL_PRINT_FUNC, #CONDITION, "", __FILE__, __LINE__) 233 #define NX_KIT_DEBUG_DETAIL_ASSERT2(CONDITION, MESSAGE) \ 234 ::nx::kit::debug::detail::doAssert( \ 235 !!(CONDITION), NX_KIT_DEBUG_DETAIL_PRINT_FUNC, #CONDITION, MESSAGE, __FILE__, __LINE__) 237 NX_KIT_API
void assertionFailed(
238 PrintFunc printFunc,
const char* conditionStr,
const std::string& message,
239 const char* file,
int line);
241 inline bool doAssert(
242 bool condition, PrintFunc printFunc,
const char* conditionStr,
const std::string& message,
243 const char* file,
int line)
246 assertionFailed(printFunc, conditionStr, message, file, line);
250 #define NX_KIT_DEBUG_DETAIL_CONCAT(X, Y) NX_KIT_DEBUG_DETAIL_CONCAT2(X, Y) 251 #define NX_KIT_DEBUG_DETAIL_CONCAT2(X, Y) X##Y 254 NX_KIT_API std::string printPrefix(
const char* file);
259 Timer(
bool enabled, PrintFunc printFunc,
const char* tag);
261 void mark(
const char* markStr);
272 Fps(PrintFunc printFunc,
const char* tag);
274 void mark(
const char* markStr =
nullptr);
281 NX_KIT_API
void printHexDump(
282 PrintFunc printFunc,
const char* caption,
const char* bytes,
int size);
290 #if defined(__linux__) 292 #define NX_KIT_DEBUG_DETAIL_THREAD_ID() \ 293 ::nx::kit::utils::format(", thread %llx", (long long) pthread_self()) 294 #elif defined(QT_CORE_LIB) 295 #include <QtCore/QThread> 296 #define NX_KIT_DEBUG_DETAIL_THREAD_ID() \ 297 ::nx::kit::utils::format(", thread %llx", (long long) QThread::currentThreadId()) 300 #define NX_KIT_DEBUG_DETAIL_THREAD_ID() ""
Definition: debug.cpp:285
Definition: debug.cpp:210