diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-25 19:31:46 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-25 19:31:46 +0100 |
commit | 7409d8ddd39944c4e68ebd50c732ee9a9a886583 (patch) | |
tree | 81d0c3beb6b1c336db19016eeaf2ec648cd21100 /compat | |
parent | 8f3c494e3d89cd146f4e032ae94ce5456328c87e (diff) |
a
Diffstat (limited to 'compat')
-rw-r--r-- | compat/debug.cpp | 29 | ||||
-rw-r--r-- | compat/debug.hpp | 27 |
2 files changed, 40 insertions, 16 deletions
diff --git a/compat/debug.cpp b/compat/debug.cpp index 0a342f8b..e3efaf5c 100644 --- a/compat/debug.cpp +++ b/compat/debug.cpp @@ -1,24 +1,43 @@ -#define FM_NO_CORRADE_DEBUG_EXTERN_TEMPLATE_QUOTED #include "debug.hpp" +#include "compat/strerror.hpp" namespace floormat::detail::corrade_debug { +Debug& operator<<(Debug& dbg, ErrorString box) +{ + auto flags = dbg.flags(); + char buf[256]; + dbg.setFlags(flags | Debug::Flag::NoSpace); + dbg << ": "; + dbg << get_error_string(buf, box.value); + dbg.setFlags(flags); + return dbg; +} + template struct Quoted<StringView>; -Debug::Flags debug1(Debug& dbg) +Debug::Flags debug1(Debug& dbg, char c) { auto flags = dbg.flags(); dbg << ""; dbg.setFlags(flags | Debug::Flag::NoSpace); - dbg << "'"; + char buf[2] { c, '\0' }; + dbg << buf; return flags; } -Debug& debug2(Debug& dbg, Debug::Flags flags) +Debug& debug2(Debug& dbg, Debug::Flags flags, char c) { - dbg << "'"; + char buf[2] { c, '\0' }; + dbg << buf; dbg.setFlags(flags); return dbg; } } // namespace floormat::detail::corrade_debug + +namespace floormat { + +floormat::detail::corrade_debug::ErrorString error_string(int error) { return { error }; } + +} // namespace floormat diff --git a/compat/debug.hpp b/compat/debug.hpp index 1d8e4676..0009ce52 100644 --- a/compat/debug.hpp +++ b/compat/debug.hpp @@ -1,26 +1,31 @@ #pragma once #include <Corrade/Utility/Debug.h> #include <Corrade/Utility/Move.h> +#include <Corrade/Containers/Containers.h> namespace floormat::detail::corrade_debug { -template<typename T> struct Quoted final { const T& value; }; - -#ifndef FM_NO_CORRADE_DEBUG_EXTERN_TEMPLATE_QUOTED -extern template struct Quoted<StringView>; -#endif +struct ErrorString final { int value; }; +Debug& operator<<(Debug& dbg, ErrorString box); -Debug::Flags debug1(Debug& dbg); -Debug& debug2(Debug& dbg, Debug::Flags flags); +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); -template<typename T> -Debug& operator<<(Debug& dbg, detail::corrade_debug::Quoted<T> box) +template<typename T> Debug& operator<<(Debug& dbg, Quoted<T> box) { - Debug::Flags flags = detail::corrade_debug::debug1(dbg); + Debug::Flags flags = debug1(dbg, '\''); dbg << box.value; - return debug2(dbg, flags); + return debug2(dbg, flags, '\''); } +extern template struct Quoted<StringView>; + } // namespace floormat::detail::corrade_debug +namespace floormat { + +floormat::detail::corrade_debug::ErrorString error_string(int error); template<typename T> floormat::detail::corrade_debug::Quoted<T> quoted(const T& value) { return { value }; } + +} // namespace floormat |