summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--compat/debug.cpp29
-rw-r--r--compat/debug.hpp27
-rw-r--r--src/dijkstra.cpp1
-rw-r--r--wall-tileset-tool/main.cpp4
4 files changed, 43 insertions, 18 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
diff --git a/src/dijkstra.cpp b/src/dijkstra.cpp
index 92bfeffb..c5efbd34 100644
--- a/src/dijkstra.cpp
+++ b/src/dijkstra.cpp
@@ -1,5 +1,6 @@
#include "path-search.hpp"
#include "compat/format.hpp"
+#include "compat/debug.hpp"
#include "object.hpp"
#include "point.hpp"
#include <cstdio>
diff --git a/wall-tileset-tool/main.cpp b/wall-tileset-tool/main.cpp
index 63277808..20e5b23a 100644
--- a/wall-tileset-tool/main.cpp
+++ b/wall-tileset-tool/main.cpp
@@ -169,8 +169,8 @@ Triple<options, Arguments, bool> parse_cmdline(int argc, const char* const* argv
if (opts.output_dir.isEmpty())
opts.output_dir = opts.input_dir;
- DBG_nospace << "input-dir '" << opts.input_dir << "'";
- DBG_nospace << "output-dir '" << opts.output_dir << "'";
+ DBG << "input-dir" << quoted(opts.input_dir);
+ DBG << "output-dir" << quoted(opts.output_dir);
if (!Path::exists(opts.input_file))
Error{Error::Flag::NoSpace} << "fatal: input file '" << opts.input_file << "' doesn't exist";