4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
10 * Full author contact details are available in file CREDITS.
16 #include "support/docstring.h"
21 /** Ideally this should have been a namespace, but since we try to be
22 * compilable on older C++ compilators too, we use a struct instead.
23 * This is all the different debug levels that we have.
39 /** A function to convert symbolic string names on debug levels
40 to their numerical value.
42 static Type value(std::string const & val);
44 /** Display the tags and descriptions of the current debug level
47 static void showLevel(std::ostream & o, Type level);
49 /** show all the possible tags that can be used for debugging */
50 static void showTags(std::ostream & o);
55 inline void operator|=(Debug::Type & d1, Debug::Type d2)
57 d1 = static_cast<Debug::Type>(d1 | d2);
64 /// Disable the stream completely
66 /// Enable the stream after a possible call of disable()
68 /// Returns true if t is part of the current debug level.
69 bool debugging(Debug::Type t = Debug::ANY) const;
73 void setStream(std::ostream & os) { stream_ = &os; }
75 std::ostream & stream() { return *stream_; }
76 /// Sets the debug level to t.
77 void level(Debug::Type t) { dt = t; }
78 /// Returns the current debug level.
79 Debug::Type level() const { return dt; }
81 operator std::ostream &() { return *stream_; }
83 /// The current debug level
85 /// Is the stream enabled?
88 std::ostream * stream_;
91 namespace support { class FileName; }
93 LyXErr & operator<<(LyXErr &, void const *);
94 LyXErr & operator<<(LyXErr &, char const *);
95 LyXErr & operator<<(LyXErr &, char);
96 LyXErr & operator<<(LyXErr &, int);
97 LyXErr & operator<<(LyXErr &, unsigned int);
98 LyXErr & operator<<(LyXErr &, long);
99 LyXErr & operator<<(LyXErr &, unsigned long);
100 LyXErr & operator<<(LyXErr &, double);
101 LyXErr & operator<<(LyXErr &, std::string const &);
102 LyXErr & operator<<(LyXErr &, docstring const &);
103 LyXErr & operator<<(LyXErr &, std::ostream &(*)(std::ostream &));
104 LyXErr & operator<<(LyXErr &, std::ios_base &(*)(std::ios_base &));
105 LyXErr & operator<<(LyXErr & l, support::FileName const & t);
107 extern LyXErr lyxerr;
111 #define LYXERR(type, msg) \
112 do { if (!lyx::lyxerr.debugging(type)) {} \
113 else lyx::lyxerr << msg << std::endl; } while (0)