--- /dev/null
+#ifndef STLPLUS_DEBUG\r
+#define STLPLUS_DEBUG\r
+////////////////////////////////////////////////////////////////////////////////\r
+\r
+// Author: Andy Rushton\r
+// Copyright: (c) Southampton University 1999-2004\r
+// (c) Andy Rushton 2004-2009\r
+// License: BSD License, see ../docs/license.html\r
+\r
+// Set of simple debug utilities, all of which are switched off by the\r
+// NDEBUG compiler directive\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+\r
+#include "portability_fixes.hpp"\r
+#include <stdexcept>\r
+#include <string>\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// Problem with missing __FUNCTION__ macro\r
+////////////////////////////////////////////////////////////////////////////////\r
+// this macro is used in debugging but was missing in Visual Studio prior to version 7\r
+// it also has a different name in Borland\r
+\r
+#if defined(_MSC_VER) && (_MSC_VER < 1300)\r
+#define __FUNCTION__ 0\r
+#endif\r
+\r
+#ifdef __BORLANDC__\r
+#define __FUNCTION__ __FUNC__\r
+#endif\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// Exception thrown if an assertion fails\r
+\r
+namespace stlplus\r
+{\r
+\r
+ class assert_failed : public std::logic_error\r
+ {\r
+ public:\r
+ assert_failed(const char* file, int line, const char* function, const char* message) throw();\r
+ ~assert_failed(void) throw();\r
+ };\r
+\r
+} // end namespace stlplus\r
+\r
+ ////////////////////////////////////////////////////////////////////////////////\r
+ // The macros used in debugging\r
+\r
+#ifndef NDEBUG\r
+\r
+#define DEBUG_TRACE stlplus::debug_trace stlplus_debug_trace(__FILE__,__LINE__,__FUNCTION__)\r
+#define IF_DEBUG(stmts) {if (stlplus_debug_trace.debug()){stlplus_debug_trace.prefix(__LINE__);stmts;}}\r
+#define DEBUG_REPORT(str) IF_DEBUG(stlplus_debug_trace.report(__LINE__,str))\r
+#define DEBUG_ERROR(str) stlplus_debug_trace.error(__LINE__,str)\r
+#define DEBUG_STACKDUMP(str) stlplus_debug_trace.stackdump(__LINE__,str)\r
+#define DEBUG_ON stlplus_debug_trace.debug_on(__LINE__,true)\r
+#define DEBUG_ON_LOCAL stlplus_debug_trace.debug_on(__LINE__,false)\r
+#define DEBUG_ON_GLOBAL stlplus::debug_global(__FILE__,__LINE__,__FUNCTION__,true)\r
+#define DEBUG_OFF_GLOBAL stlplus::debug_global(__FILE__,__LINE__,__FUNCTION__,false)\r
+#define DEBUG_OFF stlplus_debug_trace.debug_off(__LINE__)\r
+#define DEBUG_ASSERT(test) if (!(test))stlplus::debug_assert_fail(__FILE__,__LINE__,__FUNCTION__,#test)\r
+\r
+#else\r
+\r
+#define DEBUG_TRACE\r
+#define IF_DEBUG(stmts)\r
+#define DEBUG_REPORT(str)\r
+#define DEBUG_ERROR(str)\r
+#define DEBUG_STACKDUMP(str)\r
+#define DEBUG_ON\r
+#define DEBUG_ON_LOCAL\r
+#define DEBUG_ON_GLOBAL\r
+#define DEBUG_OFF_GLOBAL\r
+#define DEBUG_OFF\r
+#define DEBUG_ASSERT(test)\r
+\r
+#endif\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// infrastructure - don't use directly\r
+\r
+namespace stlplus\r
+{\r
+\r
+ void debug_global(const char* file, int line, const char* function, bool state = true);\r
+ void debug_assert_fail(const char* file, int line, const char* function, const char* test) throw(assert_failed);\r
+\r
+ class debug_trace\r
+ {\r
+ public:\r
+ debug_trace(const char* f, int l, const char* fn);\r
+ ~debug_trace(void);\r
+ const char* file(void) const;\r
+ int line(void) const;\r
+ bool debug(void) const;\r
+ void debug_on(int l, bool recurse);\r
+ void debug_off(int l);\r
+ void prefix(int l) const;\r
+ void report(int l, const std::string& message) const;\r
+ void report(const std::string& message) const;\r
+ void error(int l, const std::string& message) const;\r
+ void error(const std::string& message) const;\r
+ void stackdump(int l, const std::string& message) const;\r
+ void stackdump(const std::string& message) const;\r
+ void stackdump(void) const;\r
+\r
+ private:\r
+ const char* m_file;\r
+ int m_line;\r
+ const char* m_function;\r
+ unsigned m_depth;\r
+ const debug_trace* m_last;\r
+ bool m_dbg;\r
+ bool m_old;\r
+ void do_report(int l, const std::string& message) const;\r
+ void do_report(const std::string& message) const;\r
+\r
+ // make this class uncopyable\r
+ debug_trace(const debug_trace&);\r
+ debug_trace& operator = (const debug_trace&);\r
+ };\r
+\r
+} // end namespace stlplus\r
+\r
+ ////////////////////////////////////////////////////////////////////////////////\r
+#endif\r