summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-11-25 22:08:56 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-11-25 22:08:56 +0100
commit042f183002b88a1af7cf3c634277695dc7b43ac8 (patch)
tree03033aaa161f9350146efbc113e6e0c90e138306 /compat
parent6edd4cb9eaca78a5c4254265f27602e7055d7e44 (diff)
a
Diffstat (limited to 'compat')
-rw-r--r--compat/debug.cpp12
-rw-r--r--compat/debug.hpp14
2 files changed, 13 insertions, 13 deletions
diff --git a/compat/debug.cpp b/compat/debug.cpp
index a3c2ba25..0a77d298 100644
--- a/compat/debug.cpp
+++ b/compat/debug.cpp
@@ -8,11 +8,11 @@
namespace floormat::detail::corrade_debug {
-Debug& operator<<(Debug& dbg, Colon)
+Debug& operator<<(Debug& dbg, Colon box)
{
auto flags = dbg.flags();
dbg.setFlags(flags | Debug::Flag::NoSpace);
- dbg << ":";
+ dbg << StringView{&box.c, 1};
dbg.setFlags(flags);
return dbg;
}
@@ -33,15 +33,13 @@ Debug::Flags quoted_begin(Debug& dbg, char c)
auto flags = dbg.flags();
dbg << "";
dbg.setFlags(flags | Debug::Flag::NoSpace);
- char buf[2] { c, '\0' };
- dbg << buf;
+ dbg << StringView{&c, 1};
return flags;
}
Debug& quoted_end(Debug& dbg, Debug::Flags flags, char c)
{
- char buf[2] { c, '\0' };
- dbg << buf;
+ dbg << StringView{&c, 1};
dbg.setFlags(flags);
return dbg;
}
@@ -54,7 +52,7 @@ namespace floormat {
using namespace floormat::detail::corrade_debug;
-Colon colon() { return Colon{}; }
+Colon colon(char c) { return Colon{c}; }
ErrorString error_string(int error) { return { error }; }
ErrorString error_string() { return { errno }; }
diff --git a/compat/debug.hpp b/compat/debug.hpp
index 56db4b0f..4de2e5ea 100644
--- a/compat/debug.hpp
+++ b/compat/debug.hpp
@@ -15,7 +15,7 @@ concept DebugPrintable = requires(Debug& dbg, const T& value) {
namespace floormat::detail::corrade_debug {
// ***** colon *****
-struct Colon {};
+struct Colon { char c; };
Debug& operator<<(Debug& dbg, Colon box);
// ***** error string *****
@@ -23,15 +23,15 @@ struct ErrorString { int value; };
Debug& operator<<(Debug& dbg, ErrorString box);
// ***** quoted *****
-template<typename T> struct Quoted { const T& value; };
+template<typename T> struct Quoted { const T& value; char c; };
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 = quoted_begin(dbg, '\'');
+ Debug::Flags flags = quoted_begin(dbg, box.c);
dbg << box.value;
- return quoted_end(dbg, flags, '\'');
+ return quoted_end(dbg, flags, box.c);
}
} // namespace floormat::detail::corrade_debug
@@ -42,9 +42,11 @@ template<typename T> Debug& operator<<(Debug& dbg, Quoted<T> box)
namespace floormat {
-floormat::detail::corrade_debug::Colon colon();
+floormat::detail::corrade_debug::Colon colon(char c = ':');
floormat::detail::corrade_debug::ErrorString error_string(int error);
floormat::detail::corrade_debug::ErrorString error_string();
-template<DebugPrintable T> floormat::detail::corrade_debug::Quoted<T> quoted(const T& value) { return { value }; }
+
+template<DebugPrintable T> floormat::detail::corrade_debug::Quoted<T> quoted(const T& value, char c = '\'') { return { value, c }; }
+template<DebugPrintable T> floormat::detail::corrade_debug::Quoted<T> quoted2(const T& value) { return { value, '"' }; }
} // namespace floormat