membergroup.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 
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 "marshal.h"
30 #include "entry.h"
31 #include "md5.h"
32 
33 //static QCString idToName(int id)
34 //{
35 // QCString result;
36 // result.sprintf("mgroup_%d",id);
37 // return result;
38 //}
39 
41 {
42 }
43 
45  int id,const char *hdr,const char *d,const char *docFile,int docLine)
46 {
47  //printf("New member group id=%d header=%s desc=%s\n",id,hdr,d);
49  grpId = id;
50  grpHeader = hdr;
51  doc = d;
52  scope = 0;
54  inDeclSection = 0;
55  m_numDecMembers = -1;
56  m_numDocMembers = -1;
57  m_parent = parent;
60  m_xrefListItems = 0;
61  //printf("Member group docs=`%s'\n",doc.data());
62 }
63 
65 {
66  delete memberList;
67 }
68 
70 {
71  //printf("MemberGroup::insertMember m_parent=%s memberList=%p count=%d"
72  // " member section list: %p: md=%p:%s\n",
73  // m_parent ? m_parent->name().data() : "<null>",
74  // memberList->first() ? memberList->first()->getSectionList(m_parent) : 0,
75  // memberList->count(),
76  // md->getSectionList(m_parent),
77  // md,md->name().data());
78 
79  MemberDef *firstMd = memberList->getFirst();
80  if (inSameSection && firstMd &&
82  {
84  }
85  else if (inDeclSection==0)
86  {
88  //printf("inDeclSection=%p type=%d\n",inDeclSection,inDeclSection->listType());
89  }
90  memberList->append(md);
91 
92  // copy the group of the first member in the memberGroup
93  GroupDef *gd;
94  if (firstMd && (gd=firstMd->getGroupDef()))
95  {
96  md->setGroupDef(gd, firstMd->getGroupPri(),
97  firstMd->getGroupFileName(), firstMd->getGroupStartLine(),
98  firstMd->getGroupHasDocs());
99  gd->insertMember(md);
100  }
101 }
102 
103 
105 {
107 }
108 
110  ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
111  bool showInline)
112 {
113  //printf("MemberGroup::writeDeclarations() %s\n",grpHeader.data());
114  QCString ldoc = doc;
115  if (!ldoc.isEmpty()) ldoc.prepend("<a name=\""+anchor()+"\" id=\""+anchor()+"\"></a>");
116  memberList->writeDeclarations(ol,cd,nd,fd,gd,grpHeader,ldoc,FALSE,showInline);
117 }
118 
120  ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
121  ClassDef *inheritedFrom,const char *inheritId
122  )
123 {
124  //printf("MemberGroup::writePlainDeclarations() memberList->count()=%d\n",memberList->count());
125  memberList->writePlainDeclarations(ol,cd,nd,fd,gd,inheritedFrom,inheritId);
126 }
127 
128 void MemberGroup::writeDocumentation(OutputList &ol,const char *scopeName,
129  Definition *container,bool showEnumValues,bool showInline)
130 {
131  memberList->writeDocumentation(ol,scopeName,container,0,showEnumValues,showInline);
132 }
133 
134 void MemberGroup::writeDocumentationPage(OutputList &ol,const char *scopeName,
135  Definition *container)
136 {
137  memberList->writeDocumentationPage(ol,scopeName,container);
138 }
139 
141  MemberListType lt,
142  ClassDef *inheritedFrom,const QCString &inheritId)
143 {
144  //printf("** addGroupedInheritedMembers()\n");
146  MemberDef *md;
147  for (li.toFirst();(md=li.current());++li)
148  {
149  //printf("matching %d == %d\n",lt,md->getSectionList(m_parent)->listType());
150  if (lt==md->getSectionList(m_parent)->listType())
151  {
152  MemberList ml(lt);
153  ml.append(md);
154  ml.writePlainDeclarations(ol,cd,0,0,0,inheritedFrom,inheritId);
155  }
156  }
157 }
158 
160 {
161  //printf("** countGroupedInheritedMembers()\n");
162  int count=0;
164  MemberDef *md;
165  for (li.toFirst();(md=li.current());++li)
166  {
167  //printf("matching %d == %d\n",lt,md->getSectionList(m_parent)->listType());
168  if (lt==md->getSectionList(m_parent)->listType())
169  {
170  count++;
171  }
172  }
173  return count;
174 }
175 
176 
177 /*! Add this group as a subsection of the declaration section, instead
178  * of rendering it in its own section
179  */
181 {
182  if (inDeclSection)
183  {
184  //printf("Adding group %p to list %p (type=%d)\n",this,
185  // inDeclSection,inDeclSection->listType());
187  }
188 }
189 
191 {
192  if (m_numDecMembers==-1) /* number of member not cached */
193  {
196  }
197  return m_numDecMembers;
198 }
199 
201 {
202  if (m_numDocMembers==-1)
203  {
206  }
207  return m_numDocMembers;
208 }
209 
211 {
212  return memberList->countInheritableMembers(inheritedFrom);
213 }
214 
215 
217 {
218  //printf("MemberGroup::distributeMemberGroupDocumentation() %s\n",grpHeader.data());
220  MemberDef *md;
221  for (li.toFirst();(md=li.current());++li)
222  {
223  //printf("checking md=%s\n",md->name().data());
224  // find the first member of the group with documentation
225  if (!md->documentation().isEmpty() ||
226  !md->briefDescription().isEmpty() ||
228  )
229  {
230  //printf("found it!\n");
231  break;
232  }
233  }
234  if (md) // distribute docs of md to other members of the list
235  {
236  //printf("Member %s has documentation!\n",md->name().data());
237  MemberDef *omd;
238  for (li.toFirst();(omd=li.current());++li)
239  {
240  if (md!=omd && omd->documentation().isEmpty() &&
241  omd->briefDescription().isEmpty() &&
243  )
244  {
245  //printf("Copying documentation to member %s\n",omd->name().data());
247  omd->setDocumentation(md->documentation(),md->docFile(),md->docLine());
249  }
250  }
251  }
252 }
253 
255 {
256  return memberList->varCount();
257 }
258 
260 {
261  return memberList->funcCount();
262 }
263 
265 {
266  return memberList->enumCount();
267 }
268 
270 {
271  return memberList->enumValueCount();
272 }
273 
275 {
276  return memberList->typedefCount();
277 }
278 
280 {
281  return memberList->protoCount();
282 }
283 
285 {
286  return memberList->defineCount();
287 }
288 
290 {
291  return memberList->friendCount();
292 }
293 
295 {
296  return memberList->numDecMembers();
297 }
298 
300 {
301  return memberList->numDocMembers();
302 }
303 
305 {
307 }
308 
310 {
311  uchar md5_sig[16];
312  QCString sigStr(33);
313  QCString locHeader = grpHeader;
314  if (locHeader.isEmpty()) locHeader="[NOHEADER]";
315  MD5Buffer((const unsigned char *)locHeader.data(),locHeader.length(),md5_sig);
316  MD5SigToString(md5_sig,sigStr.rawData(),33);
317  return "amgrp"+sigStr;
318 }
319 
321 {
323  if (m_xrefListItems && def)
324  {
325  QCString name = def->getOutputFileBase()+"#"+anchor();
327  name,
329  name,
330  grpHeader,0,def);
331  }
332 }
333 
335 {
336  docFindSections(doc,0,this,m_docFile);
338 }
339 
341 {
343  marshalObjPointer(s,inDeclSection); // reference only
344  marshalInt(s,grpId);
348  marshalQCString(s,doc);
355 }
356 
358 {
361  grpId = unmarshalInt(s);
365  doc = unmarshalQCString(s);
372 }
373 
375 {
376  if (sli)
377  {
378  // deep copy the list
379  if (m_xrefListItems==0)
380  {
383  }
384  QListIterator<ListItemInfo> slii(*sli);
385  ListItemInfo *lii;
386  for (slii.toFirst();(lii=slii.current());++slii)
387  {
388  m_xrefListItems->append(new ListItemInfo(*lii));
389  }
390  }
391 }
392 
394 {
395  memberList->writeTagFile(tagFile);
396 }
397 
398 //--------------------------------------------------------------------------
399 
401 {
402  if (!sli) return;
403  if (m_sli==0)
404  {
405  m_sli = new QList<ListItemInfo>;
406  m_sli->setAutoDelete(TRUE);
407  }
408  QListIterator<ListItemInfo> slii(*sli);
409  ListItemInfo *ili;
410  for (slii.toFirst();(ili=slii.current());++slii)
411  {
412  m_sli->append(new ListItemInfo(*ili));
413  }
414 }
static QCString name
Definition: declinfo.cpp:673
MemberListType listType() const
Definition: memberlist.h:38
char * rawData() const
Definition: qcstring.h:216
QCString docFile() const
int typedefCount() const
int funcCount() const
Definition: memberlist.h:44
void append(const MemberDef *md)
Definition: memberlist.cpp:246
MemberList * unmarshalMemberList(StorageIntf *s)
Definition: marshal.cpp:676
int protoCount() const
Definition: memberlist.h:48
Definition * m_parent
Definition: membergroup.h:109
bool isEmpty() const
Definition: qcstring.h:189
int countDecMembers(GroupDef *gd=0)
Grouping::GroupPri_t getGroupPri() const
Definition: memberdef.cpp:4100
MemberList * getSectionList(Definition *d) const
Definition: memberdef.cpp:3541
uint length() const
Definition: qcstring.h:195
void setRefItems(const QList< ListItemInfo > *sli)
void append(const type *d)
Definition: qlist.h:73
int enumValueCount() const
int enumCount() const
Definition: memberlist.h:45
void writePlainDeclarations(OutputList &ol, ClassDef *cd, NamespaceDef *nd, FileDef *fd, GroupDef *gd, ClassDef *inheritedFrom, const char *inheritId)
void writeTagFile(FTextStream &)
int countGroupedInheritedMembers(MemberListType lt)
static Store * symbolStorage
Definition: doxygen.h:143
QCString inbodyDocumentation() const
int m_numDocMembers
Definition: membergroup.h:108
void setRefItems(const QList< ListItemInfo > *sli)
void writeDocumentation(OutputList &ol, const char *scopeName, Definition *container, const char *title, bool showEnumValues=FALSE, bool showInline=FALSE)
Definition: memberlist.cpp:655
const bool FALSE
Definition: qglobal.h:370
Abstract interface for file based memory storage operations.
Definition: store.h:27
QCString unmarshalQCString(StorageIntf *s)
Definition: marshal.cpp:451
int countDocMembers()
int unmarshalInt(StorageIntf *s)
Definition: marshal.cpp:418
void writeDeclarations(OutputList &ol, ClassDef *cd, NamespaceDef *nd, FileDef *fd, GroupDef *gd, bool showInline=FALSE)
QCString grpHeader
Definition: membergroup.h:102
int briefLine() const
void writeTagFile(FTextStream &)
Definition: memberlist.cpp:963
Simplified and optimized version of QTextStream.
Definition: ftextstream.h:11
void marshalInt(StorageIntf *s, int v)
Definition: marshal.cpp:16
int numDocMembers() const
virtual QCString getOutputFileBase() const =0
void * unmarshalObjPointer(StorageIntf *s)
Definition: marshal.cpp:575
int enumCount() const
int defineCount() const
Definition: memberlist.h:49
unsigned char uchar
Definition: nybbler.cc:11
bool inSameSection
Definition: membergroup.h:106
int defineCount() const
void addMemberGroup(MemberGroup *mg)
Definition: memberlist.cpp:774
void addGroupedInheritedMembers(OutputList &ol, ClassDef *cd, MemberListType lt, ClassDef *inheritedFrom, const QCString &inheritId)
int numDecMembers() const
void marshalBool(StorageIntf *s, bool b)
Definition: marshal.cpp:42
void writeDocumentation(OutputList &ol, const char *scopeName, Definition *container, bool showEnumValues, bool showInline)
void countDocMembers(bool countEnumValues=FALSE)
Definition: memberlist.cpp:208
int enumValueCount() const
Definition: memberlist.h:46
QCString inbodyFile() const
void findSectionsInDocumentation()
Definition: memberlist.cpp:818
bool unmarshalBool(StorageIntf *s)
Definition: marshal.cpp:443
void setDocumentation(const char *d, const char *docFile, int docLine, bool stripWhiteSpace=TRUE)
Definition: memberdef.cpp:1126
int protoCount() const
void setInbodyDocumentation(const char *d, const char *inbodyFile, int inbodyLine)
Definition: memberdef.cpp:1138
QCString briefDescription(bool abbr=FALSE) const
Definition: memberdef.cpp:5073
QList< ListItemInfo > * unmarshalItemInfoList(StorageIntf *s)
Definition: marshal.cpp:557
void MD5Buffer(const unsigned char *buf, unsigned int len, unsigned char sig[16])
Definition: md5.c:275
MemberList * inDeclSection
Definition: membergroup.h:100
int numDocMembers() const
Definition: memberlist.h:52
Definition * parent() const
Definition: membergroup.h:89
QCString docFile() const
Definition: membergroup.h:92
bool insertMember(MemberDef *def, bool docOnly=FALSE)
Definition: groupdef.cpp:259
void setInGroup(bool b)
QCString & prepend(const char *s)
Definition: qcstring.cpp:387
A bunch of utility functions.
const char * data() const
Definition: qcstring.h:207
void addToDeclarationSection()
type * current() const
Definition: qlist.h:146
void setInGroup(bool inGroup)
Definition: memberlist.h:73
int funcCount() const
QCString briefFile() const
type * getFirst() const
Definition: qlist.h:95
virtual QCString trGroup(bool first_capital, bool singular)=0
int typedefCount() const
Definition: memberlist.h:47
int inbodyLine() const
MemberList * memberList
Definition: membergroup.h:99
void writeDocumentationPage(OutputList &ol, const char *scopeName, Definition *container)
Definition: memberlist.cpp:715
int friendCount() const
Definition: memberlist.h:50
const char * getGroupFileName() const
Definition: memberdef.cpp:4105
int countInheritableMembers(ClassDef *inheritedFrom) const
Definition: memberlist.cpp:92
QCString documentation() const
Definition: memberdef.cpp:5085
GroupDef * getGroupDef() const
Definition: memberdef.cpp:4095
QCString m_docFile
Definition: membergroup.h:110
void countDecMembers(bool countEnumValues=FALSE, GroupDef *gd=0)
Definition: memberlist.cpp:136
void MD5SigToString(unsigned char signature[16], char *str, int len)
Definition: md5.c:285
Definition * scope
Definition: membergroup.h:104
void writeDocumentationPage(OutputList &ol, const char *scopeName, Definition *container)
void marshalItemInfoList(StorageIntf *s, QList< ListItemInfo > *sli)
Definition: marshal.cpp:148
QCString fileName
Definition: membergroup.h:103
int countInheritableMembers(ClassDef *inheritedFrom) const
static bool * b
Definition: config.cpp:1043
int varCount() const
Definition: memberlist.h:43
void addRefItem(const QList< ListItemInfo > *sli, const char *key, const char *prefix, const char *name, const char *title, const char *args, Definition *scope)
Definition: util.cpp:6456
Translator * theTranslator
Definition: language.cpp:157
void marshalQCString(StorageIntf *s, const QCString &str)
Definition: marshal.cpp:48
int getGroupStartLine() const
Definition: memberdef.cpp:4110
void setAnchors()
QCString doc
Definition: membergroup.h:105
MemberListType
Definition: types.h:104
void writeDeclarations(OutputList &ol, ClassDef *cd, NamespaceDef *nd, FileDef *fd, GroupDef *gd, const char *title, const char *subtitle, bool showEnumValues=FALSE, bool showInline=FALSE, ClassDef *inheritedFrom=0, MemberListType lt=MemberListType_pubMethods)
Definition: memberlist.cpp:519
int docLine() const
Definition: membergroup.h:93
void distributeMemberGroupDocumentation()
void setGroupDef(GroupDef *gd, Grouping::GroupPri_t pri, const QCString &fileName, int startLine, bool hasDocs, MemberDef *member=0)
Definition: memberdef.cpp:3363
int docLine() const
void docFindSections(const char *input, Definition *d, MemberGroup *mg, const char *fileName)
Definition: docparser.cpp:7434
void findSectionsInDocumentation()
void marshal(StorageIntf *s)
void marshalObjPointer(StorageIntf *s, void *obj)
Definition: marshal.cpp:167
void setAutoDelete(bool enable)
Definition: qlist.h:99
void marshalMemberList(StorageIntf *s, MemberList *ml)
Definition: marshal.cpp:280
void addListReferences(Definition *def)
Definition: memberlist.cpp:784
void setBriefDescription(const char *b, const char *briefFile, int briefLine)
Definition: memberdef.cpp:1132
static QCString * s
Definition: config.cpp:1042
QCString anchor() const
int m_numDecMembers
Definition: membergroup.h:107
const bool TRUE
Definition: qglobal.h:371
QList< ListItemInfo > * m_xrefListItems
Definition: membergroup.h:112
int varCount() const
void unmarshal(StorageIntf *s)
int numDecMembers() const
Definition: memberlist.h:51
void writePlainDeclarations(OutputList &ol, ClassDef *cd, NamespaceDef *nd, FileDef *fd, GroupDef *gd, ClassDef *inheritedFrom, const char *inheritId)
Definition: memberlist.cpp:321
bool getGroupHasDocs() const
Definition: memberdef.cpp:4115
void addListReferences(Definition *d)
int friendCount() const
type * toFirst()
Definition: qlist.h:135
void insertMember(MemberDef *md)
Definition: membergroup.cpp:69