diff options
author | Nao Pross <naopross@thearcway.org> | 2019-01-23 21:04:25 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2019-01-23 21:04:25 +0100 |
commit | 6ca79425af17c10f016545231b101f8ad8207ecd (patch) | |
tree | ea1ac3b4ee351ecd0e6b3705a4141d89abaf0903 | |
parent | Update job interface to allow safe ownership delegation (diff) | |
download | flatland-6ca79425af17c10f016545231b101f8ad8207ecd.tar.gz flatland-6ca79425af17c10f016545231b101f8ad8207ecd.zip |
Add powerful debug header
Also, delete lib/libwrapsdl2. Why is it still there?
-rw-r--r-- | lib/include/debug.hpp | 46 | ||||
m--------- | lib/libwrapsdl2 | 0 |
2 files changed, 46 insertions, 0 deletions
diff --git a/lib/include/debug.hpp b/lib/include/debug.hpp new file mode 100644 index 0000000..5ee2ac8 --- /dev/null +++ b/lib/include/debug.hpp @@ -0,0 +1,46 @@ +#pragma once + +#ifdef DEBUG +#include <iostream> +#include <sstream> + +#define __FILENAME__ (\ + __builtin_strrchr(__FILE__, '/') ? \ + __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) + +#define npdebug(...); { \ + std::cerr << "[" << __FILENAME__ \ + << ":" << __LINE__ \ + << ", " << __func__ \ + << "] " ; \ + _np::debug(__VA_ARGS__); \ +} + +#define npinspect(...); _np::inspect(__VA_ARGS__); + +namespace _np { + template<typename... Args> + inline void debug(const Args&... args) { + (std::cerr << ... << args) << std::endl; + } + + template<typename Msg, typename Expr, typename... Args> + inline T& inspect(const Msg& msg, Expr& expr, const Args&... args) { + npdebug(msg, expr, args); + return expr; + } +} + +#else + +#define npdebug(...); {} +#define npinspect(...); {} + +namespace _np { + template<typename.. Args> + void debug(Args&... args) {} + + template<typename Msg, typename Expr, typename... Args> + inline T& inspect(const Msg& msg, Expr& expr, const Args&... args) {} +} +#endif diff --git a/lib/libwrapsdl2 b/lib/libwrapsdl2 deleted file mode 160000 -Subproject 66bb51fa6148d6910da054bacd4fcbd2fa7b5ba |