]> git.lyx.org Git - lyx.git/blob - src/debug.h
0dd2501c6051cd95fb384a4473cd0905ac9e26e9
[lyx.git] / src / debug.h
1 // -*- C++ -*-
2
3 #ifndef LYXDEBUG_H
4 #define LYXDEBUG_H
5
6 #include "LString.h"
7
8 /** Ideally this should have been a namespace, but since we try to be
9     compilable on older C++ compilators too, we use a struct instead.
10     This is all the different debug levels that we have.
11 */
12 struct Debug {
13         ///
14         enum type {
15                 ///
16                 NONE = 0,
17                 ///
18                 INFO       = (1 << 0),   // 1
19                 ///
20                 INIT       = (1 << 1),   // 2
21                 ///
22                 KEY        = (1 << 2),   // 4
23                 ///
24                 TOOLBAR    = (1 << 3),   // 8
25                 ///
26                 PARSER     = (1 << 4),   // 16
27                 ///
28                 LYXRC      = (1 << 5),   // 32
29                 ///
30                 KBMAP      = (1 << 6),   // 64
31                 ///
32                 LATEX      = (1 << 7),   // 128
33                 ///
34                 MATHED     = (1 << 8),   // 256 // Alejandro, please use this.
35                 ///
36                 FONT       = (1 << 9),   // 512
37                 ///
38                 TCLASS     = (1 << 10),  // 1024
39                 ///
40                 LYXVC      = (1 << 11),  // 2048
41                 ///
42                 LYXSERVER  = (1 << 12),  // 4096
43                 ///
44                 ROFF       = (1 << 13) 
45         };
46         ///
47         static const type ANY = type(INFO | INIT | KEY | TOOLBAR |
48                                      PARSER | LYXRC | KBMAP | LATEX |
49                                      MATHED | FONT | TCLASS | LYXVC |
50                                      LYXSERVER | ROFF);
51
52         /** A function to convert symbolic string names on debug levels
53             to their numerical value.
54         */
55         static Debug::type value(string const & val) {
56                 int l = Debug::NONE;
57                 string v(val);
58                 while (!v.empty()) {
59                         string::size_type st = v.find(',');
60                         string tmp(v.substr(0, st));
61                         if (tmp.empty()) break;
62                         if (val == "NONE") l |= Debug::NONE;
63                         else if (val == "INFO") l |= Debug::INFO;
64                         else if (val == "INIT") l |= Debug::INIT;
65                         else if (val == "KEY") l |= Debug::KEY; 
66                         else if (val == "TOOLBAR") l |= Debug::TOOLBAR;
67                         else if (val == "PARSER") l |= Debug::PARSER; 
68                         else if (val == "LYXRC") l |= Debug::LYXRC; 
69                         else if (val == "KBMAP") l |= Debug::KBMAP;  
70                         else if (val == "LATEX") l |= Debug::LATEX;  
71                         else if (val == "MATHED") l |= Debug::MATHED; 
72                         else if (val == "FONT") l |= Debug::FONT;   
73                         else if (val == "TCLASS") l |= Debug::TCLASS; 
74                         else if (val == "LYXVC") l |= Debug::LYXVC;  
75                         else if (val == "LYXSERVER") l |= Debug::LYXSERVER;
76                         else if (val == "ROFF") l |= Debug::ROFF;
77                         else break; // unknown string
78                         if (st == string::npos) break;
79                         v.erase(0, st + 1);
80                 }
81                 return Debug::type(l);
82         }
83 };
84
85
86 #include "support/DebugStream.h"
87
88 ///
89 ostream & operator<<(ostream & o, Debug::type t);
90
91 extern DebugStream lyxerr;
92
93 #endif
94
95