Doxygen
Loading...
Searching...
No Matches
debug.h
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2020 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16#ifndef DEBUG_H
17#define DEBUG_H
18
19#include <cstdint>
20
21#include "construct.h"
22#include "dstring.h"
23#include "message.h"
24
25/** Class containing a print function for diagnostics. */
26class Debug
27{
28 public:
29 enum DebugMask : uint64_t {
30 Quiet = 0x00'0000ULL,
31 Preprocessor = 0x00'0001ULL,
32 CommentCnv = 0x00'0002ULL,
33 CommentScan = 0x00'0004ULL,
34 Formula = 0x00'0008ULL,
35 PrintTree = 0x00'0010ULL,
36 Time = 0x00'0020ULL,
37 ExtCmd = 0x00'0040ULL,
38 Markdown = 0x00'0080ULL,
39 FilterOutput = 0x00'0100ULL,
40 Plantuml = 0x00'0200ULL,
41 FortranFixed2Free = 0x00'0400ULL,
42 Cite = 0x00'0800ULL,
43 NoLineNo = 0x00'1000ULL,
44 Rtf = 0x00'2000ULL,
45 Qhp = 0x00'4000ULL,
46 Tag = 0x00'8000ULL,
47 Alias = 0x01'0000ULL,
48 Entries = 0x02'0000ULL,
49 Sections = 0x04'0000ULL,
50 Stderr = 0x08'0000ULL,
51 Layout = 0x10'0000ULL,
52 Mermaid = 0x20'0000ULL,
53 Lex = 0x0000'FFFF'FF00'0000ULL, // all scanners combined
54 Lex_code = 0x0000'0000'0100'0000ULL,
55 Lex_commentcnv = 0x0000'0000'0200'0000ULL,
56 Lex_commentscan = 0x0000'0000'0400'0000ULL,
57 Lex_configimpl = 0x0000'0000'0800'0000ULL,
58 Lex_constexp = 0x0000'0000'1000'0000ULL,
59 Lex_declinfo = 0x0000'0000'2000'0000ULL,
60 Lex_defargs = 0x0000'0000'4000'0000ULL,
61 Lex_doctokenizer = 0x0000'0000'8000'0000ULL,
62 Lex_fortrancode = 0x0000'0001'0000'0000ULL,
63 Lex_fortranscanner= 0x0000'0002'0000'0000ULL,
64 Lex_lexcode = 0x0000'0004'0000'0000ULL,
65 Lex_lexscanner = 0x0000'0008'0000'0000ULL,
66 Lex_pre = 0x0000'0010'0000'0000ULL,
67 Lex_pycode = 0x0000'0020'0000'0000ULL,
68 Lex_pyscanner = 0x0000'0040'0000'0000ULL,
69 Lex_scanner = 0x0000'0080'0000'0000ULL,
70 Lex_sqlcode = 0x0000'0100'0000'0000ULL,
71 Lex_vhdlcode = 0x0000'0200'0000'0000ULL,
72 Lex_xml = 0x0000'0400'0000'0000ULL,
73 Lex_xmlcode = 0x0000'0800'0000'0000ULL
74 };
75 static void print_(DebugMask mask, int prio, fmt::string_view fmt, fmt::format_args args);
76
77 template<typename ...Args>
78 static void print(DebugMask mask,int prio,fmt::format_string<Args...> fmt, Args&&... args)
79 {
80 print_(mask,prio,fmt,fmt::make_format_args(args...));
81 }
82
83 static bool setFlagStr(const DString &label);
84 static void setFlag(const DebugMask mask);
85 static void clearFlag(const DebugMask mask);
86 static bool isFlagSet(const DebugMask mask);
87 static void printFlags();
88 static void setPriority(int p);
89
90 static void startTimer();
91 static double elapsedTime();
92
93 private:
95 static int curPrio;
96};
97
99{
100 public:
101 DebugLex(Debug::DebugMask mask,const char *lexName,const char *fileName);
102 ~DebugLex();
104 static void print(Debug::DebugMask mask,const char *state,const char *lexName,const char *fileName);
105 private:
106
110};
111
112
113#endif
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:88
Class containing a print function for diagnostics.
Definition debug.h:27
DebugMask
Definition debug.h:29
@ Lex_fortranscanner
Definition debug.h:63
@ Lex_doctokenizer
Definition debug.h:61
@ Lex
Definition debug.h:53
@ Rtf
Definition debug.h:44
@ NoLineNo
Definition debug.h:43
@ Mermaid
Definition debug.h:52
@ Lex_pre
Definition debug.h:66
@ Lex_defargs
Definition debug.h:60
@ Alias
Definition debug.h:47
@ Lex_pycode
Definition debug.h:67
@ Layout
Definition debug.h:51
@ Markdown
Definition debug.h:38
@ Lex_declinfo
Definition debug.h:59
@ Tag
Definition debug.h:46
@ Lex_lexscanner
Definition debug.h:65
@ FilterOutput
Definition debug.h:39
@ Lex_sqlcode
Definition debug.h:70
@ Lex_code
Definition debug.h:54
@ Lex_pyscanner
Definition debug.h:68
@ Cite
Definition debug.h:42
@ ExtCmd
Definition debug.h:37
@ Sections
Definition debug.h:49
@ PrintTree
Definition debug.h:35
@ Time
Definition debug.h:36
@ Quiet
Definition debug.h:30
@ Lex_xml
Definition debug.h:72
@ Stderr
Definition debug.h:50
@ Plantuml
Definition debug.h:40
@ Formula
Definition debug.h:34
@ Lex_commentcnv
Definition debug.h:55
@ Lex_vhdlcode
Definition debug.h:71
@ Lex_constexp
Definition debug.h:58
@ Lex_xmlcode
Definition debug.h:73
@ Lex_fortrancode
Definition debug.h:62
@ Lex_commentscan
Definition debug.h:56
@ Lex_lexcode
Definition debug.h:64
@ Qhp
Definition debug.h:45
@ Entries
Definition debug.h:48
@ Lex_configimpl
Definition debug.h:57
@ Preprocessor
Definition debug.h:31
@ Lex_scanner
Definition debug.h:69
@ CommentCnv
Definition debug.h:32
@ FortranFixed2Free
Definition debug.h:41
@ CommentScan
Definition debug.h:33
static void printFlags()
Definition debug.cpp:138
static DebugMask curMask
Definition debug.h:94
static void setPriority(int p)
Definition debug.cpp:128
static int curPrio
Definition debug.h:95
static void clearFlag(const DebugMask mask)
Definition debug.cpp:123
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:133
static void print(DebugMask mask, int prio, fmt::format_string< Args... > fmt, Args &&... args)
Definition debug.h:78
static double elapsedTime()
Definition debug.cpp:201
static void startTimer()
Definition debug.cpp:196
static bool setFlagStr(const DString &label)
Definition debug.cpp:104
static void print_(DebugMask mask, int prio, fmt::string_view fmt, fmt::format_args args)
Definition debug.cpp:82
static void setFlag(const DebugMask mask)
Definition debug.cpp:118
DebugLex(Debug::DebugMask mask, const char *lexName, const char *fileName)
Definition debug.cpp:147
DString m_lexName
Definition debug.h:108
~DebugLex()
Definition debug.cpp:152
DString m_fileName
Definition debug.h:109
Debug::DebugMask m_mask
Definition debug.h:107
static void print(Debug::DebugMask mask, const char *state, const char *lexName, const char *fileName)
Definition debug.cpp:157
#define NON_COPYABLE(cls)
Macro to help implementing the rule of 5 for a non-copyable & movable class.
Definition construct.h:37
Definition message.h:144