summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--compat/debug.cpp24
-rw-r--r--compat/debug.hpp26
-rw-r--r--wall-tileset-tool/main.cpp9
3 files changed, 55 insertions, 4 deletions
diff --git a/compat/debug.cpp b/compat/debug.cpp
new file mode 100644
index 00000000..0a342f8b
--- /dev/null
+++ b/compat/debug.cpp
@@ -0,0 +1,24 @@
+#define FM_NO_CORRADE_DEBUG_EXTERN_TEMPLATE_QUOTED
+#include "debug.hpp"
+
+namespace floormat::detail::corrade_debug {
+
+template struct Quoted<StringView>;
+
+Debug::Flags debug1(Debug& dbg)
+{
+ auto flags = dbg.flags();
+ dbg << "";
+ dbg.setFlags(flags | Debug::Flag::NoSpace);
+ dbg << "'";
+ return flags;
+}
+
+Debug& debug2(Debug& dbg, Debug::Flags flags)
+{
+ dbg << "'";
+ dbg.setFlags(flags);
+ return dbg;
+}
+
+} // namespace floormat::detail::corrade_debug
diff --git a/compat/debug.hpp b/compat/debug.hpp
new file mode 100644
index 00000000..1d8e4676
--- /dev/null
+++ b/compat/debug.hpp
@@ -0,0 +1,26 @@
+#pragma once
+#include <Corrade/Utility/Debug.h>
+#include <Corrade/Utility/Move.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
+
+Debug::Flags debug1(Debug& dbg);
+Debug& debug2(Debug& dbg, Debug::Flags flags);
+
+template<typename T>
+Debug& operator<<(Debug& dbg, detail::corrade_debug::Quoted<T> box)
+{
+ Debug::Flags flags = detail::corrade_debug::debug1(dbg);
+ dbg << box.value;
+ return debug2(dbg, flags);
+}
+
+} // namespace floormat::detail::corrade_debug
+
+template<typename T> floormat::detail::corrade_debug::Quoted<T> quoted(const T& value) { return { value }; }
diff --git a/wall-tileset-tool/main.cpp b/wall-tileset-tool/main.cpp
index aac56490..63277808 100644
--- a/wall-tileset-tool/main.cpp
+++ b/wall-tileset-tool/main.cpp
@@ -3,7 +3,8 @@
#include "compat/sysexits.hpp"
#include "compat/fix-argv0.hpp"
#include "compat/strerror.hpp"
-#include "compat/format.hpp"
+//#include "compat/format.hpp"
+#include "compat/debug.hpp"
#include "src/wall-atlas.hpp"
//#include "serialize/wall-atlas.hpp"
//#include "serialize/json-helper.hpp"
@@ -118,7 +119,7 @@ bool do_direction(state& st, size_t i)
bool do_input_file(state& st)
{
- DBG_nospace << "input-file '" << st.old_atlas.header.name << "'";
+ DBG << "input-file" << quoted(st.old_atlas.header.name);
fm_assert(!st.buffer.empty());
fm_assert(loader.check_atlas_name(st.old_atlas.header.name));
@@ -168,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_nospace << "input-dir '" << opts.input_dir << "'";
+ DBG_nospace << "output-dir '" << opts.output_dir << "'";
if (!Path::exists(opts.input_file))
Error{Error::Flag::NoSpace} << "fatal: input file '" << opts.input_file << "' doesn't exist";