1 /******************************************************************************
3 * $Id: outputlist.cpp,v 1.35 2001/03/19 19:27:41 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.
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"
31 #include "docparser.h"
33 OutputList::OutputList(bool)
35 //printf("OutputList::OutputList()\n");
36 outputs = new QList<OutputGenerator>;
37 outputs->setAutoDelete(TRUE);
40 OutputList::~OutputList()
42 //printf("OutputList::~OutputList()\n");
46 void OutputList::add(const OutputGenerator *og)
48 if (og) outputs->append(og);
51 void OutputList::disableAllBut(OutputGenerator::OutputType o)
53 OutputGenerator *og=outputs->first();
61 void OutputList::enableAll()
63 OutputGenerator *og=outputs->first();
71 void OutputList::disableAll()
73 OutputGenerator *og=outputs->first();
81 void OutputList::disable(OutputGenerator::OutputType o)
83 OutputGenerator *og=outputs->first();
91 void OutputList::enable(OutputGenerator::OutputType o)
93 OutputGenerator *og=outputs->first();
101 bool OutputList::isEnabled(OutputGenerator::OutputType o)
104 OutputGenerator *og=outputs->first();
107 result=result || og->isEnabled(o);
113 void OutputList::pushGeneratorState()
115 OutputGenerator *og=outputs->first();
118 og->pushGeneratorState();
123 void OutputList::popGeneratorState()
125 OutputGenerator *og=outputs->first();
128 og->popGeneratorState();
133 void OutputList::parseDoc(const char *fileName,int startLine,
134 Definition *ctx,MemberDef * md,
135 const QCString &docStr,bool indexWords,
136 bool isExample,const char *exampleName,
137 bool singleLine,bool linkFromIndex)
140 if (docStr.isEmpty()) return;
142 OutputGenerator *og=outputs->first();
145 if (og->isEnabled()) count++;
148 if (count==0) return; // no output formats enabled.
151 if (docStr.at(docStr.length()-1)=='\n')
153 root = validatingParseDoc(fileName,startLine,
154 ctx,md,docStr,indexWords,isExample,exampleName,
155 singleLine,linkFromIndex);
159 root = validatingParseDoc(fileName,startLine,
160 ctx,md,docStr+"\n",indexWords,isExample,exampleName,
161 singleLine,linkFromIndex);
167 //printf("og->printDoc(extension=%s)\n",
168 // ctx?ctx->getDefFileExtension().data():"<null>");
169 if (og->isEnabled()) og->writeDoc(root,ctx,md);
176 void OutputList::parseText(const QCString &textStr)
179 OutputGenerator *og=outputs->first();
182 if (og->isEnabled()) count++;
185 if (count==0) return; // no output formats enabled.
187 DocNode *root = validatingParseText(textStr);
192 if (og->isEnabled()) og->writeDoc(root,0,0);
200 //--------------------------------------------------------------------------
201 // Create some overloaded definitions of the forall function.
202 // Using template functions here would have made it a little less
203 // portable (I guess).
206 void OutputList::forall(void (OutputGenerator::*func)())
208 OutputGenerator *og=outputs->first();
211 if (og->isEnabled()) (og->*func)();
217 #define FORALL1(a1,p1) \
218 void OutputList::forall(void (OutputGenerator::*func)(a1),a1) \
220 OutputGenerator *og=outputs->first(); \
223 if (og->isEnabled()) (og->*func)(p1); \
224 og=outputs->next(); \
229 #define FORALL2(a1,a2,p1,p2) \
230 void OutputList::forall(void (OutputGenerator::*func)(a1,a2),a1,a2) \
232 OutputGenerator *og=outputs->first(); \
235 if (og->isEnabled()) (og->*func)(p1,p2); \
236 og=outputs->next(); \
241 #define FORALL3(a1,a2,a3,p1,p2,p3) \
242 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3),a1,a2,a3) \
244 OutputGenerator *og=outputs->first(); \
247 if (og->isEnabled()) (og->*func)(p1,p2,p3); \
248 og=outputs->next(); \
253 #define FORALL4(a1,a2,a3,a4,p1,p2,p3,p4) \
254 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3,a4),a1,a2,a3,a4) \
256 OutputGenerator *og=outputs->first(); \
259 if (og->isEnabled()) (og->*func)(p1,p2,p3,p4); \
260 og=outputs->next(); \
265 #define FORALL5(a1,a2,a3,a4,a5,p1,p2,p3,p4,p5) \
266 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3,a4,a5),a1,a2,a3,a4,a5) \
268 OutputGenerator *og=outputs->first(); \
271 if (og->isEnabled()) (og->*func)(p1,p2,p3,p4,p5); \
272 og=outputs->next(); \
277 #define FORALL6(a1,a2,a3,a4,a5,a6,p1,p2,p3,p4,p5,p6) \
278 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3,a4,a5,a6),a1,a2,a3,a4,a5,a6) \
280 OutputGenerator *og=outputs->first(); \
283 if (og->isEnabled()) (og->*func)(p1,p2,p3,p4,p5,p6); \
284 og=outputs->next(); \
288 // now instantiate only the ones we need.
290 FORALL1(const char *a1,a1)
293 FORALL1(const DotClassGraph &a1,a1)
294 FORALL1(const DotInclDepGraph &a1,a1)
295 FORALL1(const DotCallGraph &a1,a1)
296 FORALL1(const DotDirDeps &a1,a1)
297 FORALL1(const DotGfxHierarchyTable &a1,a1)
298 FORALL1(const DotGroupCollaboration &a1,a1)
299 FORALL1(SectionTypes a1,a1)
300 #if defined(HAS_BOOL_TYPE) || defined(Q_HAS_BOOL_TYPE)
302 FORALL2(bool a1,int a2,a1,a2)
303 FORALL2(bool a1,bool a2,a1,a2)
304 FORALL2(const char *a1,bool a2,a1,a2)
305 FORALL4(const char *a1,const char *a2,const char *a3,bool a4,a1,a2,a3,a4)
307 FORALL2(int a1,bool a2,a1,a2)
308 FORALL2(bool a1,const char *a2,a1,a2)
309 FORALL2(ParamListTypes a1,const char *a2,a1,a2)
310 FORALL1(IndexSections a1,a1)
311 FORALL2(const char *a1,const char *a2,a1,a2)
312 FORALL2(const char *a1,int a2,a1,a2)
313 FORALL2(const char *a1,SectionInfo::SectionType a2,a1,a2)
314 FORALL3(bool a1,HighlightedItem a2,const char *a3,a1,a2,a3)
315 FORALL3(bool a1,bool a2,bool a3,a1,a2,a3)
316 FORALL3(const ClassDiagram &a1,const char *a2,const char *a3,a1,a2,a3)
317 FORALL3(const char *a1,const char *a2,const char *a3,a1,a2,a3)
318 FORALL3(const char *a1,const char *a2,bool a3,a1,a2,a3)
319 FORALL3(const char *a1,int a2,const char *a3,a1,a2,a3)
320 FORALL3(const char *a1,const char *a2,SectionInfo::SectionType a3,a1,a2,a3)
321 FORALL3(uchar a1,uchar a2,uchar a3,a1,a2,a3)
322 FORALL4(SectionTypes a1,const char *a2,const char *a3,const char *a4,a1,a2,a3,a4)
323 FORALL4(const char *a1,const char *a2,const char *a3,const char *a4,a1,a2,a3,a4)
324 FORALL4(const char *a1,const char *a2,const char *a3,int a4,a1,a2,a3,a4)
325 FORALL5(const char *a1,const char *a2,const char *a3,const char *a4,const char *a5,a1,a2,a3,a4,a5)
326 FORALL5(const char *a1,const char *a2,const char *a3,const char *a4,bool a5,a1,a2,a3,a4,a5)
327 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)
330 //--------------------------------------------------------------------------