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