My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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;
53  inSameSection = TRUE;
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  {
83  inSameSection=FALSE;
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());
151  if (ml && lt==ml->listType())
152  {
153  MemberList ml(lt);
154  ml.append(md);
155  ml.writePlainDeclarations(ol,cd,0,0,0,inheritedFrom,inheritId);
156  }
157  }
158 }
159 
161 {
162  //printf("** countGroupedInheritedMembers()\n");
163  int count=0;
165  MemberDef *md;
166  for (li.toFirst();(md=li.current());++li)
167  {
168  //printf("matching %d == %d\n",lt,md->getSectionList(m_parent)->listType());
170  if (ml && lt==ml->listType())
171  {
172  count++;
173  }
174  }
175  return count;
176 }
177 
178 
183 {
184  if (inDeclSection)
185  {
186  //printf("Adding group %p to list %p (type=%d)\n",this,
187  // inDeclSection,inDeclSection->listType());
189  }
190 }
191 
193 {
194  if (m_numDecMembers==-1) /* number of member not cached */
195  {
198  }
199  return m_numDecMembers;
200 }
201 
203 {
204  if (m_numDocMembers==-1)
205  {
208  }
209  return m_numDocMembers;
210 }
211 
213 {
214  return memberList->countInheritableMembers(inheritedFrom);
215 }
216 
217 
219 {
220  //printf("MemberGroup::distributeMemberGroupDocumentation() %s\n",grpHeader.data());
222  MemberDef *md;
223  for (li.toFirst();(md=li.current());++li)
224  {
225  //printf("checking md=%s\n",md->name().data());
226  // find the first member of the group with documentation
227  if (!md->documentation().isEmpty() ||
228  !md->briefDescription().isEmpty() ||
229  !md->inbodyDocumentation().isEmpty()
230  )
231  {
232  //printf("found it!\n");
233  break;
234  }
235  }
236  if (md) // distribute docs of md to other members of the list
237  {
238  //printf("Member %s has documentation!\n",md->name().data());
239  MemberDef *omd;
240  for (li.toFirst();(omd=li.current());++li)
241  {
242  if (md!=omd && omd->documentation().isEmpty() &&
243  omd->briefDescription().isEmpty() &&
244  omd->inbodyDocumentation().isEmpty()
245  )
246  {
247  //printf("Copying documentation to member %s\n",omd->name().data());
249  omd->setDocumentation(md->documentation(),md->docFile(),md->docLine());
251  }
252  }
253  }
254 }
255 
257 {
258  return memberList->varCount();
259 }
260 
262 {
263  return memberList->funcCount();
264 }
265 
267 {
268  return memberList->enumCount();
269 }
270 
272 {
273  return memberList->enumValueCount();
274 }
275 
277 {
278  return memberList->typedefCount();
279 }
280 
282 {
283  return memberList->protoCount();
284 }
285 
287 {
288  return memberList->defineCount();
289 }
290 
292 {
293  return memberList->friendCount();
294 }
295 
297 {
298  return memberList->numDecMembers();
299 }
300 
302 {
303  return memberList->numDocMembers();
304 }
305 
307 {
309 }
310 
311 QCString MemberGroup::anchor() const
312 {
313  uchar md5_sig[16];
314  QCString sigStr(33);
315  QCString locHeader = grpHeader;
316  if (locHeader.isEmpty()) locHeader="[NOHEADER]";
317  MD5Buffer((const unsigned char *)locHeader.data(),locHeader.length(),md5_sig);
318  MD5SigToString(md5_sig,sigStr.rawData(),33);
319  return "amgrp"+sigStr;
320 }
321 
323 {
325  if (m_xrefListItems && def)
326  {
327  QCString name = def->getOutputFileBase()+"#"+anchor();
329  name,
330  theTranslator->trGroup(TRUE,TRUE),
331  name,
332  grpHeader,0,def);
333  }
334 }
335 
337 {
338  docFindSections(doc,0,this,m_docFile);
340 }
341 
343 {
345  marshalObjPointer(s,inDeclSection); // reference only
346  marshalInt(s,grpId);
350  marshalQCString(s,doc);
357 }
358 
360 {
363  grpId = unmarshalInt(s);
367  doc = unmarshalQCString(s);
374 }
375 
376 void MemberGroup::setRefItems(const QList<ListItemInfo> *sli)
377 {
378  if (sli)
379  {
380  // deep copy the list
381  if (m_xrefListItems==0)
382  {
383  m_xrefListItems=new QList<ListItemInfo>;
384  m_xrefListItems->setAutoDelete(TRUE);
385  }
386  QListIterator<ListItemInfo> slii(*sli);
387  ListItemInfo *lii;
388  for (slii.toFirst();(lii=slii.current());++slii)
389  {
390  m_xrefListItems->append(new ListItemInfo(*lii));
391  }
392  }
393 }
394 
396 {
397  memberList->writeTagFile(tagFile);
398 }
399 
400 //--------------------------------------------------------------------------
401 
402 void MemberGroupInfo::setRefItems(const QList<ListItemInfo> *sli)
403 {
404  if (!sli) return;
405  if (m_sli==0)
406  {
407  m_sli = new QList<ListItemInfo>;
408  m_sli->setAutoDelete(TRUE);
409  }
410  QListIterator<ListItemInfo> slii(*sli);
411  ListItemInfo *ili;
412  for (slii.toFirst();(ili=slii.current());++slii)
413  {
414  m_sli->append(new ListItemInfo(*ili));
415  }
416 }