1 /******************************************************************************
3 * $Id: membergroup.cpp,v 1.19 2001/03/19 19:27:41 root Exp $
5 * Copyright (C) 1997-2012 by Dimitri van Heesch.
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.
13 * Documents produced by Doxygen are derivative works derived from the
14 * input used in their production; they are not affected by this license.
19 #include "membergroup.h"
20 #include "memberlist.h"
21 #include "outputlist.h"
24 #include "namespacedef.h"
29 #include "docparser.h"
34 //static QCString idToName(int id)
37 // result.sprintf("mgroup_%d",id);
41 MemberGroup::MemberGroup()
45 MemberGroup::MemberGroup(Definition *parent,
46 int id,const char *hdr,const char *d,const char *docFile)
48 //printf("New member group id=%d header=%s desc=%s\n",id,hdr,d);
49 memberList = new MemberList(MemberList::memberGroup);
61 //printf("Member group docs=`%s'\n",doc.data());
64 MemberGroup::~MemberGroup()
69 void MemberGroup::insertMember(MemberDef *md)
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());
79 MemberDef *firstMd = memberList->first();
80 if (inSameSection && memberList->count()>0 &&
81 firstMd->getSectionList(m_parent)!=md->getSectionList(m_parent))
85 else if (inDeclSection==0)
87 inDeclSection = md->getSectionList(m_parent);
88 //printf("inDeclSection=%p type=%d\n",inDeclSection,inDeclSection->listType());
90 memberList->append(md);
92 // copy the group of the first member in the memberGroup
94 if (firstMd && (gd=firstMd->getGroupDef()))
96 md->setGroupDef(gd, firstMd->getGroupPri(),
97 firstMd->getGroupFileName(), firstMd->getGroupStartLine(),
98 firstMd->getGroupHasDocs());
104 void MemberGroup::setAnchors(ClassDef *context)
106 ::setAnchors(context,'z',memberList,grpId);
109 void MemberGroup::writeDeclarations(OutputList &ol,
110 ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
113 //printf("MemberGroup::writeDeclarations() %s\n",grpHeader.data());
115 if (!ldoc.isEmpty()) ldoc.prepend("<a name=\""+anchor()+"\" id=\""+anchor()+"\"></a>");
116 memberList->writeDeclarations(ol,cd,nd,fd,gd,grpHeader,ldoc,FALSE,showInline);
119 void MemberGroup::writePlainDeclarations(OutputList &ol,
120 ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
121 ClassDef *inheritedFrom,const char *inheritId
124 //printf("MemberGroup::writePlainDeclarations() memberList->count()=%d\n",memberList->count());
125 memberList->writePlainDeclarations(ol,cd,nd,fd,gd,inheritedFrom,inheritId);
128 void MemberGroup::writeDocumentation(OutputList &ol,const char *scopeName,
129 Definition *container,bool showEnumValues,bool showInline)
131 memberList->writeDocumentation(ol,scopeName,container,0,showEnumValues,showInline);
134 void MemberGroup::writeDocumentationPage(OutputList &ol,const char *scopeName,
135 Definition *container)
137 memberList->writeDocumentationPage(ol,scopeName,container);
140 void MemberGroup::addGroupedInheritedMembers(OutputList &ol,ClassDef *cd,
141 MemberList::ListType lt,
142 ClassDef *inheritedFrom,const QCString &inheritId)
144 //printf("** addGroupedInheritedMembers()\n");
145 MemberListIterator li(*memberList);
147 for (li.toFirst();(md=li.current());++li)
149 //printf("matching %d == %d\n",lt,md->getSectionList(m_parent)->listType());
150 if (lt==md->getSectionList(m_parent)->listType())
154 ml.writePlainDeclarations(ol,cd,0,0,0,inheritedFrom,inheritId);
159 int MemberGroup::countGroupedInheritedMembers(MemberList::ListType lt)
161 //printf("** countGroupedInheritedMembers()\n");
163 MemberListIterator li(*memberList);
165 for (li.toFirst();(md=li.current());++li)
167 //printf("matching %d == %d\n",lt,md->getSectionList(m_parent)->listType());
168 if (lt==md->getSectionList(m_parent)->listType())
177 /*! Add this group as a subsection of the declaration section, instead
178 * of rendering it in its own section
180 void MemberGroup::addToDeclarationSection()
184 //printf("Adding group %p to list %p (type=%d)\n",this,
185 // inDeclSection,inDeclSection->listType());
186 inDeclSection->addMemberGroup(this);
190 int MemberGroup::countDecMembers(GroupDef *gd)
192 if (m_numDecMembers==-1) /* number of member not cached */
194 memberList->countDecMembers(gd);
195 m_numDecMembers = memberList->numDecMembers();
197 return m_numDecMembers;
200 int MemberGroup::countDocMembers()
202 if (m_numDocMembers==-1)
204 memberList->countDocMembers();
205 m_numDocMembers = memberList->numDocMembers();
207 return m_numDocMembers;
210 int MemberGroup::countInheritableMembers(ClassDef *inheritedFrom) const
212 return memberList->countInheritableMembers(inheritedFrom);
216 void MemberGroup::distributeMemberGroupDocumentation()
218 //printf("MemberGroup::distributeMemberGroupDocumentation() %s\n",grpHeader.data());
219 MemberDef *md=memberList->first();
222 //printf("checking md=%s\n",md->name().data());
223 // find the first member of the group with documentation
224 if (!md->documentation().isEmpty() ||
225 !md->briefDescription().isEmpty() ||
226 !md->inbodyDocumentation().isEmpty()
229 //printf("found it!\n");
232 md=memberList->next();
234 if (md) // distribute docs of md to other members of the list
236 //printf("Member %s has documentation!\n",md->name().data());
237 MemberDef *omd=memberList->first();
240 if (md!=omd && omd->documentation().isEmpty() &&
241 omd->briefDescription().isEmpty() &&
242 omd->inbodyDocumentation().isEmpty()
245 //printf("Copying documentation to member %s\n",omd->name().data());
246 omd->setBriefDescription(md->briefDescription(),md->briefFile(),md->briefLine());
247 omd->setDocumentation(md->documentation(),md->docFile(),md->docLine());
248 omd->setInbodyDocumentation(md->inbodyDocumentation(),md->inbodyFile(),md->inbodyLine());
250 omd=memberList->next();
255 int MemberGroup::varCount() const
257 return memberList->varCount();
260 int MemberGroup::funcCount() const
262 return memberList->funcCount();
265 int MemberGroup::enumCount() const
267 return memberList->enumCount();
270 int MemberGroup::enumValueCount() const
272 return memberList->enumValueCount();
275 int MemberGroup::typedefCount() const
277 return memberList->typedefCount();
280 int MemberGroup::protoCount() const
282 return memberList->protoCount();
285 int MemberGroup::defineCount() const
287 return memberList->defineCount();
290 int MemberGroup::friendCount() const
292 return memberList->friendCount();
295 int MemberGroup::numDecMembers() const
297 return memberList->numDecMembers();
300 int MemberGroup::numDocMembers() const
302 return memberList->numDocMembers();
305 void MemberGroup::setInGroup(bool b)
307 memberList->setInGroup(b);
310 QCString MemberGroup::anchor() const
314 QCString locHeader = grpHeader;
315 if (locHeader.isEmpty()) locHeader="[NOHEADER]";
316 MD5Buffer((const unsigned char *)locHeader.data(),locHeader.length(),md5_sig);
317 MD5SigToString(md5_sig,sigStr.data(),33);
318 return "amgrp"+sigStr;
321 void MemberGroup::addListReferences(Definition *def)
323 memberList->addListReferences(def);
324 if (m_xrefListItems && def)
326 QCString name = def->getOutputFileBase()+"#"+anchor();
327 addRefItem(m_xrefListItems,
329 theTranslator->trGroup(TRUE,TRUE),
335 void MemberGroup::findSectionsInDocumentation()
337 docFindSections(doc,0,this,m_docFile);
338 memberList->findSectionsInDocumentation();
341 void MemberGroup::marshal(StorageIntf *s)
343 marshalMemberList(s,memberList);
344 marshalObjPointer(s,inDeclSection); // reference only
346 marshalQCString(s,grpHeader);
347 marshalQCString(s,fileName);
348 marshalObjPointer(s,scope);
349 marshalQCString(s,doc);
350 marshalBool(s,inSameSection);
351 marshalInt(s,m_numDecMembers);
352 marshalInt(s,m_numDocMembers);
353 marshalObjPointer(s,m_parent);
354 marshalQCString(s,m_docFile);
355 marshalItemInfoList (Doxygen::symbolStorage,m_xrefListItems);
358 void MemberGroup::unmarshal(StorageIntf *s)
360 memberList = unmarshalMemberList(s);
361 inDeclSection = (MemberList *)unmarshalObjPointer(s);
362 grpId = unmarshalInt(s);
363 grpHeader = unmarshalQCString(s);
364 fileName = unmarshalQCString(s);
365 scope = (Definition *)unmarshalObjPointer(s);
366 doc = unmarshalQCString(s);
367 inSameSection = unmarshalBool(s);
368 m_numDecMembers = unmarshalInt(s);
369 m_numDocMembers = unmarshalInt(s);
370 m_parent = (Definition *)unmarshalObjPointer(s);
371 m_docFile = unmarshalQCString(s);
372 m_xrefListItems = unmarshalItemInfoList (Doxygen::symbolStorage);
375 void MemberGroup::setRefItems(const QList<ListItemInfo> *sli)
379 // deep copy the list
380 if (m_xrefListItems==0)
382 m_xrefListItems=new QList<ListItemInfo>;
383 m_xrefListItems->setAutoDelete(TRUE);
385 QListIterator<ListItemInfo> slii(*sli);
387 for (slii.toFirst();(lii=slii.current());++slii)
389 m_xrefListItems->append(new ListItemInfo(*lii));
393 //--------------------------------------------------------------------------
395 void MemberGroupInfo::setRefItems(const QList<ListItemInfo> *sli)
400 m_sli = new QList<ListItemInfo>;
401 m_sli->setAutoDelete(TRUE);
403 QListIterator<ListItemInfo> slii(*sli);
405 for (slii.toFirst();(ili=slii.current());++slii)
407 m_sli->append(new ListItemInfo(*ili));