outputlist.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  *
4  *
5  * Copyright (C) 1997-2015 by Dimitri van Heesch.
6  *
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.
12  *
13  * Documents produced by Doxygen are derivative works derived from the
14  * input used in their production; they are not affected by this license.
15  *
16  */
17 
18 /*! \file
19  * This class represents a list of output generators that work in "parallel".
20  * The class only knows about the abstract base class OutputGenerators.
21  * All output is produced by calling a method of this class, which forwards
22  * the call to all output generators.
23  */
24 
25 #include "outputlist.h"
26 #include "outputgen.h"
27 #include "config.h"
28 #include "message.h"
29 #include "definition.h"
30 #include "docparser.h"
31 #include "vhdldocgen.h"
32 
34 {
35  //printf("OutputList::OutputList()\n");
37 }
38 
40 {
41  //printf("OutputList::~OutputList()\n");
42 }
43 
45 {
46  if (og) m_outputs.append(og);
47 }
48 
50 {
52  OutputGenerator *og;
53  for (it.toFirst();(og=it.current());++it)
54  {
55  og->disableIfNot(o);
56  }
57 }
58 
60 {
62  OutputGenerator *og;
63  for (it.toFirst();(og=it.current());++it)
64  {
65  og->enable();
66  }
67 }
68 
70 {
72  OutputGenerator *og;
73  for (it.toFirst();(og=it.current());++it)
74  {
75  og->disable();
76  }
77 }
78 
80 {
82  OutputGenerator *og;
83  for (it.toFirst();(og=it.current());++it)
84  {
85  og->disableIf(o);
86  }
87 }
88 
90 {
92  OutputGenerator *og;
93  for (it.toFirst();(og=it.current());++it)
94  {
95  og->enableIf(o);
96  }
97 }
98 
100 {
101  bool result=FALSE;
103  OutputGenerator *og;
104  for (it.toFirst();(og=it.current());++it)
105  {
106  result=result || og->isEnabled(o);
107  }
108  return result;
109 }
110 
112 {
114  OutputGenerator *og;
115  for (it.toFirst();(og=it.current());++it)
116  {
117  og->pushGeneratorState();
118  }
119 }
120 
122 {
124  OutputGenerator *og;
125  for (it.toFirst();(og=it.current());++it)
126  {
127  og->popGeneratorState();
128  }
129 }
130 
131 bool OutputList::generateDoc(const char *fileName,int startLine,
132  Definition *ctx,MemberDef * md,
133  const QCString &docStr,bool indexWords,
134  bool isExample,const char *exampleName,
135  bool singleLine,bool linkFromIndex)
136 {
137  int count=0;
138  if (docStr.isEmpty()) return TRUE;
139 
141  OutputGenerator *og;
142  for (it.toFirst();(og=it.current());++it)
143  {
144  if (og->isEnabled()) count++;
145  }
146  if (count==0) return TRUE; // no output formats enabled.
147 
148  DocRoot *root=0;
149  root = validatingParseDoc(fileName,startLine,
150  ctx,md,docStr,indexWords,isExample,exampleName,
151  singleLine,linkFromIndex);
152 
153  writeDoc(root,ctx,md);
154 
155  bool isEmpty = root->isEmpty();
156 
157  delete root;
158 
159  return isEmpty;
160 }
161 
163 {
165  OutputGenerator *og;
166  for (it.toFirst();(og=it.current());++it)
167  {
168  //printf("og->printDoc(extension=%s)\n",
169  // ctx?ctx->getDefFileExtension().data():"<null>");
170  if (og->isEnabled()) og->writeDoc(root,ctx,md);
171  }
173 }
174 
175 bool OutputList::parseText(const QCString &textStr)
176 {
177  int count=0;
179  OutputGenerator *og;
180  for (it.toFirst();(og=it.current());++it)
181  {
182  if (og->isEnabled()) count++;
183  }
184  if (count==0) return TRUE; // no output formats enabled.
185 
186  DocText *root = validatingParseText(textStr);
187 
188  for (it.toFirst();(og=it.current());++it)
189  {
190  if (og->isEnabled()) og->writeDoc(root,0,0);
191  }
192 
193  bool isEmpty = root->isEmpty();
194 
195  delete root;
196 
197  return isEmpty;
198 }
199 
200 
201 //--------------------------------------------------------------------------
202 // Create some overloaded definitions of the forall function.
203 // Using template functions here would have made it a little less
204 // portable (I guess).
205 
206 // zero arguments
208 {
210  OutputGenerator *og;
211  for (it.toFirst();(og=it.current());++it)
212  {
213  if (og->isEnabled()) (og->*func)();
214  }
215 }
216 
217 // one argument
218 #define FORALL1(a1,p1) \
219 void OutputList::forall(void (OutputGenerator::*func)(a1),a1) \
220 { \
221  QListIterator<OutputGenerator> it(m_outputs); \
222  OutputGenerator *og; \
223  for (it.toFirst();(og=it.current());++it) \
224  { \
225  if (og->isEnabled()) (og->*func)(p1); \
226  } \
227 }
228 
229 // two arguments
230 #define FORALL2(a1,a2,p1,p2) \
231 void OutputList::forall(void (OutputGenerator::*func)(a1,a2),a1,a2) \
232 { \
233  QListIterator<OutputGenerator> it(m_outputs); \
234  OutputGenerator *og; \
235  for (it.toFirst();(og=it.current());++it) \
236  { \
237  if (og->isEnabled()) (og->*func)(p1,p2); \
238  } \
239 }
240 
241 // three arguments
242 #define FORALL3(a1,a2,a3,p1,p2,p3) \
243 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3),a1,a2,a3) \
244 { \
245  QListIterator<OutputGenerator> it(m_outputs); \
246  OutputGenerator *og; \
247  for (it.toFirst();(og=it.current());++it) \
248  { \
249  if (og->isEnabled()) (og->*func)(p1,p2,p3); \
250  } \
251 }
252 
253 // four arguments
254 #define FORALL4(a1,a2,a3,a4,p1,p2,p3,p4) \
255 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3,a4),a1,a2,a3,a4) \
256 { \
257  QListIterator<OutputGenerator> it(m_outputs); \
258  OutputGenerator *og; \
259  for (it.toFirst();(og=it.current());++it) \
260  { \
261  if (og->isEnabled()) (og->*func)(p1,p2,p3,p4); \
262  } \
263 }
264 
265 // five arguments
266 #define FORALL5(a1,a2,a3,a4,a5,p1,p2,p3,p4,p5) \
267 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3,a4,a5),a1,a2,a3,a4,a5) \
268 { \
269  QListIterator<OutputGenerator> it(m_outputs); \
270  OutputGenerator *og; \
271  for (it.toFirst();(og=it.current());++it) \
272  { \
273  if (og->isEnabled()) (og->*func)(p1,p2,p3,p4,p5); \
274  } \
275 }
276 
277 // six arguments
278 #define FORALL6(a1,a2,a3,a4,a5,a6,p1,p2,p3,p4,p5,p6) \
279 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3,a4,a5,a6),a1,a2,a3,a4,a5,a6) \
280 { \
281  QListIterator<OutputGenerator> it(m_outputs); \
282  OutputGenerator *og; \
283  for (it.toFirst();(og=it.current());++it) \
284  { \
285  if (og->isEnabled()) (og->*func)(p1,p2,p3,p4,p5,p6); \
286  } \
287 }
288 
289 // seven arguments
290 #define FORALL7(a1,a2,a3,a4,a5,a6,a7,p1,p2,p3,p4,p5,p6,p7) \
291 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3,a4,a5,a6,a7),a1,a2,a3,a4,a5,a6,a7) \
292 { \
293  QListIterator<OutputGenerator> it(m_outputs); \
294  OutputGenerator *og; \
295  for (it.toFirst();(og=it.current());++it) \
296  { \
297  if (og->isEnabled()) (og->*func)(p1,p2,p3,p4,p5,p6,p7); \
298  } \
299 }
300 
301 
302 // eight arguments
303 #define FORALL8(a1,a2,a3,a4,a5,a6,a7,a8,p1,p2,p3,p4,p5,p6,p7,p8) \
304 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3,a4,a5,a6,a7,a8),a1,a2,a3,a4,a5,a6,a7,a8) \
305 { \
306  QListIterator<OutputGenerator> it(m_outputs); \
307  OutputGenerator *og; \
308  for (it.toFirst();(og=it.current());++it) \
309  { \
310  if (og->isEnabled()) (og->*func)(p1,p2,p3,p4,p5,p6,p7,p8); \
311  } \
312 }
313 
314 // now instantiate only the ones we need.
315 
316 FORALL1(const char *a1,a1)
317 FORALL1(char a1,a1)
318 FORALL1(int a1,a1)
321 FORALL1(const DotCallGraph &a1,a1)
322 FORALL1(const DotDirDeps &a1,a1)
325 FORALL1(SectionTypes a1,a1)
326 #if defined(HAS_BOOL_TYPE) || defined(Q_HAS_BOOL_TYPE)
327 FORALL1(bool a1,a1)
328 FORALL2(bool a1,int a2,a1,a2)
329 FORALL2(bool a1,bool a2,a1,a2)
330 FORALL2(const char *a1,bool a2,a1,a2)
331 FORALL4(const char *a1,const char *a2,const char *a3,bool a4,a1,a2,a3,a4)
332 #endif
333 FORALL2(int a1,bool a2,a1,a2)
334 FORALL2(bool a1,const char *a2,a1,a2)
335 FORALL2(ParamListTypes a1,const char *a2,a1,a2)
336 FORALL1(IndexSections a1,a1)
337 FORALL2(const char *a1,const char *a2,a1,a2)
338 FORALL2(const char *a1,int a2,a1,a2)
339 FORALL2(const char *a1,SectionInfo::SectionType a2,a1,a2)
340 FORALL3(bool a1,HighlightedItem a2,const char *a3,a1,a2,a3)
341 FORALL3(bool a1,bool a2,bool a3,a1,a2,a3)
342 FORALL3(const ClassDiagram &a1,const char *a2,const char *a3,a1,a2,a3)
343 FORALL3(const char *a1,const char *a2,const char *a3,a1,a2,a3)
344 FORALL3(const char *a1,const char *a2,bool a3,a1,a2,a3)
345 FORALL3(const char *a1,int a2,const char *a3,a1,a2,a3)
346 FORALL3(const char *a1,const char *a2,SectionInfo::SectionType a3,a1,a2,a3)
347 FORALL3(uchar a1,uchar a2,uchar a3,a1,a2,a3)
348 FORALL3(Definition *a1,const char *a2,bool a3,a1,a2,a3)
349 FORALL4(SectionTypes a1,const char *a2,const char *a3,const char *a4,a1,a2,a3,a4)
350 FORALL4(const char *a1,const char *a2,const char *a3,const char *a4,a1,a2,a3,a4)
351 FORALL4(const char *a1,const char *a2,const char *a3,int a4,a1,a2,a3,a4)
352 FORALL5(const char *a1,const char *a2,const char *a3,const char *a4,const char *a5,a1,a2,a3,a4,a5)
353 FORALL5(const char *a1,const char *a2,const char *a3,const char *a4,bool a5,a1,a2,a3,a4,a5)
354 FORALL6(const char *a1,const char *a2,const char *a3,const char *a4,const char *a5,const char *a6,a1,a2,a3,a4,a5,a6)
355 FORALL6(const char *a1,const DocLinkInfo &a2,const char *a3,const char *a4,const SourceLinkInfo &a5,const SourceLinkInfo &a6,a1,a2,a3,a4,a5,a6)
356 
357 
358 //--------------------------------------------------------------------------
virtual bool isEnabled(OutputType o)=0
uint count() const
Definition: outputlist.h:61
virtual void enable()=0
#define a6
static QCString result
bool isEmpty() const
Definition: qcstring.h:189
void pushGeneratorState()
Definition: outputgen.cpp:63
void append(const type *d)
Definition: qlist.h:73
bool generateDoc(const char *fileName, int startLine, Definition *ctx, MemberDef *md, const QCString &docStr, bool indexWords, bool isExample, const char *exampleName=0, bool singleLine=FALSE, bool linkFromIndex=FALSE)
Definition: outputlist.cpp:131
void disableAllBut(OutputGenerator::OutputType o)
Definition: outputlist.cpp:49
#define FORALL5(a1, a2, a3, a4, a5, p1, p2, p3, p4, p5)
Definition: outputlist.cpp:266
DocText * validatingParseText(const char *input)
Definition: docparser.cpp:7381
IndexSections
Definition: index.h:157
const bool FALSE
Definition: qglobal.h:370
DocRoot * validatingParseDoc(const char *fileName, int startLine, Definition *ctx, MemberDef *md, const char *input, bool indexWords, bool isExample, const char *exampleName, bool singleLine, bool linkFromIndex)
Definition: docparser.cpp:7179
bool isEnabled(OutputGenerator::OutputType o)
Definition: outputlist.cpp:99
virtual ~OutputList()
Definition: outputlist.cpp:39
unsigned char uchar
Definition: nybbler.cc:11
bool parseText(const QCString &textStr)
Definition: outputlist.cpp:175
#define FORALL6(a1, a2, a3, a4, a5, a6, p1, p2, p3, p4, p5, p6)
Definition: outputlist.cpp:278
#define a5
#define FORALL4(a1, a2, a3, a4, p1, p2, p3, p4)
Definition: outputlist.cpp:254
void popGeneratorState()
Definition: outputlist.cpp:121
#define a2
static void setFlowMember(const MemberDef *flowMember)
Definition: vhdldocgen.cpp:90
#define a3
fileName
Definition: dumpTree.py:9
void pushGeneratorState()
Definition: outputlist.cpp:111
virtual void disableIfNot(OutputType o)=0
bool isEmpty() const
Definition: docparser.h:1396
void disable(OutputGenerator::OutputType o)
Definition: outputlist.cpp:79
type * current() const
Definition: qlist.h:146
void writeDoc(DocRoot *root, Definition *ctx, MemberDef *md)
Definition: outputlist.cpp:162
void enable(OutputGenerator::OutputType o)
Definition: outputlist.cpp:89
#define FORALL3(a1, a2, a3, p1, p2, p3)
Definition: outputlist.cpp:242
#define FORALL1(a1, p1)
Definition: outputlist.cpp:218
OutputList(bool)
Definition: outputlist.cpp:33
void add(const OutputGenerator *)
Definition: outputlist.cpp:44
void popGeneratorState()
Definition: outputgen.cpp:69
void enableAll()
Definition: outputlist.cpp:59
def func()
Definition: docstring.py:7
#define FORALL2(a1, a2, p1, p2)
Definition: outputlist.cpp:230
#define a4
bool isEmpty() const
Definition: docparser.h:1409
HighlightedItem
Definition: index.h:180
virtual void enableIf(OutputType o)=0
virtual void disable()=0
virtual void writeDoc(DocNode *, Definition *ctx, MemberDef *md)=0
void forall(void(OutputGenerator::*func)())
Definition: outputlist.cpp:207
void setAutoDelete(bool enable)
Definition: qlist.h:99
const bool TRUE
Definition: qglobal.h:371
virtual void disableIf(OutputType o)=0
#define a1
void disableAll()
Definition: outputlist.cpp:69
type * toFirst()
Definition: qlist.h:135
QList< OutputGenerator > m_outputs
Definition: outputlist.h:551