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