]> git.lyx.org Git - lyx.git/blobdiff - src/support/debug.h
thinko
[lyx.git] / src / support / debug.h
index 3835242b366f7e3e34e35f4ce9fd530857afeb80..10bb5a7e87326d47042cee820ec3d0edc1f7aadc 100644 (file)
 
 #include "support/strfwd.h"
 
+// Forward definitions do not work with libc++
+// but ios_base has already been defined in strfwd
+// if compiling with it
+#ifndef USE_LLVM_LIBCPP
 namespace std {
 
 class ios_base;
@@ -24,7 +28,8 @@ class ios_base;
 template<typename CharT, typename Traits> class basic_streambuf;
 typedef basic_streambuf<char, char_traits<char> > streambuf;
 
-}
+} // namespace std
+#endif
 
 
 namespace lyx {
@@ -36,76 +41,76 @@ namespace Debug {
                ///
                NONE = 0,
                ///
-               INFO       = (1 << 0),   // 1
+               INFO       = (1u << 0),   // 1
                ///
-               INIT       = (1 << 1),   // 2
+               INIT       = (1u << 1),   // 2
                ///
-               KEY        = (1 << 2),   // 4
+               KEY        = (1u << 2),   // 4
                ///
-               GUI        = (1 << 3),   // 8
+               GUI        = (1u << 3),   // 8
                ///
-               PARSER     = (1 << 4),   // 16
+               PARSER     = (1u << 4),   // 16
                ///
-               LYXRC      = (1 << 5),   // 32
+               LYXRC      = (1u << 5),   // 32
                ///
-               KBMAP      = (1 << 6),   // 64
+               KBMAP      = (1u << 6),   // 64
                ///
-               LATEX      = (1 << 7),   // 128
+               LATEX      = (1u << 7),   // 128
                ///
-               MATHED     = (1 << 8),   // 256 // Alejandro, please use this.
+               MATHED     = (1u << 8),   // 256 // Alejandro, please use this.
                ///
-               FONT       = (1 << 9),   // 512
+               FONT       = (1u << 9),   // 512
                ///
-               TCLASS     = (1 << 10),  // 1024
+               TCLASS     = (1u << 10),  // 1024
                ///
-               LYXVC      = (1 << 11),  // 2048
+               LYXVC      = (1u << 11),  // 2048
                ///
-               LYXSERVER  = (1 << 12),  // 4096
+               LYXSERVER  = (1u << 12),  // 4096
                ///
-               UNDO       = (1 << 13),  // 8192
+               UNDO       = (1u << 13),  // 8192
                ///
-               ACTION     = (1 << 14),   // 16384
+               ACTION     = (1u << 14),   // 16384
                ///
-               LYXLEX     = (1 << 15),
+               LYXLEX     = (1u << 15),
                ///
-               DEPEND     = (1 << 16),
+               DEPEND     = (1u << 16),
                ///
-               INSETS     = (1 << 17),
+               INSETS     = (1u << 17),
                ///
-               FILES      = (1 << 18),
+               FILES      = (1u << 18),
                ///
-               WORKAREA   = (1 << 19),
+               WORKAREA   = (1u << 19),
                ///
-               INSETTEXT  = (1 << 20),
+               CLIPBOARD  = (1u << 20),
                ///
-               GRAPHICS   = (1 << 21),
+               GRAPHICS   = (1u << 21),
                /// change tracking
-               CHANGES    = (1 << 22),
+               CHANGES    = (1u << 22),
                ///
-               EXTERNAL   = (1 << 23),
+               EXTERNAL   = (1u << 23),
                ///
-               PAINTING   = (1 << 24),
+               PAINTING   = (1u << 24),
                ///
-               SCROLLING  = (1 << 25),
+               SCROLLING  = (1u << 25),
                ///
-               MACROS     = (1 << 26),
+               MACROS     = (1u << 26),
                ///     rtl-related
-               RTL        = (1 << 27),
+               RTL        = (1u << 27),
                ///     locale related
-               LOCALE     = (1 << 28),
+               LOCALE     = (1u << 28),
                ///     selection
-               SELECTION  = (1 << 29),
+               SELECTION  = (1u << 29),
                /// Find and Replace
-               FIND       = (1 << 30),
+               FIND       = (1u << 30),
                ///
-               DEBUG      = (1 << 31),
+               DEBUG      = (1u << 31),
                ///
                ANY = 0xffffffff
        };
 
        /// Return number of levels
        int levelCount();
+
        /// A function to convert debug level string names numerical values
        Type value(std::string const & val);
 
@@ -124,8 +129,6 @@ namespace Debug {
        /// Show all the possible tags that can be used for debugging
        void showTags(std::ostream & os);
 
-       /// Print simple callstack to stderr
-       void printCallStack();
 
 } // namespace Debug
 
@@ -139,8 +142,9 @@ inline void operator|=(Debug::Type & d1, Debug::Type d2)
 class LyXErr
 {
 public:
-       LyXErr(): enabled_(true), second_enabled_(false) {}
-       
+       LyXErr(): dt_(Debug::NONE), stream_(0), enabled_(true),
+                 second_stream_(0), second_enabled_(false) {}
+
        /// Disable the stream completely
        void disable();
        /// Enable the stream after a possible call of disable()
@@ -159,9 +163,9 @@ public:
        bool enabled() const { return enabled_; }
 
        /// Returns second stream
-       std::ostream & secondStream() { return *second_stream_; };
+       std::ostream & secondStream() { return *second_stream_; }
        /// Sets second stream
-       void setSecondStream(std::ostream * os) 
+       void setSecondStream(std::ostream * os)
                { second_enabled_ = (second_stream_ = os); }
        /// Is the second stream is enabled?
        bool secondEnabled() { return second_enabled_; }
@@ -173,6 +177,9 @@ public:
        /// Returns true if t is part of the current debug level
        bool debugging(Debug::Type t = Debug::ANY) const;
 
+       ///
+       static char const * stripName(char const *);
+
 private:
        /// The current debug level
        Debug::Type dt_;
@@ -195,6 +202,10 @@ LyXErr & operator<<(LyXErr &, int);
 LyXErr & operator<<(LyXErr &, unsigned int);
 LyXErr & operator<<(LyXErr &, long);
 LyXErr & operator<<(LyXErr &, unsigned long);
+#ifdef HAVE_LONG_LONG_INT
+LyXErr & operator<<(LyXErr &, long long);
+LyXErr & operator<<(LyXErr &, unsigned long long);
+#endif
 LyXErr & operator<<(LyXErr &, double);
 LyXErr & operator<<(LyXErr &, std::string const &);
 LyXErr & operator<<(LyXErr &, docstring const &);
@@ -206,11 +217,10 @@ extern LyXErr lyxerr;
 
 } // namespace lyx
 
-#if USE_BOOST_CURRENT_FUNCTION
-#      include <boost/current_function.hpp>
-#      define CURRENT_POSITION BOOST_CURRENT_FUNCTION ": "
+#if USE__func__
+#      define CURRENT_POSITION __func__ ": "
 #else
-# define CURRENT_POSITION __FILE__ << "(" << __LINE__ << "): "
+# define CURRENT_POSITION lyx::LyXErr::stripName(__FILE__) << " (" << __LINE__ << "): "
 #endif
 
 #define LYXERR(type, msg) \