1 /******************************************************************************
5 * Copyright (C) 1997-2014 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.
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.
25 #include "outputlist.h"
26 #include "outputgen.h"
29 #include "definition.h"
30 #include "docparser.h"
31 #include "vhdldocgen.h"
33 OutputList::OutputList(bool)
35 //printf("OutputList::OutputList()\n");
36 m_outputs.setAutoDelete(TRUE);
39 OutputList::~OutputList()
41 //printf("OutputList::~OutputList()\n");
44 void OutputList::add(const OutputGenerator *og)
46 if (og) m_outputs.append(og);
49 void OutputList::disableAllBut(OutputGenerator::OutputType o)
51 QListIterator<OutputGenerator> it(m_outputs);
53 for (it.toFirst();(og=it.current());++it)
59 void OutputList::enableAll()
61 QListIterator<OutputGenerator> it(m_outputs);
63 for (it.toFirst();(og=it.current());++it)
69 void OutputList::disableAll()
71 QListIterator<OutputGenerator> it(m_outputs);
73 for (it.toFirst();(og=it.current());++it)
79 void OutputList::disable(OutputGenerator::OutputType o)
81 QListIterator<OutputGenerator> it(m_outputs);
83 for (it.toFirst();(og=it.current());++it)
89 void OutputList::enable(OutputGenerator::OutputType o)
91 QListIterator<OutputGenerator> it(m_outputs);
93 for (it.toFirst();(og=it.current());++it)
99 bool OutputList::isEnabled(OutputGenerator::OutputType o)
102 QListIterator<OutputGenerator> it(m_outputs);
104 for (it.toFirst();(og=it.current());++it)
106 result=result || og->isEnabled(o);
111 void OutputList::pushGeneratorState()
113 QListIterator<OutputGenerator> it(m_outputs);
115 for (it.toFirst();(og=it.current());++it)
117 og->pushGeneratorState();
121 void OutputList::popGeneratorState()
123 QListIterator<OutputGenerator> it(m_outputs);
125 for (it.toFirst();(og=it.current());++it)
127 og->popGeneratorState();
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)
138 if (docStr.isEmpty()) return TRUE;
140 QListIterator<OutputGenerator> it(m_outputs);
142 for (it.toFirst();(og=it.current());++it)
144 if (og->isEnabled()) count++;
146 if (count==0) return TRUE; // no output formats enabled.
149 root = validatingParseDoc(fileName,startLine,
150 ctx,md,docStr,indexWords,isExample,exampleName,
151 singleLine,linkFromIndex);
153 writeDoc(root,ctx,md);
155 bool isEmpty = root->isEmpty();
162 void OutputList::writeDoc(DocRoot *root,Definition *ctx,MemberDef *md)
164 QListIterator<OutputGenerator> it(m_outputs);
166 for (it.toFirst();(og=it.current());++it)
168 //printf("og->printDoc(extension=%s)\n",
169 // ctx?ctx->getDefFileExtension().data():"<null>");
170 if (og->isEnabled()) og->writeDoc(root,ctx,md);
173 VhdlDocGen::setFlowMember(0);
176 bool OutputList::parseText(const QCString &textStr)
179 QListIterator<OutputGenerator> it(m_outputs);
181 for (it.toFirst();(og=it.current());++it)
183 if (og->isEnabled()) count++;
185 if (count==0) return TRUE; // no output formats enabled.
187 DocText *root = validatingParseText(textStr);
189 for (it.toFirst();(og=it.current());++it)
191 if (og->isEnabled()) og->writeDoc(root,0,0);
194 bool isEmpty = root->isEmpty();
202 //--------------------------------------------------------------------------
203 // Create some overloaded definitions of the forall function.
204 // Using template functions here would have made it a little less
205 // portable (I guess).
208 void OutputList::forall(void (OutputGenerator::*func)())
210 QListIterator<OutputGenerator> it(m_outputs);
212 for (it.toFirst();(og=it.current());++it)
214 if (og->isEnabled()) (og->*func)();
219 #define FORALL1(a1,p1) \
220 void OutputList::forall(void (OutputGenerator::*func)(a1),a1) \
222 QListIterator<OutputGenerator> it(m_outputs); \
223 OutputGenerator *og; \
224 for (it.toFirst();(og=it.current());++it) \
226 if (og->isEnabled()) (og->*func)(p1); \
231 #define FORALL2(a1,a2,p1,p2) \
232 void OutputList::forall(void (OutputGenerator::*func)(a1,a2),a1,a2) \
234 QListIterator<OutputGenerator> it(m_outputs); \
235 OutputGenerator *og; \
236 for (it.toFirst();(og=it.current());++it) \
238 if (og->isEnabled()) (og->*func)(p1,p2); \
243 #define FORALL3(a1,a2,a3,p1,p2,p3) \
244 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3),a1,a2,a3) \
246 QListIterator<OutputGenerator> it(m_outputs); \
247 OutputGenerator *og; \
248 for (it.toFirst();(og=it.current());++it) \
250 if (og->isEnabled()) (og->*func)(p1,p2,p3); \
255 #define FORALL4(a1,a2,a3,a4,p1,p2,p3,p4) \
256 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3,a4),a1,a2,a3,a4) \
258 QListIterator<OutputGenerator> it(m_outputs); \
259 OutputGenerator *og; \
260 for (it.toFirst();(og=it.current());++it) \
262 if (og->isEnabled()) (og->*func)(p1,p2,p3,p4); \
267 #define FORALL5(a1,a2,a3,a4,a5,p1,p2,p3,p4,p5) \
268 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3,a4,a5),a1,a2,a3,a4,a5) \
270 QListIterator<OutputGenerator> it(m_outputs); \
271 OutputGenerator *og; \
272 for (it.toFirst();(og=it.current());++it) \
274 if (og->isEnabled()) (og->*func)(p1,p2,p3,p4,p5); \
279 #define FORALL6(a1,a2,a3,a4,a5,a6,p1,p2,p3,p4,p5,p6) \
280 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3,a4,a5,a6),a1,a2,a3,a4,a5,a6) \
282 QListIterator<OutputGenerator> it(m_outputs); \
283 OutputGenerator *og; \
284 for (it.toFirst();(og=it.current());++it) \
286 if (og->isEnabled()) (og->*func)(p1,p2,p3,p4,p5,p6); \
291 #define FORALL7(a1,a2,a3,a4,a5,a6,a7,p1,p2,p3,p4,p5,p6,p7) \
292 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3,a4,a5,a6,a7),a1,a2,a3,a4,a5,a6,a7) \
294 QListIterator<OutputGenerator> it(m_outputs); \
295 OutputGenerator *og; \
296 for (it.toFirst();(og=it.current());++it) \
298 if (og->isEnabled()) (og->*func)(p1,p2,p3,p4,p5,p6,p7); \
304 #define FORALL8(a1,a2,a3,a4,a5,a6,a7,a8,p1,p2,p3,p4,p5,p6,p7,p8) \
305 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3,a4,a5,a6,a7,a8),a1,a2,a3,a4,a5,a6,a7,a8) \
307 QListIterator<OutputGenerator> it(m_outputs); \
308 OutputGenerator *og; \
309 for (it.toFirst();(og=it.current());++it) \
311 if (og->isEnabled()) (og->*func)(p1,p2,p3,p4,p5,p6,p7,p8); \
315 // now instantiate only the ones we need.
317 FORALL1(const char *a1,a1)
320 FORALL1(const DotClassGraph &a1,a1)
321 FORALL1(const DotInclDepGraph &a1,a1)
322 FORALL1(const DotCallGraph &a1,a1)
323 FORALL1(const DotDirDeps &a1,a1)
324 FORALL1(const DotGfxHierarchyTable &a1,a1)
325 FORALL1(const DotGroupCollaboration &a1,a1)
326 FORALL1(SectionTypes a1,a1)
327 #if defined(HAS_BOOL_TYPE) || defined(Q_HAS_BOOL_TYPE)
329 FORALL2(bool a1,int a2,a1,a2)
330 FORALL2(bool a1,bool a2,a1,a2)
331 FORALL2(const char *a1,bool a2,a1,a2)
332 FORALL4(const char *a1,const char *a2,const char *a3,bool a4,a1,a2,a3,a4)
334 FORALL2(int a1,bool a2,a1,a2)
335 FORALL2(bool a1,const char *a2,a1,a2)
336 FORALL2(ParamListTypes a1,const char *a2,a1,a2)
337 FORALL1(IndexSections a1,a1)
338 FORALL2(const char *a1,const char *a2,a1,a2)
339 FORALL2(const char *a1,int a2,a1,a2)
340 FORALL2(const char *a1,SectionInfo::SectionType a2,a1,a2)
341 FORALL3(bool a1,HighlightedItem a2,const char *a3,a1,a2,a3)
342 FORALL3(bool a1,bool a2,bool a3,a1,a2,a3)
343 FORALL3(const ClassDiagram &a1,const char *a2,const char *a3,a1,a2,a3)
344 FORALL3(const char *a1,const char *a2,const char *a3,a1,a2,a3)
345 FORALL3(const char *a1,const char *a2,bool a3,a1,a2,a3)
346 FORALL3(const char *a1,int a2,const char *a3,a1,a2,a3)
347 FORALL3(const char *a1,const char *a2,SectionInfo::SectionType a3,a1,a2,a3)
348 FORALL3(uchar a1,uchar a2,uchar a3,a1,a2,a3)
349 FORALL3(Definition *a1,const char *a2,bool a3,a1,a2,a3)
350 FORALL4(SectionTypes 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,const char *a4,a1,a2,a3,a4)
352 FORALL4(const char *a1,const char *a2,const char *a3,int a4,a1,a2,a3,a4)
353 FORALL5(const char *a1,const char *a2,const char *a3,const char *a4,const char *a5,a1,a2,a3,a4,a5)
354 FORALL5(const char *a1,const char *a2,const char *a3,const char *a4,bool a5,a1,a2,a3,a4,a5)
355 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)
356 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)
359 //--------------------------------------------------------------------------