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