summaryrefslogtreecommitdiffstats
path: root/src/outputlist.cpp
blob: e4f0fe23abc1577ce5e56f75b92d575003edd94d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/******************************************************************************
 *
 *
 *
 * Copyright (C) 1997-2015 by Dimitri van Heesch.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation under the terms of the GNU General Public License is hereby
 * granted. No representations are made about the suitability of this software
 * for any purpose. It is provided "as is" without express or implied warranty.
 * See the GNU General Public License for more details.
 *
 * Documents produced by Doxygen are derivative works derived from the
 * input used in their production; they are not affected by this license.
 *
 */

/*! \file
 *  This class represents a list of output generators that work in "parallel".
 *  The class only knows about the abstract base class OutputGenerators.
 *  All output is produced by calling a method of this class, which forwards
 *  the call to all output generators.
 */

#include <atomic>

#include "outputlist.h"
#include "outputgen.h"
#include "config.h"
#include "message.h"
#include "definition.h"
#include "docparser.h"
#include "vhdldocgen.h"
#include "doxygen.h"

static AtomicInt g_outId;

OutputList::OutputList()
{
  newId();
  //printf("OutputList::OutputList()\n");
}

OutputList::OutputList(const OutputList &ol)
{
  m_id = ol.m_id;
  for (const auto &og : ol.m_outputs)
  {
    m_outputs.emplace_back(og->clone());
  }
}

OutputList &OutputList::operator=(const OutputList &ol)
{
  if (this!=&ol)
  {
    m_id = ol.m_id;
    for (const auto &og : ol.m_outputs)
    {
      m_outputs.emplace_back(og->clone());
    }
  }
  return *this;
}

OutputList::~OutputList()
{
  //printf("OutputList::~OutputList()\n");
}

void OutputList::newId()
{
  m_id = ++g_outId;
}

void OutputList::disableAllBut(OutputGenerator::OutputType o)
{
  for (const auto &og : m_outputs)
  {
    og->disableIfNot(o);
  }
}

void OutputList::enableAll()
{
  for (const auto &og : m_outputs)
  {
    og->enable();
  }
}

void OutputList::disableAll()
{
  for (const auto &og : m_outputs)
  {
    og->disable();
  }
}

void OutputList::disable(OutputGenerator::OutputType o)
{
  for (const auto &og : m_outputs)
  {
    og->disableIf(o);
  }
}

void OutputList::enable(OutputGenerator::OutputType o)
{
  for (const auto &og : m_outputs)
  {
    og->enableIf(o);
  }
}

bool OutputList::isEnabled(OutputGenerator::OutputType o)
{
  bool result=FALSE;
  for (const auto &og : m_outputs)
  {
    result=result || og->isEnabled(o);
  }
  return result;
}

void OutputList::pushGeneratorState()
{
  for (const auto &og : m_outputs)
  {
    og->pushGeneratorState();
  }
}

void OutputList::popGeneratorState()
{
  for (const auto &og : m_outputs)
  {
    og->popGeneratorState();
  }
}

void OutputList::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)
{
  int count=0;
  if (docStr.isEmpty()) return;

  for (const auto &og : m_outputs)
  {
    if (og->isEnabled()) count++;
  }

  // we want to validate irrespective of the number of output formats
  // specified as:
  // - when only XML format there should be warnings as well (XML has its own write routines)
  // - no formats there should be warnings as well
  DocRoot *root=0;
  root = validatingParseDoc(fileName,startLine,
                            ctx,md,docStr,indexWords,isExample,exampleName,
                            singleLine,linkFromIndex,markdownSupport);
  if (count>0) writeDoc(root,ctx,md,m_id);
  delete root;
}

void OutputList::writeDoc(DocRoot *root,const Definition *ctx,const MemberDef *md,int)
{
  for (const auto &og : m_outputs)
  {
    //printf("og->printDoc(extension=%s)\n",
    //    ctx?qPrint(ctx->getDefFileExtension()):"<null>");
    if (og->isEnabled()) og->writeDoc(root,ctx,md,m_id);
  }
  VhdlDocGen::setFlowMember(0);
}

void OutputList::parseText(const QCString &textStr)
{
  int count=0;
  for (const auto &og : m_outputs)
  {
    if (og->isEnabled()) count++;
  }

  // we want to validate irrespective of the number of output formats
  // specified as:
  // - when only XML format there should be warnings as well (XML has its own write routines)
  // - no formats there should be warnings as well
  DocText *root = validatingParseText(textStr);

  if (count>0)
  {
    for (const auto &og : m_outputs)
    {
      if (og->isEnabled()) og->writeDoc(root,0,0,m_id);
    }
  }

  delete root;
}

//--------------------------------------------------------------------------