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