My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
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");
36  m_outputs.setAutoDelete(TRUE);
37 }
38 
40 {
41  //printf("OutputList::~OutputList()\n");
42 }
43 
45 {
46  if (og) m_outputs.append(og);
47 }
48 
50 {
51  QListIterator<OutputGenerator> it(m_outputs);
52  OutputGenerator *og;
53  for (it.toFirst();(og=it.current());++it)
54  {
55  og->disableIfNot(o);
56  }
57 }
58 
60 {
61  QListIterator<OutputGenerator> it(m_outputs);
62  OutputGenerator *og;
63  for (it.toFirst();(og=it.current());++it)
64  {
65  og->enable();
66  }
67 }
68 
70 {
71  QListIterator<OutputGenerator> it(m_outputs);
72  OutputGenerator *og;
73  for (it.toFirst();(og=it.current());++it)
74  {
75  og->disable();
76  }
77 }
78 
80 {
81  QListIterator<OutputGenerator> it(m_outputs);
82  OutputGenerator *og;
83  for (it.toFirst();(og=it.current());++it)
84  {
85  og->disableIf(o);
86  }
87 }
88 
90 {
91  QListIterator<OutputGenerator> it(m_outputs);
92  OutputGenerator *og;
93  for (it.toFirst();(og=it.current());++it)
94  {
95  og->enableIf(o);
96  }
97 }
98 
100 {
101  bool result=FALSE;
102  QListIterator<OutputGenerator> it(m_outputs);
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 {
113  QListIterator<OutputGenerator> it(m_outputs);
114  OutputGenerator *og;
115  for (it.toFirst();(og=it.current());++it)
116  {
117  og->pushGeneratorState();
118  }
119 }
120 
122 {
123  QListIterator<OutputGenerator> it(m_outputs);
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 
140  QListIterator<OutputGenerator> it(m_outputs);
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 {
164  QListIterator<OutputGenerator> it(m_outputs);
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;
178  QListIterator<OutputGenerator> it(m_outputs);
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
207 void OutputList::forall(void (OutputGenerator::*func)())
208 {
209  QListIterator<OutputGenerator> it(m_outputs);
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)
319 FORALL1(const DotClassGraph &a1,a1)
320 FORALL1(const DotInclDepGraph &a1,a1)
321 FORALL1(const DotCallGraph &a1,a1)
322 FORALL1(const DotDirDeps &a1,a1)
323 FORALL1(const DotGfxHierarchyTable &a1,a1)
324 FORALL1(const DotGroupCollaboration &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 FORALL7(const char *a1,const char *a2,const char *a3,const char *a4,int a5,int a6,bool a7,a1,a2,a3,a4,a5,a6,a7)
357 
358 
359 //--------------------------------------------------------------------------