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