]> git.lyx.org Git - lyx.git/blob - src/debug.h
Fixed some lines that were too long. It compiled afterwards.
[lyx.git] / src / debug.h
1 // -*- C++ -*-
2 /**
3  * \file debug.h
4  *
5  * FIXME: It would be nice if, in lyx::use_gui mode, instead of
6  * outputting to the console, we would pipe all messages onto a file
7  * and visualise the contents dynamically in a Qt window if needed.
8  *
9  * This file is part of LyX, the document processor.
10  * Licence details can be found in the file COPYING.
11  *
12  * \author Lars Gullik Bjønnes
13  * \author Jean-Marc Lasgouttes
14  *
15  * Full author contact details are available in file CREDITS.
16  */
17
18 #ifndef LYXDEBUG_H
19 #define LYXDEBUG_H
20
21 #include "support/debugstream.h"
22 #include "support/docstring.h"
23
24
25 namespace lyx {
26
27 /** Ideally this should have been a namespace, but since we try to be
28  *  compilable on older C++ compilators too, we use a struct instead.
29  *  This is all the different debug levels that we have.
30  */
31 class lyx_debug_trait {
32 public:
33         ///
34         enum type {
35                 ///
36                 NONE = 0,
37                 ///
38                 INFO       = (1 << 0),   // 1
39                 ///
40                 INIT       = (1 << 1),   // 2
41                 ///
42                 KEY        = (1 << 2),   // 4
43                 ///
44                 GUI        = (1 << 3),   // 8
45                 ///
46                 PARSER     = (1 << 4),   // 16
47                 ///
48                 LYXRC      = (1 << 5),   // 32
49                 ///
50                 KBMAP      = (1 << 6),   // 64
51                 ///
52                 LATEX      = (1 << 7),   // 128
53                 ///
54                 MATHED     = (1 << 8),   // 256 // Alejandro, please use this.
55                 ///
56                 FONT       = (1 << 9),   // 512
57                 ///
58                 TCLASS     = (1 << 10),  // 1024
59                 ///
60                 LYXVC      = (1 << 11),  // 2048
61                 ///
62                 LYXSERVER  = (1 << 12),  // 4096
63                 ///
64                 ROFF       = (1 << 13),  // 8192
65                 ///
66                 ACTION     = (1 << 14),   // 16384
67                 ///
68                 LYXLEX     = (1 << 15),
69                 ///
70                 DEPEND     = (1 << 16),
71                 ///
72                 INSETS     = (1 << 17),
73                 ///
74                 FILES      = (1 << 18),
75                 ///
76                 WORKAREA   = (1 << 19),
77                 ///
78                 INSETTEXT  = (1 << 20),
79                 ///
80                 GRAPHICS   = (1 << 21),
81                 /// change tracking
82                 CHANGES    = (1 << 22),
83                 ///
84                 EXTERNAL   = (1 << 23),
85                 ///
86                 PAINTING   = (1 << 24),
87                 ///
88                 DEBUG      = (1 << 31),
89                 ///
90                 ANY = 0xffffffff
91         };
92
93         static bool match(type a, type b) {
94                 return (a & b);
95         }
96
97         /** A function to convert symbolic string names on debug levels
98             to their numerical value.
99         */
100         static type value(std::string const & val);
101
102         /** Display the tags and descriptions of the current debug level
103             of ds
104         */
105         static void showLevel(std::ostream & o, type level);
106
107         /** show all the possible tags that can be used for debugging */
108         static void showTags(std::ostream & o);
109
110 };
111
112
113
114 inline
115 void operator|=(lyx_debug_trait::type & d1, lyx_debug_trait::type d2)
116 {
117         d1 = static_cast<lyx_debug_trait::type>(d1 | d2);
118 }
119
120
121 typedef basic_debugstream<lyx_debug_trait> LyXErr;
122 typedef LyXErr::debug Debug;
123
124 extern LyXErr lyxerr;
125
126 } // namespace lyx
127
128 #define LYXERR(type) if (!lyx::lyxerr.debugging(type)) ; else lyx::lyxerr
129
130
131 #endif