]> git.lyx.org Git - lyx.git/blob - src/debug.h
fix some of the bugs reported, should hopefully be a bit better now.
[lyx.git] / src / debug.h
1 // -*- C++ -*-
2
3 #ifndef LYXDEBUG_H
4 #define LYXDEBUG_H
5
6 #include "LString.h"
7 #include "support/LOstream.h"
8 #include "support/lstrings.h"
9
10 /** Ideally this should have been a namespace, but since we try to be
11     compilable on older C++ compilators too, we use a struct instead.
12     This is all the different debug levels that we have.
13 */
14 struct Debug {
15         ///
16         enum type {
17                 ///
18                 NONE = 0,
19                 ///
20                 INFO       = (1 << 0),   // 1
21                 ///
22                 INIT       = (1 << 1),   // 2
23                 ///
24                 KEY        = (1 << 2),   // 4
25                 ///
26                 TOOLBAR    = (1 << 3),   // 8
27                 ///
28                 PARSER     = (1 << 4),   // 16
29                 ///
30                 LYXRC      = (1 << 5),   // 32
31                 ///
32                 KBMAP      = (1 << 6),   // 64
33                 ///
34                 LATEX      = (1 << 7),   // 128
35                 ///
36                 MATHED     = (1 << 8),   // 256 // Alejandro, please use this.
37                 ///
38                 FONT       = (1 << 9),   // 512
39                 ///
40                 TCLASS     = (1 << 10),  // 1024
41                 ///
42                 LYXVC      = (1 << 11),  // 2048
43                 ///
44                 LYXSERVER  = (1 << 12),  // 4096
45                 ///
46                 ROFF       = (1 << 13),  // 8192
47                 ///
48                 ACTION     = (1 << 14),   // 16384
49                 ///
50                 LYXLEX     = (1 << 15)
51         };
52         ///
53         static const type ANY = type(INFO | INIT | KEY | TOOLBAR |
54                                      PARSER | LYXRC | KBMAP | LATEX |
55                                      MATHED | FONT | TCLASS | LYXVC |
56                                      LYXSERVER | ROFF | ACTION | LYXLEX);
57         ///
58         friend inline void operator|=(Debug::type & d1, Debug::type d2);
59         
60         /** A function to convert symbolic string names on debug levels
61             to their numerical value.
62         */
63         static Debug::type value(string const & val); 
64
65         /** Display the tags and descriptions of the current debug level 
66             of ds 
67         */
68         static void showLevel(ostream & o, type level);
69
70         /** show all the possible tags that can be used for debugging */
71         static void showTags(ostream & o);
72
73 };
74
75
76 ///
77 inline void operator|= (Debug::type & d1, Debug::type d2)
78 {
79         d1 = static_cast<Debug::type>(d1 | d2);
80 }
81
82
83 #include "support/DebugStream.h"
84
85
86 ///
87 ostream & operator<<(ostream & o, Debug::type t);
88
89 extern DebugStream lyxerr;
90
91 #endif