1 /******************************************************************************
3 * $Id: debug.cpp,v 1.7 2001/03/19 19:27:40 root Exp $
5 * Copyright (C) 1997-2012 by Dimitri van Heesch.
7 * Permission to use, copy, modify, and distribute this software and its
8 * documentation under the terms of the GNU General Public License is hereby
9 * granted. No representations are made about the suitability of this software
10 * for any purpose. It is provided "as is" without express or implied warranty.
11 * See the GNU General Public License for more details.
13 * Documents produced by Doxygen are derivative works derived from the
14 * input used in their production; they are not affected by this license.
26 //------------------------------------------------------------------------
28 /** Helper struct representing a mapping from debug label to a debug ID */
32 Debug::DebugMask event;
35 static LabelMap s_labels[] =
37 { "findmembers", Debug::FindMembers },
38 { "functions", Debug::Functions },
39 { "variables", Debug::Variables },
40 { "preprocessor", Debug::Preprocessor },
41 { "classes", Debug::Classes },
42 { "commentcnv", Debug::CommentCnv },
43 { "commentscan", Debug::CommentScan },
44 { "validate", Debug::Validate },
45 { "printtree", Debug::PrintTree },
46 { "time", Debug::Time },
47 { "extcmd", Debug::ExtCmd },
48 { "markdown", Debug::Markdown },
49 { "filteroutput", Debug::FilterOutput },
50 { 0, (Debug::DebugMask)0 }
53 /** Class representing a mapping from debug labels to debug IDs. */
57 LabelMapper() : m_map(17)
59 m_map.setAutoDelete(TRUE);
60 LabelMap *p = s_labels;
63 m_map.insert(p->name,new Debug::DebugMask(p->event));
67 Debug::DebugMask *find(const char *s) const
73 QDict<Debug::DebugMask> m_map;
76 static LabelMapper g_labelMapper;
78 //------------------------------------------------------------------------
80 Debug::DebugMask Debug::curMask = Debug::Quiet;
81 int Debug::curPrio = 0;
83 void Debug::print(DebugMask mask,int prio,const char *fmt,...)
85 if ((curMask&mask) && prio<=curPrio)
89 vfprintf(stdout, fmt, args);
94 static int labelToEnumValue(const char *l)
97 Debug::DebugMask *event = g_labelMapper.find(label.lower());
98 if (event) return *event; else return 0;
101 void Debug::setFlag(const char *lab)
103 curMask = (DebugMask)(curMask | labelToEnumValue(lab));
106 void Debug::clearFlag(const char *lab)
108 curMask = (DebugMask)(curMask & ~labelToEnumValue(lab));
111 void Debug::setPriority(int p)
116 bool Debug::isFlagSet(DebugMask mask)
118 return (curMask & mask)!=0;