Doxygen
outputlist.cpp
浏览该文件的文档.
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 <atomic>
26 
27 #include "outputlist.h"
28 #include "outputgen.h"
29 #include "config.h"
30 #include "message.h"
31 #include "definition.h"
32 #include "docparser.h"
33 #include "vhdldocgen.h"
34 #include "doxygen.h"
35 
37 
39 {
40  newId();
41  //printf("OutputList::OutputList()\n");
42 }
43 
45 {
46  m_id = ol.m_id;
47  for (const auto &og : ol.m_outputs)
48  {
49  m_outputs.emplace_back(og->clone());
50  }
51 }
52 
54 {
55  if (this!=&ol)
56  {
57  m_id = ol.m_id;
58  for (const auto &og : ol.m_outputs)
59  {
60  m_outputs.emplace_back(og->clone());
61  }
62  }
63  return *this;
64 }
65 
67 {
68  //printf("OutputList::~OutputList()\n");
69 }
70 
72 {
73  m_id = ++g_outId;
74 }
75 
77 {
78  for (const auto &og : m_outputs)
79  {
80  og->disableIfNot(o);
81  }
82 }
83 
85 {
86  for (const auto &og : m_outputs)
87  {
88  og->enable();
89  }
90 }
91 
93 {
94  for (const auto &og : m_outputs)
95  {
96  og->disable();
97  }
98 }
99 
101 {
102  for (const auto &og : m_outputs)
103  {
104  og->disableIf(o);
105  }
106 }
107 
109 {
110  for (const auto &og : m_outputs)
111  {
112  og->enableIf(o);
113  }
114 }
115 
117 {
118  bool result=FALSE;
119  for (const auto &og : m_outputs)
120  {
121  result=result || og->isEnabled(o);
122  }
123  return result;
124 }
125 
127 {
128  for (const auto &og : m_outputs)
129  {
130  og->pushGeneratorState();
131  }
132 }
133 
135 {
136  for (const auto &og : m_outputs)
137  {
138  og->popGeneratorState();
139  }
140 }
141 
142 void OutputList::generateDoc(const QCString &fileName,int startLine,
143  const Definition *ctx,const MemberDef * md,
144  const QCString &docStr,bool indexWords,
145  bool isExample,const QCString &exampleName,
146  bool singleLine,bool linkFromIndex,
147  bool markdownSupport)
148 {
149  int count=0;
150  if (docStr.isEmpty()) return;
151 
152  for (const auto &og : m_outputs)
153  {
154  if (og->isEnabled()) count++;
155  }
156 
157  // we want to validate irrespective of the number of output formats
158  // specified as:
159  // - when only XML format there should be warnings as well (XML has its own write routines)
160  // - no formats there should be warnings as well
161  std::unique_ptr<IDocParser> parser { createDocParser() };
162  std::unique_ptr<DocRoot> root { validatingParseDoc(*parser.get(),
163  fileName,startLine,
164  ctx,md,docStr,indexWords,isExample,exampleName,
165  singleLine,linkFromIndex,markdownSupport) };
166  if (count>0) writeDoc(root.get(),ctx,md,m_id);
167 }
168 
169 void OutputList::writeDoc(DocRoot *root,const Definition *ctx,const MemberDef *md,int)
170 {
171  for (const auto &og : m_outputs)
172  {
173  //printf("og->printDoc(extension=%s)\n",
174  // ctx?qPrint(ctx->getDefFileExtension()):"<null>");
175  if (og->isEnabled()) og->writeDoc(root,ctx,md,m_id);
176  }
177 }
178 
179 void OutputList::parseText(const QCString &textStr)
180 {
181  int count=0;
182  for (const auto &og : m_outputs)
183  {
184  if (og->isEnabled()) count++;
185  }
186 
187  // we want to validate irrespective of the number of output formats
188  // specified as:
189  // - when only XML format there should be warnings as well (XML has its own write routines)
190  // - no formats there should be warnings as well
191  std::unique_ptr<IDocParser> parser { createDocParser() };
192  std::unique_ptr<DocText> root { validatingParseText(*parser.get(), textStr) };
193 
194  if (count>0)
195  {
196  for (const auto &og : m_outputs)
197  {
198  if (og->isEnabled()) og->writeDoc(root.get(),0,0,m_id);
199  }
200  }
201 }
202 
203 //--------------------------------------------------------------------------
OutputList::disableAllBut
void disableAllBut(OutputGenerator::OutputType o)
Definition: outputlist.cpp:76
outputlist.h
Definition
The common base class of all entity definitions found in the sources.
Definition: definition.h:76
DocRoot
Root node of documentation tree
Definition: docparser.h:1457
g_outId
static AtomicInt g_outId
Definition: outputlist.cpp:36
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
AtomicInt
#define AtomicInt
Definition: doxygen.h:28
OutputList::writeDoc
void writeDoc(DocRoot *root, const Definition *ctx, const MemberDef *md, int id=0)
Definition: outputlist.cpp:169
OutputList::~OutputList
virtual ~OutputList()
Definition: outputlist.cpp:66
OutputList::disableAll
void disableAll()
Definition: outputlist.cpp:92
OutputList
Class representing a list of output generators that are written to in parallel.
Definition: outputlist.h:37
outputgen.h
MemberDef
A model of a class/file/namespace member symbol.
Definition: memberdef.h:45
OutputList::disable
void disable(OutputGenerator::OutputType o)
Definition: outputlist.cpp:100
message.h
OutputList::newId
void newId()
Definition: outputlist.cpp:71
doxygen.h
validatingParseDoc
DocRoot * validatingParseDoc(IDocParser &parserIntf, const QCString &fileName, int startLine, const Definition *ctx, const MemberDef *md, const QCString &input, bool indexWords, bool isExample, const QCString &exampleName, bool singleLine, bool linkFromIndex, bool markdownSupport)
Definition: docparser.cpp:7495
docparser.h
OutputList::m_id
int m_id
Definition: outputlist.h:517
OutputList::enableAll
void enableAll()
Definition: outputlist.cpp:84
OutputList::isEnabled
bool isEnabled(OutputGenerator::OutputType o)
Definition: outputlist.cpp:116
validatingParseText
DocText * validatingParseText(IDocParser &parserIntf, const QCString &input)
Definition: docparser.cpp:7621
OutputList::popGeneratorState
void popGeneratorState()
Definition: outputlist.cpp:134
OutputList::OutputList
OutputList()
Definition: outputlist.cpp:38
OutputList::operator=
OutputList & operator=(const OutputList &ol)
Definition: outputlist.cpp:53
OutputList::m_outputs
std::vector< std::unique_ptr< OutputGenerator > > m_outputs
Definition: outputlist.h:516
definition.h
OutputList::parseText
void parseText(const QCString &textStr)
Definition: outputlist.cpp:179
OutputList::generateDoc
void generateDoc(const QCString &fileName, int startLine, const Definition *ctx, const MemberDef *md, const QCString &docStr, bool indexWords, bool isExample, const QCString &exampleName, bool singleLine, bool linkFromIndex, bool markdownSupport)
Definition: outputlist.cpp:142
config.h
OutputList::pushGeneratorState
void pushGeneratorState()
Definition: outputlist.cpp:126
OutputGenerator::OutputType
OutputType
Definition: outputgen.h:333
OutputList::enable
void enable(OutputGenerator::OutputType o)
Definition: outputlist.cpp:108
vhdldocgen.h
createDocParser
std::unique_ptr< IDocParser > createDocParser()
Definition: docparser.cpp:179
FALSE
#define FALSE
Definition: qcstring.h:33
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108