Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/util/doxygen/src/membergroup.cpp

Source at commit 1322 created 12 years 8 months ago.
By meklort, Add doxygen to utils folder
1/******************************************************************************
2 *
3 * $Id: membergroup.cpp,v 1.19 2001/03/19 19:27:41 root Exp $
4 *
5 * Copyright (C) 1997-2011 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 "qtbc.h"
19#include "membergroup.h"
20#include "memberlist.h"
21#include "outputlist.h"
22#include "util.h"
23#include "classdef.h"
24#include "namespacedef.h"
25#include "filedef.h"
26#include "language.h"
27#include "groupdef.h"
28#include "doxygen.h"
29#include "docparser.h"
30#include "marshal.h"
31#include "entry.h"
32#include "md5.h"
33
34//static QCString idToName(int id)
35//{
36// QCString result;
37// result.sprintf("mgroup_%d",id);
38// return result;
39//}
40
41MemberGroup::MemberGroup()
42{
43}
44
45MemberGroup::MemberGroup(Definition *parent,
46 int id,const char *hdr,const char *d,const char *docFile)
47{
48 //printf("New member group id=%d header=%s desc=%s\n",id,hdr,d);
49 memberList = new MemberList(MemberList::memberGroup);
50 grpId = id;
51 grpHeader = hdr;
52 doc = d;
53 scope = 0;
54 inSameSection = TRUE;
55 inDeclSection = 0;
56 m_numDecMembers = -1;
57 m_numDocMembers = -1;
58 m_parent = parent;
59 m_docFile = docFile;
60 m_xrefListItems = 0;
61 //printf("Member group docs=`%s'\n",doc.data());
62}
63
64MemberGroup::~MemberGroup()
65{
66 delete memberList;
67}
68
69void MemberGroup::insertMember(MemberDef *md)
70{
71 //printf("MemberGroup::insertMember m_parent=%s memberList=%p count=%d"
72 // " member section list: %p\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 MemberDef *firstMd = memberList->first();
78 if (inSameSection && memberList->count()>0 &&
79 firstMd->getSectionList(m_parent)!=md->getSectionList(m_parent))
80 {
81 inSameSection=FALSE;
82 }
83 else if (inDeclSection==0)
84 {
85 inDeclSection = md->getSectionList(m_parent);
86 //printf("inDeclSection=%p type=%d\n",inDeclSection,inDeclSection->listType());
87 }
88 memberList->append(md);
89
90 // copy the group of the first member in the memberGroup
91 GroupDef *gd;
92 if (firstMd && (gd=firstMd->getGroupDef()))
93 {
94 md->setGroupDef(gd, firstMd->getGroupPri(),
95 firstMd->getGroupFileName(), firstMd->getGroupStartLine(),
96 firstMd->getGroupHasDocs());
97 gd->insertMember(md);
98 }
99}
100
101
102void MemberGroup::setAnchors(ClassDef *context)
103{
104 ::setAnchors(context,'z',memberList,grpId);
105}
106
107void MemberGroup::writeDeclarations(OutputList &ol,
108 ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
109 bool showInline)
110{
111 //printf("MemberGroup::writeDeclarations() %s\n",grpHeader.data());
112 QCString ldoc = doc;
113 if (!ldoc.isEmpty()) ldoc.prepend("<a name=\""+anchor()+"\" id=\""+anchor()+"\"></a>");
114 memberList->writeDeclarations(ol,cd,nd,fd,gd,grpHeader,ldoc,FALSE,showInline);
115}
116
117void MemberGroup::writePlainDeclarations(OutputList &ol,
118 ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd
119 )
120{
121 //printf("MemberGroup::writePlainDeclarations() memberList->count()=%d\n",memberList->count());
122 memberList->writePlainDeclarations(ol,cd,nd,fd,gd);
123}
124
125void MemberGroup::writeDocumentation(OutputList &ol,const char *scopeName,
126 Definition *container,bool showEnumValues,bool showInline)
127{
128 memberList->writeDocumentation(ol,scopeName,container,0,showEnumValues,showInline);
129}
130
131void MemberGroup::writeDocumentationPage(OutputList &ol,const char *scopeName,
132 Definition *container)
133{
134 memberList->writeDocumentationPage(ol,scopeName,container);
135}
136
137/*! Add this group as a subsection of the declaration section, instead
138 * of rendering it in its own section
139 */
140void MemberGroup::addToDeclarationSection()
141{
142 if (inDeclSection)
143 {
144 //printf("Adding group %p to list %p (type=%d)\n",this,
145 // inDeclSection,inDeclSection->listType());
146 inDeclSection->addMemberGroup(this);
147 }
148}
149
150int MemberGroup::countDecMembers(GroupDef *gd)
151{
152 if (m_numDecMembers==-1) /* number of member not cached */
153 {
154 memberList->countDecMembers(gd);
155 m_numDecMembers = memberList->numDecMembers();
156 }
157 return m_numDecMembers;
158}
159
160int MemberGroup::countDocMembers()
161{
162 if (m_numDocMembers==-1)
163 {
164 memberList->countDocMembers();
165 m_numDocMembers = memberList->numDocMembers();
166 }
167 return m_numDocMembers;
168}
169
170void MemberGroup::distributeMemberGroupDocumentation()
171{
172 //printf("MemberGroup::distributeMemberGroupDocumentation() %s\n",grpHeader.data());
173 MemberDef *md=memberList->first();
174 while (md)
175 {
176 //printf("checking md=%s\n",md->name().data());
177 // find the first member of the group with documentation
178 if (!md->documentation().isEmpty() ||
179 !md->briefDescription().isEmpty() ||
180 !md->inbodyDocumentation().isEmpty()
181 )
182 {
183 //printf("found it!\n");
184 break;
185 }
186 md=memberList->next();
187 }
188 if (md) // distribute docs of md to other members of the list
189 {
190 //printf("Member %s has documentation!\n",md->name().data());
191 MemberDef *omd=memberList->first();
192 while (omd)
193 {
194 if (md!=omd && omd->documentation().isEmpty() &&
195 omd->briefDescription().isEmpty() &&
196 omd->inbodyDocumentation().isEmpty()
197 )
198 {
199 //printf("Copying documentation to member %s\n",omd->name().data());
200 omd->setBriefDescription(md->briefDescription(),md->briefFile(),md->briefLine());
201 omd->setDocumentation(md->documentation(),md->docFile(),md->docLine());
202 omd->setInbodyDocumentation(md->inbodyDocumentation(),md->inbodyFile(),md->inbodyLine());
203 }
204 omd=memberList->next();
205 }
206 }
207}
208
209int MemberGroup::varCount() const
210{
211 return memberList->varCount();
212}
213
214int MemberGroup::funcCount() const
215{
216 return memberList->funcCount();
217}
218
219int MemberGroup::enumCount() const
220{
221 return memberList->enumCount();
222}
223
224int MemberGroup::enumValueCount() const
225{
226 return memberList->enumValueCount();
227}
228
229int MemberGroup::typedefCount() const
230{
231 return memberList->typedefCount();
232}
233
234int MemberGroup::protoCount() const
235{
236 return memberList->protoCount();
237}
238
239int MemberGroup::defineCount() const
240{
241 return memberList->defineCount();
242}
243
244int MemberGroup::friendCount() const
245{
246 return memberList->friendCount();
247}
248
249int MemberGroup::numDecMembers() const
250{
251 return memberList->numDecMembers();
252}
253
254int MemberGroup::numDocMembers() const
255{
256 return memberList->numDocMembers();
257}
258
259void MemberGroup::setInGroup(bool b)
260{
261 memberList->setInGroup(b);
262}
263
264QCString MemberGroup::anchor() const
265{
266 uchar md5_sig[16];
267 QCString sigStr(33);
268 QCString locHeader = grpHeader;
269 if (locHeader.isEmpty()) locHeader="[NOHEADER]";
270 MD5Buffer((const unsigned char *)locHeader.data(),locHeader.length(),md5_sig);
271 MD5SigToString(md5_sig,sigStr.data(),33);
272 return "amgrp"+sigStr;
273}
274
275void MemberGroup::addListReferences(Definition *def)
276{
277 memberList->addListReferences(def);
278 if (m_xrefListItems && def)
279 {
280 QCString name = def->getOutputFileBase()+"#"+anchor();
281 addRefItem(m_xrefListItems,
282 name,
283 theTranslator->trGroup(TRUE,TRUE),
284 name,
285 grpHeader,0);
286 }
287}
288
289void MemberGroup::findSectionsInDocumentation()
290{
291 docFindSections(doc,0,this,m_docFile);
292 memberList->findSectionsInDocumentation();
293}
294
295void MemberGroup::marshal(StorageIntf *s)
296{
297 marshalMemberList(s,memberList);
298 marshalObjPointer(s,inDeclSection); // reference only
299 marshalInt(s,grpId);
300 marshalQCString(s,grpHeader);
301 marshalQCString(s,fileName);
302 marshalObjPointer(s,scope);
303 marshalQCString(s,doc);
304 marshalBool(s,inSameSection);
305 marshalInt(s,m_numDecMembers);
306 marshalInt(s,m_numDocMembers);
307 marshalObjPointer(s,m_parent);
308 marshalQCString(s,m_docFile);
309 marshalItemInfoList (Doxygen::symbolStorage,m_xrefListItems);
310}
311
312void MemberGroup::unmarshal(StorageIntf *s)
313{
314 memberList = unmarshalMemberList(s);
315 inDeclSection = (MemberList *)unmarshalObjPointer(s);
316 grpId = unmarshalInt(s);
317 grpHeader = unmarshalQCString(s);
318 fileName = unmarshalQCString(s);
319 scope = (Definition *)unmarshalObjPointer(s);
320 doc = unmarshalQCString(s);
321 inSameSection = unmarshalBool(s);
322 m_numDecMembers = unmarshalInt(s);
323 m_numDocMembers = unmarshalInt(s);
324 m_parent = (Definition *)unmarshalObjPointer(s);
325 m_docFile = unmarshalQCString(s);
326 m_xrefListItems = unmarshalItemInfoList (Doxygen::symbolStorage);
327}
328
329void MemberGroup::setRefItems(const QList<ListItemInfo> *sli)
330{
331 if (sli)
332 {
333 // deep copy the list
334 if (m_xrefListItems==0)
335 {
336 m_xrefListItems=new QList<ListItemInfo>;
337 m_xrefListItems->setAutoDelete(TRUE);
338 }
339 QListIterator<ListItemInfo> slii(*sli);
340 ListItemInfo *lii;
341 for (slii.toFirst();(lii=slii.current());++slii)
342 {
343 m_xrefListItems->append(new ListItemInfo(*lii));
344 }
345 }
346}
347//--------------------------------------------------------------------------
348
349void MemberGroupInfo::setRefItems(const QList<ListItemInfo> *sli)
350{
351 if (!sli) return;
352 if (m_sli==0)
353 {
354 m_sli = new QList<ListItemInfo>;
355 m_sli->setAutoDelete(TRUE);
356 }
357 QListIterator<ListItemInfo> slii(*sli);
358 ListItemInfo *ili;
359 for (slii.toFirst();(ili=slii.current());++slii)
360 {
361 m_sli->append(new ListItemInfo(*ili));
362 }
363}
364

Archive Download this file

Revision: 1322