This commit was manufactured by cvs2svn to create tag
[lyx.git] / src / debug.h
blobce584db816e4c0ceb833b49b0c7ea5402371b9ec
1 // -*- C++ -*-
3 #ifndef LYXDEBUG_H
4 #define LYXDEBUG_H
6 #include "LString.h"
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.
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)
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 friend inline void operator|=(Debug::type & d1, Debug::type d2);
54 /** A function to convert symbolic string names on debug levels
55 to their numerical value.
57 static Debug::type value(string const & val) {
58 type l = Debug::NONE;
59 string v(val);
60 while (!v.empty()) {
61 string::size_type st = v.find(',');
62 string tmp(v.substr(0, st));
63 if (tmp.empty()) break;
64 if (val == "NONE") l |= Debug::NONE;
65 else if (val == "INFO") l |= Debug::INFO;
66 else if (val == "INIT") l |= Debug::INIT;
67 else if (val == "KEY") l |= Debug::KEY;
68 else if (val == "TOOLBAR") l |= Debug::TOOLBAR;
69 else if (val == "PARSER") l |= Debug::PARSER;
70 else if (val == "LYXRC") l |= Debug::LYXRC;
71 else if (val == "KBMAP") l |= Debug::KBMAP;
72 else if (val == "LATEX") l |= Debug::LATEX;
73 else if (val == "MATHED") l |= Debug::MATHED;
74 else if (val == "FONT") l |= Debug::FONT;
75 else if (val == "TCLASS") l |= Debug::TCLASS;
76 else if (val == "LYXVC") l |= Debug::LYXVC;
77 else if (val == "LYXSERVER") l |= Debug::LYXSERVER;
78 else if (val == "ROFF") l |= Debug::ROFF;
79 else break; // unknown string
80 if (st == string::npos) break;
81 v.erase(0, st + 1);
83 return l;
86 ///
87 inline void operator|=(Debug::type & d1, Debug::type d2)
89 d1 = static_cast<Debug::type>(d1 | d2);
93 #include "support/DebugStream.h"
95 ///
96 ostream & operator<<(ostream & o, Debug::type t);
98 extern DebugStream lyxerr;
100 #endif