]> git.lyx.org Git - lyx.git/blob - src/debug.h
more cursor dispatch
[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 struct lyx_debug_trait {
23         ///
24         enum type {
25                 ///
26                 NONE = 0,
27                 ///
28                 INFO       = (1 << 0),   // 1
29                 ///
30                 INIT       = (1 << 1),   // 2
31                 ///
32                 KEY        = (1 << 2),   // 4
33                 ///
34                 GUI        = (1 << 3),   // 8
35                 ///
36                 PARSER     = (1 << 4),   // 16
37                 ///
38                 LYXRC      = (1 << 5),   // 32
39                 ///
40                 KBMAP      = (1 << 6),   // 64
41                 ///
42                 LATEX      = (1 << 7),   // 128
43                 ///
44                 MATHED     = (1 << 8),   // 256 // Alejandro, please use this.
45                 ///
46                 FONT       = (1 << 9),   // 512
47                 ///
48                 TCLASS     = (1 << 10),  // 1024
49                 ///
50                 LYXVC      = (1 << 11),  // 2048
51                 ///
52                 LYXSERVER  = (1 << 12),  // 4096
53                 ///
54                 ROFF       = (1 << 13),  // 8192
55                 ///
56                 ACTION     = (1 << 14),   // 16384
57                 ///
58                 LYXLEX     = (1 << 15),
59                 ///
60                 DEPEND     = (1 << 16),
61                 ///
62                 INSETS     = (1 << 17),
63                 ///
64                 FILES      = (1 << 18),
65                 ///
66                 WORKAREA   = (1 << 19),
67                 ///
68                 INSETTEXT  = (1 << 20),
69                 ///
70                 GRAPHICS   = (1 << 21),
71                 /// change tracking
72                 CHANGES    = (1 << 22),
73                 ///
74                 EXTERNAL   = (1 << 23),
75                 ///
76                 ANY = 0xffffff
77         };
78
79         static bool match(type a, type b) {
80                 return (a & b);
81         }
82
83         /** A function to convert symbolic string names on debug levels
84             to their numerical value.
85         */
86         static type value(std::string const & val);
87
88         /** Display the tags and descriptions of the current debug level
89             of ds
90         */
91         static void showLevel(std::ostream & o, type level);
92
93         /** show all the possible tags that can be used for debugging */
94         static void showTags(std::ostream & o);
95
96 };
97
98
99
100 inline
101 void operator|=(lyx_debug_trait::type & d1, lyx_debug_trait::type d2)
102 {
103         d1 = static_cast<lyx_debug_trait::type>(d1 | d2);
104 }
105
106
107 // std::ostream & operator<<(std::ostream & o, Debug::type t);
108
109 typedef basic_debugstream<lyx_debug_trait> LyXErr;
110 typedef LyXErr::debug Debug;
111
112 extern LyXErr lyxerr;
113
114 #endif