]> git.lyx.org Git - lyx.git/blob - src/client/debug.h
7403b13638a9ce79d023386d50d02fb4681b37fc
[lyx.git] / src / client / 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
19 namespace lyx {
20
21 /** Ideally this should have been a namespace, but since we try to be
22     compilable on older C++ compilators too, we use a class instead.
23     This is all the different debug levels that we have.
24 */
25 class lyx_debug_trait {
26 public:
27         ///
28         enum type {
29                 ///
30                 NONE = 0,
31                 ///
32                 INFO       = (1 << 0),
33                 ///
34                 DEBUG      = (1 << 31),
35                 ///
36                 ANY = 0xffffffff
37         };
38
39         static bool match(type a, type b) {
40                 return (a & b);
41         }
42
43         /** A function to convert symbolic string names on debug levels
44             to their numerical value.
45         */
46         static type value(std::string const & val);
47
48         /** Display the tags and descriptions of the current debug level
49             of ds
50         */
51         static void showLevel(std::ostream & o, type level);
52
53         /** show all the possible tags that can be used for debugging */
54         static void showTags(std::ostream & o);
55
56 };
57
58
59
60 inline
61 void operator|=(lyx_debug_trait::type & d1, lyx_debug_trait::type d2)
62 {
63         d1 = static_cast<lyx_debug_trait::type>(d1 | d2);
64 }
65
66
67 // std::ostream & operator<<(std::ostream & o, Debug::type t);
68
69 typedef basic_debugstream<lyx_debug_trait> LyXErr;
70 typedef LyXErr::debug Debug;
71
72 extern LyXErr lyxerr;
73
74
75 } // namespace lyx
76
77 #endif