Doxygen
membergroup.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 #include "membergroup.h"
19 #include "memberlist.h"
20 #include "outputlist.h"
21 #include "util.h"
22 #include "classdef.h"
23 #include "namespacedef.h"
24 #include "filedef.h"
25 #include "language.h"
26 #include "groupdef.h"
27 #include "doxygen.h"
28 #include "docparser.h"
29 #include "entry.h"
30 #include "md5.h"
31 
32 MemberGroup::MemberGroup(const Definition *container,int id,const QCString &hdr,
33  const QCString &d,const QCString &docFile,int docLine,
35  : m_container(container),
36  memberList(std::make_unique<MemberList>(MemberListType_memberGroup,con)),
37  grpId(id), grpHeader(hdr), doc(d), m_docFile(docFile), m_docLine(docLine)
38 {
39  //printf("New member group id=%d header=%s desc=%s\n",id,hdr,d);
40  memberList->setNeedsSorting(Config_getBool(SORT_BRIEF_DOCS)); // detailed sections are already sorted elsewhere.
41  //printf("Member group docs='%s'\n",qPrint(doc));
42 }
43 
45 {
46 }
47 
49 {
50  //printf("MemberGroup::insertMember memberList=%p count=%d"
51  // " member section list: %p: md=%p:%s\n",
52  // memberList->first() ? memberList->first()->getSectionList() : 0,
53  // memberList->count(),
54  // md->getSectionList(),
55  // md,qPrint(md->name()));
56 
57  const MemberDef *firstMd = memberList->empty() ? 0 : memberList->front();
58  if (inSameSection && firstMd &&
60  {
62  }
63  else if (inDeclSection==0)
64  {
66  //printf("inDeclSection=%p type=%d\n",inDeclSection,inDeclSection->listType());
67  }
68  memberList->push_back(md);
69 
70  // copy the group of the first member in the memberGroup
71  GroupDef *gd;
72  if (firstMd && !firstMd->isAlias() && (gd=const_cast<GroupDef*>(firstMd->getGroupDef())))
73  {
75  if (mdm)
76  {
77  mdm->setGroupDef(gd, firstMd->getGroupPri(),
78  firstMd->getGroupFileName(),
79  firstMd->getGroupStartLine(),
80  firstMd->getGroupHasDocs());
81  }
82  gd->insertMember(md);
83  }
84 }
85 
86 
88 {
89  memberList->setAnchors();
90 }
91 
93  const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd,const GroupDef *gd,
94  bool showInline) const
95 {
96  //printf("MemberGroup::writeDeclarations() %s\n",qPrint(grpHeader));
97  QCString ldoc = doc;
98  if (!ldoc.isEmpty()) ldoc.prepend("<a name=\""+anchor()+"\" id=\""+anchor()+"\"></a>");
99  memberList->writeDeclarations(ol,cd,nd,fd,gd,grpHeader,ldoc,FALSE,showInline);
100 }
101 
103  const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd,const GroupDef *gd,
104  int indentLevel,const ClassDef *inheritedFrom,const QCString &inheritId
105  ) const
106 {
107  //printf("MemberGroup::writePlainDeclarations() memberList->count()=%d\n",memberList->count());
108  memberList->writePlainDeclarations(ol,inGroup,cd,nd,fd,gd,indentLevel,inheritedFrom,inheritId);
109 }
110 
112  const Definition *container,bool showEnumValues,bool showInline) const
113 {
114  //printf("MemberGroup::writeDocumentation() %s\n",qPrint(grpHeader));
115  memberList->writeDocumentation(ol,scopeName,container,QCString(),showEnumValues,showInline);
116 }
117 
119  const DefinitionMutable *container) const
120 {
121  memberList->writeDocumentationPage(ol,scopeName,container);
122 }
123 
125 {
126  memberList->setAnonymousEnumType();
127 }
128 
130  MemberListType lt,
131  const ClassDef *inheritedFrom,const QCString &inheritId) const
132 {
133  //printf("** addGroupedInheritedMembers()\n");
134  for (const auto &md : *memberList)
135  {
136  //printf("matching %d == %d\n",lt,md->getSectionList()->listType());
137  const MemberList *ml = md->getSectionList(m_container);
138  if (ml && lt==ml->listType())
139  {
141  mml.push_back(md);
142  mml.countDecMembers();
143  mml.writePlainDeclarations(ol,false,cd,0,0,0,0,inheritedFrom,inheritId);
144  }
145  }
146 }
147 
149 {
150  //printf("** countGroupedInheritedMembers()\n");
151  int count=0;
152  for (const auto &md : *memberList)
153  {
154  //printf("matching %d == %d\n",lt,md->getSectionList()->listType());
155  const MemberList *ml = md->getSectionList(m_container);
156  if (ml && lt==ml->listType())
157  {
158  count++;
159  }
160  }
161  return count;
162 }
163 
164 
165 /*! Add this group as a subsection of the declaration section, instead
166  * of rendering it in its own section
167  */
169 {
170  if (inDeclSection)
171  {
172  //printf("Adding group %p to list %p (type=%d) memberList=%p\n",this,
173  // inDeclSection,inDeclSection->listType(),memberList);
175  }
176 }
177 
179 {
180  memberList->countDecMembers();
181 }
182 
184 {
185  memberList->countDocMembers();
186 }
187 
189 {
190  return m_container;
191 }
192 
193 int MemberGroup::countInheritableMembers(const ClassDef *inheritedFrom) const
194 {
195  return memberList->countInheritableMembers(inheritedFrom);
196 }
197 
198 
200 {
201  //printf("MemberGroup::distributeMemberGroupDocumentation() %s\n",qPrint(grpHeader));
202  const MemberDef *md = 0;
203  for (const auto &smd : *memberList)
204  {
205  //printf("checking md=%s\n",qPrint(md->name()));
206  // find the first member of the group with documentation
207  if (!smd->documentation().isEmpty() ||
208  !smd->briefDescription().isEmpty() ||
209  !smd->inbodyDocumentation().isEmpty()
210  )
211  {
212  //printf("found it!\n");
213  md = smd;
214  break;
215  }
216  }
217  if (md) // distribute docs of md to other members of the list
218  {
219  //printf("Member %s has documentation!\n",qPrint(md->name()));
220  for (const auto &iomd : *memberList)
221  {
223  if (omd && md!=omd && omd->documentation().isEmpty() &&
224  omd->briefDescription().isEmpty() &&
226  )
227  {
228  //printf("Copying documentation to member %s\n",qPrint(omd->name()));
230  omd->setDocumentation(md->documentation(),md->docFile(),md->docLine());
232  }
233  }
234  }
235 }
236 
237 
239 {
240  return memberList->numDecMembers();
241 }
242 
244 {
245  return memberList->numDecEnumValues();
246 }
247 
249 {
250  return memberList->numDocMembers();
251 }
252 
254 {
255  return memberList->numDocEnumValues();
256 }
257 
259 {
260  uchar md5_sig[16];
261  char sigStr[33];
262  QCString locHeader = grpHeader;
263  if (locHeader.isEmpty()) locHeader="[NOHEADER]";
264  MD5Buffer((const unsigned char *)locHeader.data(),locHeader.length(),md5_sig);
265  MD5SigToString(md5_sig,sigStr);
266  return QCString("amgrp")+sigStr;
267 }
268 
270 {
271  memberList->addListReferences(def);
272  if (def)
273  {
274  QCString name = def->getOutputFileBase()+"#"+anchor();
276  name,
278  name,
279  grpHeader,QCString(),def);
280  }
281 }
282 
284 {
286  memberList->findSectionsInDocumentation(d);
287 }
288 
290 {
291  m_xrefListItems.insert(m_xrefListItems.end(), sli.cbegin(), sli.cend());
292 }
293 
295 {
296  memberList->writeTagFile(tagFile);
297 }
298 
299 //--------------------------------------------------------------------------
300 
302 {
303  m_sli.insert(m_sli.end(), sli.cbegin(), sli.cend());
304 }
MemberGroup::distributeMemberGroupDocumentation
void distributeMemberGroupDocumentation()
Definition: membergroup.cpp:199
MemberGroup::m_container
const Definition * m_container
Definition: membergroup.h:92
outputlist.h
MemberGroup::inDeclSection
MemberList * inDeclSection
Definition: membergroup.h:94
GroupDef::insertMember
virtual bool insertMember(const MemberDef *def, bool docOnly=FALSE)=0
MemberGroup::inSameSection
bool inSameSection
Definition: membergroup.h:99
Definition::docLine
virtual int docLine() const =0
MemberGroupInfo::m_sli
RefItemVector m_sli
Definition: membergroup.h:122
toMemberDefMutable
MemberDefMutable * toMemberDefMutable(Definition *d)
Definition: memberdef.cpp:6125
membergroup.h
MemberListType
MemberListType
Definition: types.h:100
MemberDef::briefDescription
virtual QCString briefDescription(bool abbr=FALSE) const =0
Definition
The common base class of all entity definitions found in the sources.
Definition: definition.h:76
MemberGroup::writeDeclarations
void writeDeclarations(OutputList &ol, const ClassDef *cd, const NamespaceDef *nd, const FileDef *fd, const GroupDef *gd, bool showInline=FALSE) const
Definition: membergroup.cpp:92
MemberDef::documentation
virtual QCString documentation() const =0
NamespaceDef
An abstract interface of a namespace symbol.
Definition: namespacedef.h:54
MemberGroup::countInheritableMembers
int countInheritableMembers(const ClassDef *inheritedFrom) const
Definition: membergroup.cpp:193
MemberGroup::numDecEnumValues
int numDecEnumValues() const
Definition: membergroup.cpp:243
MemberDef::getGroupPri
virtual Grouping::GroupPri_t getGroupPri() const =0
QCString::length
uint length() const
Returns the length of the string, not counting the 0-terminator.
Definition: qcstring.h:147
MemberDef::getGroupFileName
virtual QCString getGroupFileName() const =0
MemberGroup::anchor
QCString anchor() const
Definition: membergroup.cpp:258
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
MemberGroup::countDocMembers
void countDocMembers()
Definition: membergroup.cpp:183
namespacedef.h
MemberVector::push_back
void push_back(const MemberDef *md)
Definition: memberlist.h:42
MemberList::countDecMembers
void countDecMembers()
Definition: memberlist.cpp:116
MemberGroup::setAnchors
void setAnchors()
Definition: membergroup.cpp:87
Definition::inbodyLine
virtual int inbodyLine() const =0
MemberGroup::addListReferences
void addListReferences(Definition *d)
Definition: membergroup.cpp:269
TextStream
Text streaming class that buffers data.
Definition: textstream.h:33
Definition::briefLine
virtual int briefLine() const =0
MemberDefMutable::setBriefDescription
virtual void setBriefDescription(const QCString &b, const QCString &briefFile, int briefLine)=0
MemberDefMutable
Definition: memberdef.h:296
MemberGroup::writeDocumentation
void writeDocumentation(OutputList &ol, const QCString &scopeName, const Definition *container, bool showEnumValues, bool showInline) const
Definition: membergroup.cpp:111
Definition::docFile
virtual QCString docFile() const =0
GroupDef
A model of a group of symbols.
Definition: groupdef.h:49
MemberGroup::addGroupedInheritedMembers
void addGroupedInheritedMembers(OutputList &ol, const ClassDef *cd, MemberListType lt, const ClassDef *inheritedFrom, const QCString &inheritId) const
Definition: membergroup.cpp:129
OutputList
Class representing a list of output generators that are written to in parallel.
Definition: outputlist.h:37
MemberGroup::m_xrefListItems
RefItemVector m_xrefListItems
Definition: membergroup.h:102
entry.h
MemberDef
A model of a class/file/namespace member symbol.
Definition: memberdef.h:45
MemberGroup::writeDocumentationPage
void writeDocumentationPage(OutputList &ol, const QCString &scopeName, const DefinitionMutable *container) const
Definition: membergroup.cpp:118
ClassDef
A abstract class representing of a compound symbol.
Definition: classdef.h:103
uchar
unsigned char uchar
Definition: qcstring.h:38
MemberGroup::numDocMembers
int numDocMembers() const
Definition: membergroup.cpp:248
MemberList::listType
MemberListType listType() const
Definition: memberlist.h:86
MemberList::writePlainDeclarations
void writePlainDeclarations(OutputList &ol, bool inGroup, const ClassDef *cd, const NamespaceDef *nd, const FileDef *fd, const GroupDef *gd, int indentLevel, const ClassDef *inheritedFrom, const QCString &inheritId) const
Definition: memberlist.cpp:327
Definition::isAlias
virtual bool isAlias() const =0
MemberGroup::~MemberGroup
~MemberGroup()
Definition: membergroup.cpp:44
DefinitionMutable
Definition: definition.h:308
MemberDef::getGroupHasDocs
virtual bool getGroupHasDocs() const =0
theTranslator
Translator * theTranslator
Definition: language.cpp:156
Definition::inbodyDocumentation
virtual QCString inbodyDocumentation() const =0
MemberGroup::findSectionsInDocumentation
void findSectionsInDocumentation(const Definition *d)
Definition: membergroup.cpp:283
MemberGroup::grpHeader
QCString grpHeader
Definition: membergroup.h:96
doxygen.h
Definition::inbodyFile
virtual QCString inbodyFile() const =0
MemberDefMutable::setInbodyDocumentation
virtual void setInbodyDocumentation(const QCString &d, const QCString &inbodyFile, int inbodyLine)=0
language.h
MemberListContainer
MemberListContainer
Definition: types.h:196
MemberDefMutable::setGroupDef
virtual void setGroupDef(const GroupDef *gd, Grouping::GroupPri_t pri, const QCString &fileName, int startLine, bool hasDocs, MemberDef *member=0)=0
docparser.h
TRUE
#define TRUE
Definition: qcstring.h:36
Definition::getOutputFileBase
virtual QCString getOutputFileBase() const =0
filedef.h
MemberGroup::writePlainDeclarations
void writePlainDeclarations(OutputList &ol, bool inGroup, const ClassDef *cd, const NamespaceDef *nd, const FileDef *fd, const GroupDef *gd, int indentLevel, const ClassDef *inheritedFrom, const QCString &inheritId) const
Definition: membergroup.cpp:102
MemberGroup::container
const Definition * container() const
Definition: membergroup.cpp:188
memberlist.h
MemberGroup::MemberGroup
MemberGroup(const Definition *container, int id, const QCString &header, const QCString &docs, const QCString &docFile, int docLine, MemberListContainer con)
Definition: membergroup.cpp:32
addRefItem
void addRefItem(const RefItemVector &sli, const QCString &key, const QCString &prefix, const QCString &name, const QCString &title, const QCString &args, const Definition *scope)
Definition: util.cpp:4880
Definition::briefFile
virtual QCString briefFile() const =0
docFindSections
void docFindSections(const QCString &input, const Definition *d, const QCString &fileName)
Definition: docparser.cpp:7681
MemberGroup::numDecMembers
int numDecMembers() const
Definition: membergroup.cpp:238
MemberGroup::doc
QCString doc
Definition: membergroup.h:98
MemberDef::getSectionList
virtual const MemberList * getSectionList(const Definition *container) const =0
classdef.h
MemberGroup::setRefItems
void setRefItems(const RefItemVector &sli)
Definition: membergroup.cpp:289
RefItemVector
std::vector< RefItem * > RefItemVector
Definition: reflist.h:132
Config_getBool
#define Config_getBool(name)
Definition: config.h:33
MemberDefMutable::setDocumentation
virtual void setDocumentation(const QCString &d, const QCString &docFile, int docLine, bool stripWhiteSpace=TRUE)=0
MemberGroup::memberList
std::unique_ptr< MemberList > memberList
Definition: membergroup.h:93
MemberList::addMemberGroup
void addMemberGroup(MemberGroup *mg)
Definition: memberlist.cpp:826
MemberGroup::insertMember
void insertMember(const MemberDef *md)
Definition: membergroup.cpp:48
groupdef.h
QCString::data
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string
Definition: qcstring.h:153
MemberGroup::writeTagFile
void writeTagFile(TextStream &)
Definition: membergroup.cpp:294
FileDef
A model of a file symbol.
Definition: filedef.h:73
MemberGroup::addToDeclarationSection
void addToDeclarationSection()
Definition: membergroup.cpp:168
MemberDef::getGroupStartLine
virtual int getGroupStartLine() const =0
MemberGroupInfo::setRefItems
void setRefItems(const RefItemVector &sli)
Definition: membergroup.cpp:301
MemberGroup::m_docFile
QCString m_docFile
Definition: membergroup.h:100
util.h
A bunch of utility functions.
MemberListContainer::Class
@ Class
MemberList
A list of MemberDef objects as shown in documentation sections.
Definition: memberlist.h:81
MemberListType_memberGroup
@ MemberListType_memberGroup
Definition: types.h:181
MemberGroup::countDecMembers
void countDecMembers()
Definition: membergroup.cpp:178
QCString::prepend
QCString & prepend(const char *s)
Definition: qcstring.h:339
MemberGroup::numDocEnumValues
int numDocEnumValues() const
Definition: membergroup.cpp:253
MemberGroup::setAnonymousEnumType
void setAnonymousEnumType()
Definition: membergroup.cpp:124
MemberDef::getGroupDef
virtual const GroupDef * getGroupDef() const =0
MemberGroup::countGroupedInheritedMembers
int countGroupedInheritedMembers(MemberListType lt)
Definition: membergroup.cpp:148
Translator::trGroup
virtual QCString trGroup(bool first_capital, bool singular)=0
FALSE
#define FALSE
Definition: qcstring.h:33
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108