summaryrefslogtreecommitdiffhomepage
path: root/compat/debug.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-11-25 21:19:43 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-11-25 21:20:12 +0100
commit6edd4cb9eaca78a5c4254265f27602e7055d7e44 (patch)
treeca700ddbb03b44a1b012a8a8ef186a3382100087 /compat/debug.hpp
parent7409d8ddd39944c4e68ebd50c732ee9a9a886583 (diff)
a
Diffstat (limited to 'compat/debug.hpp')
-rw-r--r--compat/debug.hpp39
1 files changed, 29 insertions, 10 deletions
diff --git a/compat/debug.hpp b/compat/debug.hpp
index 0009ce52..56db4b0f 100644
--- a/compat/debug.hpp
+++ b/compat/debug.hpp
@@ -1,31 +1,50 @@
#pragma once
#include <Corrade/Utility/Debug.h>
-#include <Corrade/Utility/Move.h>
#include <Corrade/Containers/Containers.h>
+#include <concepts>
+
+namespace floormat {
+
+template<typename T>
+concept DebugPrintable = requires(Debug& dbg, const T& value) {
+ { dbg << value } -> std::convertible_to<Debug&>;
+};
+
+} // namespace floormat
namespace floormat::detail::corrade_debug {
-struct ErrorString final { int value; };
+// ***** colon *****
+struct Colon {};
+Debug& operator<<(Debug& dbg, Colon box);
+
+// ***** error string *****
+struct ErrorString { int value; };
Debug& operator<<(Debug& dbg, ErrorString box);
-template<typename T> struct Quoted final { const T& value; };
-Debug::Flags debug1(Debug& dbg, char c);
-Debug& debug2(Debug& dbg, Debug::Flags flags, char c);
+// ***** quoted *****
+template<typename T> struct Quoted { const T& value; };
+Debug::Flags quoted_begin(Debug& dbg, char c);
+Debug& quoted_end(Debug& dbg, Debug::Flags flags, char c);
template<typename T> Debug& operator<<(Debug& dbg, Quoted<T> box)
{
- Debug::Flags flags = debug1(dbg, '\'');
+ Debug::Flags flags = quoted_begin(dbg, '\'');
dbg << box.value;
- return debug2(dbg, flags, '\'');
+ return quoted_end(dbg, flags, '\'');
}
-extern template struct Quoted<StringView>;
-
} // namespace floormat::detail::corrade_debug
+// ***** api *****
+
+// ***** functions *****
+
namespace floormat {
+floormat::detail::corrade_debug::Colon colon();
floormat::detail::corrade_debug::ErrorString error_string(int error);
-template<typename T> floormat::detail::corrade_debug::Quoted<T> quoted(const T& value) { return { value }; }
+floormat::detail::corrade_debug::ErrorString error_string();
+template<DebugPrintable T> floormat::detail::corrade_debug::Quoted<T> quoted(const T& value) { return { value }; }
} // namespace floormat