1 /******************************************************************************
5 * Copyright (C) 1997-2015 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.
25 #include "filestorage.h"
26 #include "arguments.h"
28 //------------------------------------------------------------------
30 #define HEADER ('D'<<24)+('O'<<16)+('X'<<8)+'!'
32 //------------------------------------------------------------------
38 //printf("Entry::Entry(%p)\n",this);
42 m_sublist = new QList<Entry>;
43 m_sublist->setAutoDelete(TRUE);
44 extends = new QList<BaseInfo>;
45 extends->setAutoDelete(TRUE);
46 groups = new QList<Grouping>;
47 groups->setAutoDelete(TRUE);
48 anchors = new QList<SectionInfo>; // Doxygen::sectionDict takes ownership of the items!
49 argList = new ArgumentList;
50 argList->setAutoDelete(TRUE);
51 //printf("Entry::Entry() tArgList=0\n");
59 groupDocType = GROUPDOC_NORMAL;
63 Entry::Entry(const Entry &e)
65 //printf("Entry::Entry(%p):copy\n",this);
71 protection = e.protection;
74 initLines = e.initLines;
76 localToc = e.localToc;
77 explicitExternal = e.explicitExternal;
79 subGrouping = e.subGrouping;
80 callGraph = e.callGraph;
81 callerGraph = e.callerGraph;
82 referencedByRelation = e.referencedByRelation;
83 referencesRelation = e.referencesRelation;
86 bitfields = e.bitfields;
87 argList = e.argList->deepCopy();
90 initializer = e.initializer;
91 includeFile = e.includeFile;
92 includeName = e.includeName;
97 briefLine = e.briefLine;
98 briefFile = e.briefFile;
99 inbodyDocs = e.inbodyDocs;
100 inbodyLine = e.inbodyLine;
101 inbodyFile = e.inbodyFile;
103 relatesType = e.relatesType;
107 exception = e.exception;
109 bodyLine = e.bodyLine;
110 endBodyLine = e.endBodyLine;
112 extends = new QList<BaseInfo>;
113 extends->setAutoDelete(TRUE);
114 groups = new QList<Grouping>;
115 groups->setAutoDelete(TRUE);
116 anchors = new QList<SectionInfo>;
117 fileName = e.fileName;
118 startLine = e.startLine;
119 startColumn = e.startColumn;
122 sli = new QList<ListItemInfo>;
123 sli->setAutoDelete(TRUE);
124 QListIterator<ListItemInfo> slii(*e.sli);
126 for (slii.toFirst();(ili=slii.current());++slii)
128 sli->append(new ListItemInfo(*ili));
137 artificial = e.artificial;
138 groupDocType = e.groupDocType;
141 m_parent = e.m_parent;
142 m_sublist = new QList<Entry>;
143 m_sublist->setAutoDelete(TRUE);
145 // deep copy of the child entry list
146 QListIterator<Entry> eli(*e.m_sublist);
148 for (;(cur=eli.current());++eli)
150 m_sublist->append(new Entry(*cur));
153 // deep copy base class list
154 QListIterator<BaseInfo> bli(*e.extends);
156 for (;(bi=bli.current());++bli)
158 extends->append(new BaseInfo(*bi));
161 // deep copy group list
162 QListIterator<Grouping> gli(*e.groups);
164 for (;(g=gli.current());++gli)
166 groups->append(new Grouping(*g));
169 QListIterator<SectionInfo> sli2(*e.anchors);
171 for (;(s=sli2.current());++sli2)
173 anchors->append(s); // shallow copy, object are owned by Doxygen::sectionDict
176 // deep copy type constraint list
179 typeConstr = e.typeConstr->deepCopy();
182 // deep copy template argument lists
185 tArgLists = copyArgumentLists(e.tArgLists);
192 //printf("Entry::~Entry(%p) num=%d\n",this,num);
193 //printf("Deleting entry %d name %s type %x children %d\n",
194 // num,name.data(),section,sublist->count());
196 delete m_sublist; // each element is now own by a EntryNav so we do no longer own
209 void Entry::addSubEntry(Entry *current)
211 //printf("Entry %d with name %s type 0x%x added to %s type 0x%x\n",
212 // current->num,current->name.data(),current->section,
213 // name.data(),section);
214 //printf("Entry::addSubEntry(%s:%p) to %s\n",current->name.data(),
215 // current,name.data());
216 current->m_parent=this;
217 m_sublist->append(current);
222 static bool entryCallGraph = Config_getBool(CALL_GRAPH);
223 static bool entryCallerGraph = Config_getBool(CALLER_GRAPH);
224 static bool entryReferencedByRelation = Config_getBool(REFERENCED_BY_RELATION);
225 static bool entryReferencesRelation = Config_getBool(REFERENCES_RELATION);
226 //printf("Entry::reset()\n");
233 includeFile.resize(0);
234 includeName.resize(0);
243 inbodyDocs.resize(0);
244 inbodyFile.resize(0);
248 initializer.resize(0);
255 callGraph = entryCallGraph;
256 callerGraph = entryCallerGraph;
257 referencedByRelation = entryReferencedByRelation;
258 referencesRelation = entryReferencesRelation;
264 explicitExternal = FALSE;
266 lang = SrcLangExt_Unknown;
271 groupDocType = GROUPDOC_NORMAL;
279 if (tagInfo) { delete tagInfo; tagInfo=0; }
280 if (tArgLists) { delete tArgLists; tArgLists=0; }
281 if (sli) { delete sli; sli=0; }
282 if (typeConstr) { delete typeConstr; typeConstr=0; }
283 //if (mtArgList) { delete mtArgList; mtArgList=0; }
289 return sizeof(Entry);
292 void Entry::createSubtreeIndex(EntryNav *nav,FileStorage *storage,FileDef *fd)
294 EntryNav *childNav = new EntryNav(nav,this);
295 nav->addChild(childNav);
296 childNav->setFileDef(fd);
297 childNav->saveEntry(this,storage);
300 //printf("saveEntry: %d children\n",node->sublist->count());
301 QListIterator<Entry> eli(*m_sublist);
303 for (eli.toFirst();(childNode=eli.current());++eli)
305 childNode->createSubtreeIndex(childNav,storage,fd);
307 //m_sublist->setAutoDelete(FALSE);
312 void Entry::createNavigationIndex(EntryNav *rootNav,FileStorage *storage,FileDef *fd)
314 createSubtreeIndex(rootNav,storage,fd);
317 void Entry::addSpecialListItem(const char *listName,int itemId)
321 sli = new QList<ListItemInfo>;
322 sli->setAutoDelete(TRUE);
324 ListItemInfo *ili=new ListItemInfo;
325 ili->type = listName;
326 ili->itemId = itemId;
330 Entry *Entry::removeSubEntry(Entry *e)
332 int i = m_sublist->find(e);
333 return i!=-1 ? m_sublist->take(i) : 0;
336 //------------------------------------------------------------------
339 EntryNav::EntryNav(EntryNav *parent, Entry *e)
340 : m_parent(parent), m_subList(0), m_section(e->section), m_type(e->type),
341 m_name(e->name), m_fileDef(0), m_lang(e->lang),
342 m_info(0), m_offset(-1), m_noLoad(FALSE)
346 m_tagInfo = new TagInfo;
347 m_tagInfo->tagName = e->tagInfo->tagName;
348 m_tagInfo->fileName = e->tagInfo->fileName;
349 m_tagInfo->anchor = e->tagInfo->anchor;
352 //printf("tagInfo %p: tagName=%s fileName=%s anchor=%s\n",
354 // e->tagInfo->tagName.data(),
355 // e->tagInfo->fileName.data(),
356 // e->tagInfo->anchor.data());
365 EntryNav::~EntryNav()
372 void EntryNav::addChild(EntryNav *e)
376 m_subList = new QList<EntryNav>;
377 m_subList->setAutoDelete(TRUE);
379 m_subList->append(e);
382 bool EntryNav::loadEntry(FileStorage *storage)
390 //printf("offset not set!\n");
394 //printf("EntryNav::loadEntry: new entry %p: %s\n",m_info,m_name.data());
395 //m_info->tagInfo = m_tagInfo;
398 // m_info->parent = m_parent->m_info;
400 //m_info->parent = 0;
401 //printf("load entry: seek to %llx\n",m_offset);
402 if (!storage->seek(m_offset))
404 //printf("seek failed!\n");
407 if (m_info) delete m_info;
408 m_info = unmarshalEntry(storage);
409 m_info->name = m_name;
410 m_info->type = m_type;
411 m_info->section = m_section;
415 bool EntryNav::saveEntry(Entry *e,FileStorage *storage)
417 m_offset = storage->pos();
418 //printf("EntryNav::saveEntry offset=%llx\n",m_offset);
419 marshalEntry(storage,e);
423 void EntryNav::releaseEntry()
427 //printf("EntryNav::releaseEntry %p\n",m_info);
433 void EntryNav::setEntry(Entry *e)
437 //printf("EntryNav::setEntry %p\n",e);