refactor(framework): move debug utils to their own namespace

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2026-01-15 20:16:57 -05:00
parent b6df1547e2
commit a51bd5fc33
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C
4 changed files with 13 additions and 4 deletions

View File

@ -1,5 +1,7 @@
#include "include/public/toon_boom/ext/util.hpp"
namespace util::debug {
std::ostream devnull(new NullBuffer());
std::ostream& out = TB_EXT_FRAMEWORK_DEBUG ? std::cout : devnull;
}

View File

@ -1,6 +1,7 @@
#pragma once
#include "../PLUG_Services.hpp"
#include "../toon_boom_layout.hpp"
#include "./util.hpp"
#include "QtXml/qdom.h"
#include <QtCore/QObject>
#include <QtCore/QPointer>
@ -9,6 +10,7 @@
#include <iostream>
#include <type_traits>
using namespace util;
template <typename T>
concept isQWidget = std::is_base_of<QWidget, T>::value;
@ -100,7 +102,7 @@ protected:
QObject::connect(
parent, &QObject::destroyed, m_widget.data(),
[this]() {
std::cout << "[parent destroyed] Unparenting widget to prevent "
debug::out << "[parent destroyed] Unparenting widget to prevent "
"cross-DLL heap deletion"
<< std::endl;
if (m_widget) {
@ -123,10 +125,10 @@ protected:
if (am) {
QList<QString> ids;
am->loadToolbars(element, ids);
std::cout << "Registered toolbar with AC_Manager. IDs loaded: "
debug::out << "Registered toolbar with AC_Manager. IDs loaded: "
<< ids.size() << std::endl;
for (const auto &id : ids) {
std::cout << " - " << id.toStdString() << std::endl;
debug::out << " - " << id.toStdString() << std::endl;
}
} else {
std::cerr << "Could not get AC_Manager!" << std::endl;

View File

@ -7,6 +7,8 @@
#if !defined(TB_EXT_FRAMEWORK_DEBUG)
#define TB_EXT_FRAMEWORK_DEBUG 0
#endif
namespace util::debug {
struct NullBuffer : std::streambuf {
int overflow(int c) { return c; }
};
@ -16,3 +18,4 @@ std::string addrToHex(void *addr);
std::string constAddrToHex(const void *addr);
extern std::ostream &out;
} // namespace util::debug

View File

@ -1,9 +1,11 @@
#include "include/public/toon_boom/ext/util.hpp"
namespace util::debug {
std::string addrToHex(void* addr) {
return std::format("0x{:010X}", reinterpret_cast<uintptr_t>(addr));
}
std::string constAddrToHex(const void* addr) {
return std::format("0x{:010X}", reinterpret_cast<const uintptr_t>(addr));
}
}
} // namespace util::debug