]> git.lyx.org Git - lyx.git/blobdiff - src/support/debug.h
Improve quotation mark opening/closing guess
[lyx.git] / src / support / debug.h
index ecabb506c1f4a7231e6cd5e4736752bdae0a8f2c..b98dfd0eab5fe988e75121907bd4045b04d75873 100644 (file)
@@ -2,10 +2,6 @@
 /**
  * \file debug.h
  *
- * FIXME: It would be nice if, in lyx::use_gui mode, instead of
- * outputting to the console, we would pipe all messages onto a file
- * and visualise the contents dynamically in a Qt window if needed.
- *
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
 #define LYXDEBUG_H
 
 #include "support/strfwd.h"
-#include <vector>
 
+// 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;
@@ -30,6 +29,7 @@ template<typename CharT, typename Traits> class basic_streambuf;
 typedef basic_streambuf<char, char_traits<char> > streambuf;
 
 }
+#endif
 
 
 namespace lyx {
@@ -81,7 +81,7 @@ namespace Debug {
                ///
                WORKAREA   = (1 << 19),
                ///
-               INSETTEXT  = (1 << 20),
+               CLIPBOARD  = (1 << 20),
                ///
                GRAPHICS   = (1 << 21),
                /// change tracking
@@ -108,28 +108,28 @@ namespace Debug {
                ANY = 0xffffffff
        };
 
-       const std::vector<Type> levels();
-
-       /** A function to convert symbolic string names on debug levels
-           to their numerical value.
-       */
+       /// Return number of levels
+       int levelCount();
+       /// A function to convert debug level string names numerical values
        Type value(std::string const & val);
 
+       /// A function to convert index of level to their numerical value
+       Type value(int val);
+
        /// Return description of level
        std::string const description(Type val);
 
        /// Return name of level
        std::string const name(Type val);
 
-
-       /** Display the tags and descriptions of the current debug level
-           of ds
-       */
+       /// Display the tags and descriptions of the current debug level
        void showLevel(std::ostream & os, Type level);
 
-       /** show all the possible tags that can be used for debugging */
+       /// Show all the possible tags that can be used for debugging
        void showTags(std::ostream & os);
 
+
 } // namespace Debug
 
 
@@ -142,45 +142,55 @@ inline void operator|=(Debug::Type & d1, Debug::Type d2)
 class LyXErr
 {
 public:
-       LyXErr(): enabled_(true), second_used_(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()
        void enable();
-       ///
-       bool enabled() const { return enabled_; }
-       /// Returns true if t is part of the current debug level.
-       bool debugging(Debug::Type t = Debug::ANY) const;
+
        /// Ends output
        void endl();
-       /// Sets stream
-       void setStream(std::ostream & os) { stream_ = &os; }
-       /// Sets stream
+
+       /// Returns stream
        std::ostream & stream() { return *stream_; }
-       /// Sets the debug level to t.
-       void level(Debug::Type t) { dt = t; }
-       /// Returns the current debug level.
-       Debug::Type level() const { return dt; }
        /// Returns stream
        operator std::ostream &() { return *stream_; }
-       /// Returns second_used_
-       bool second_used() { return second_used_; }
-       // Returns second stream
-       std::ostream & second() { return *second_; };
-       /// Sets the second stream
-       void setSecond(std::ostream * os) { second_used_ = (second_ = os); }
+       /// Sets stream
+       void setStream(std::ostream & os) { stream_ = &os; }
+       /// Is the stream enabled ?
+       bool enabled() const { return enabled_; }
+
+       /// Returns second stream
+       std::ostream & secondStream() { return *second_stream_; }
+       /// Sets second stream
+       void setSecondStream(std::ostream * os) 
+               { second_enabled_ = (second_stream_ = os); }
+       /// Is the second stream is enabled?
+       bool secondEnabled() { return second_enabled_; }
+
+       /// Sets the debug level
+       void setLevel(Debug::Type t) { dt_ = t; }
+       /// Returns the current debug level
+       Debug::Type level() const { return dt_; }
+       /// 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;
-       /// Is the stream enabled?
-       bool enabled_;
+       Debug::Type dt_;
        /// The real stream
        std::ostream * stream_;
+       /// Is the stream enabled?
+       bool enabled_;
        /// Next stream for output duplication
-       std::ostream * second_;
+       std::ostream * second_stream_;
        /// Is the second stream enabled?
-       bool second_used_;
+       bool second_enabled_;
 };
 
 namespace support { class FileName; }
@@ -192,6 +202,10 @@ LyXErr & operator<<(LyXErr &, int);
 LyXErr & operator<<(LyXErr &, unsigned int);
 LyXErr & operator<<(LyXErr &, long);
 LyXErr & operator<<(LyXErr &, unsigned long);
+#ifdef LYX_USE_LONG_LONG
+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 &);
@@ -207,7 +221,7 @@ extern LyXErr lyxerr;
 #      include <boost/current_function.hpp>
 #      define CURRENT_POSITION BOOST_CURRENT_FUNCTION ": "
 #else
-# define CURRENT_POSITION __FILE__ << "(" << __LINE__ << "): "
+# define CURRENT_POSITION lyx::LyXErr::stripName(__FILE__) << " (" << __LINE__ << "): "
 #endif
 
 #define LYXERR(type, msg) \