My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
entry.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 <stdlib.h>
19 #include <qfile.h>
20 #include "entry.h"
21 #include "marshal.h"
22 #include "util.h"
23 #include "section.h"
24 #include "doxygen.h"
25 #include "filestorage.h"
26 #include "arguments.h"
27 #include "config.h"
28 //------------------------------------------------------------------
29 
30 #define HEADER ('D'<<24)+('O'<<16)+('X'<<8)+'!'
31 
32 //------------------------------------------------------------------
33 
34 int Entry::num=0;
35 
37 {
38  //printf("Entry::Entry(%p)\n",this);
39  num++;
40  m_parent=0;
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");
52  tArgLists = 0;
53  typeConstr = 0;
54  mGrpId = -1;
55  tagInfo = 0;
56  sli = 0;
58  hidden = FALSE;
60  reset();
61 }
62 
64 {
65  //printf("Entry::Entry(%p):copy\n",this);
66  num++;
67  section = e.section;
68  type = e.type;
69  name = e.name;
70  tagInfo = e.tagInfo;
72  mtype = e.mtype;
73  spec = e.spec;
74  initLines = e.initLines;
75  stat = e.stat;
77  proto = e.proto;
79  callGraph = e.callGraph;
81  virt = e.virt;
82  args = e.args;
83  bitfields = e.bitfields;
84  argList = e.argList->deepCopy();
85  tArgLists = 0;
86  program = e.program;
90  doc = e.doc;
91  docLine = e.docLine;
92  docFile = e.docFile;
93  brief = e.brief;
94  briefLine = e.briefLine;
95  briefFile = e.briefFile;
99  relates = e.relates;
101  read = e.read;
102  write = e.write;
103  inside = e.inside;
104  exception = e.exception;
105  typeConstr = 0;
106  bodyLine = e.bodyLine;
108  mGrpId = e.mGrpId;
109  extends = new QList<BaseInfo>;
110  extends->setAutoDelete(TRUE);
111  groups = new QList<Grouping>;
112  groups->setAutoDelete(TRUE);
113  anchors = new QList<SectionInfo>;
114  fileName = e.fileName;
115  startLine = e.startLine;
117  if (e.sli)
118  {
119  sli = new QList<ListItemInfo>;
120  sli->setAutoDelete(TRUE);
121  QListIterator<ListItemInfo> slii(*e.sli);
122  ListItemInfo *ili;
123  for (slii.toFirst();(ili=slii.current());++slii)
124  {
125  sli->append(new ListItemInfo(*ili));
126  }
127  }
128  else
129  {
130  sli=0;
131  }
132  lang = e.lang;
133  hidden = e.hidden;
136  id = e.id;
137 
138  m_parent = e.m_parent;
139  m_sublist = new QList<Entry>;
140  m_sublist->setAutoDelete(TRUE);
141 
142  // deep copy of the child entry list
143  QListIterator<Entry> eli(*e.m_sublist);
144  Entry *cur;
145  for (;(cur=eli.current());++eli)
146  {
147  m_sublist->append(new Entry(*cur));
148  }
149 
150  // deep copy base class list
151  QListIterator<BaseInfo> bli(*e.extends);
152  BaseInfo *bi;
153  for (;(bi=bli.current());++bli)
154  {
155  extends->append(new BaseInfo(*bi));
156  }
157 
158  // deep copy group list
159  QListIterator<Grouping> gli(*e.groups);
160  Grouping *g;
161  for (;(g=gli.current());++gli)
162  {
163  groups->append(new Grouping(*g));
164  }
165 
166  QListIterator<SectionInfo> sli2(*e.anchors);
167  SectionInfo *s;
168  for (;(s=sli2.current());++sli2)
169  {
170  anchors->append(new SectionInfo(*s));
171  }
172 
173  // deep copy type constraint list
174  if (e.typeConstr)
175  {
177  }
178 
179  // deep copy template argument lists
180  if (e.tArgLists)
181  {
183  }
184 
185 }
186 
188 {
189  //printf("Entry::~Entry(%p) num=%d\n",this,num);
190  //printf("Deleting entry %d name %s type %x children %d\n",
191  // num,name.data(),section,sublist->count());
192 
193  delete m_sublist; // each element is now own by a EntryNav so we do no longer own
194  // our children.
195  delete extends;
196  delete groups;
197  delete anchors;
198  delete argList;
199  delete tArgLists;
200  delete tagInfo;
201  delete typeConstr;
202  delete sli;
203  num--;
204 }
205 
206 void Entry::addSubEntry(Entry *current)
207 {
208  //printf("Entry %d with name %s type 0x%x added to %s type 0x%x\n",
209  // current->num,current->name.data(),current->section,
210  // name.data(),section);
211  //printf("Entry::addSubEntry(%s:%p) to %s\n",current->name.data(),
212  // current,name.data());
213  current->m_parent=this;
214  m_sublist->append(current);
215 }
216 
218 {
219  static bool entryCallGraph = Config_getBool(CALL_GRAPH);
220  static bool entryCallerGraph = Config_getBool(CALLER_GRAPH);
221  //printf("Entry::reset()\n");
222  name.resize(0);
223  type.resize(0);
224  args.resize(0);
225  bitfields.resize(0);
226  exception.resize(0);
227  program.resize(0);
228  includeFile.resize(0);
229  includeName.resize(0);
230  doc.resize(0);
231  docFile.resize(0);
232  docLine=-1;
233  relates.resize(0);
235  brief.resize(0);
236  briefFile.resize(0);
237  briefLine=-1;
238  inbodyDocs.resize(0);
239  inbodyFile.resize(0);
240  inbodyLine=-1;
241  inside.resize(0);
242  fileName.resize(0);
243  initializer.resize(0);
244  initLines = -1;
245  startLine = 1;
246  startColumn = 1;
247  bodyLine = -1;
248  endBodyLine = -1;
249  mGrpId = -1;
250  callGraph = entryCallGraph;
251  callerGraph = entryCallerGraph;
252  section = EMPTY_SEC;
253  mtype = Method;
254  virt = Normal;
255  stat = FALSE;
256  proto = FALSE;
257  explicitExternal = FALSE;
258  spec = 0;
260  hidden = FALSE;
261  artificial = FALSE;
262  subGrouping = TRUE;
263  protection = Public;
265  id.resize(0);
266  m_sublist->clear();
267  extends->clear();
268  groups->clear();
269  anchors->clear();
270  argList->clear();
271  if (tagInfo) { delete tagInfo; tagInfo=0; }
272  if (tArgLists) { delete tArgLists; tArgLists=0; }
273  if (sli) { delete sli; sli=0; }
274  if (typeConstr) { delete typeConstr; typeConstr=0; }
275  //if (mtArgList) { delete mtArgList; mtArgList=0; }
276 }
277 
278 
280 {
281  return sizeof(Entry);
282 }
283 
285 {
286  EntryNav *childNav = new EntryNav(nav,this);
287  nav->addChild(childNav);
288  childNav->setFileDef(fd);
289  childNav->saveEntry(this,storage);
290  if (m_sublist)
291  {
292  //printf("saveEntry: %d children\n",node->sublist->count());
293  QListIterator<Entry> eli(*m_sublist);
294  Entry *childNode;
295  for (eli.toFirst();(childNode=eli.current());++eli)
296  {
297  childNode->createSubtreeIndex(childNav,storage,fd);
298  }
299  //m_sublist->setAutoDelete(FALSE);
300  m_sublist->clear();
301  }
302 }
303 
305 {
306  createSubtreeIndex(rootNav,storage,fd);
307 }
308 
309 void Entry::addSpecialListItem(const char *listName,int itemId)
310 {
311  if (sli==0)
312  {
313  sli = new QList<ListItemInfo>;
314  sli->setAutoDelete(TRUE);
315  }
316  ListItemInfo *ili=new ListItemInfo;
317  ili->type = listName;
318  ili->itemId = itemId;
319  sli->append(ili);
320 }
321 
323 {
324  int i = m_sublist->find(e);
325  return i!=-1 ? m_sublist->take(i) : 0;
326 }
327 
328 //------------------------------------------------------------------
329 
330 
332  : m_parent(parent), m_subList(0), m_section(e->section), m_type(e->type),
333  m_name(e->name), m_fileDef(0), m_lang(e->lang),
334  m_info(0), m_offset(-1), m_noLoad(FALSE)
335 {
336  if (e->tagInfo)
337  {
338  m_tagInfo = new TagInfo;
342  if (e->tagInfo)
343  {
344  //printf("tagInfo %p: tagName=%s fileName=%s anchor=%s\n",
345  // e->tagInfo,
346  // e->tagInfo->tagName.data(),
347  // e->tagInfo->fileName.data(),
348  // e->tagInfo->anchor.data());
349  }
350  }
351  else
352  {
353  m_tagInfo = 0;
354  }
355 }
356 
358 {
359  delete m_subList;
360  delete m_info;
361  delete m_tagInfo;
362 }
363 
365 {
366  if (m_subList==0)
367  {
368  m_subList = new QList<EntryNav>;
369  m_subList->setAutoDelete(TRUE);
370  }
371  m_subList->append(e);
372 }
373 
375 {
376  if (m_noLoad)
377  {
378  return TRUE;
379  }
380  if (m_offset==-1)
381  {
382  //printf("offset not set!\n");
383  return FALSE;
384  }
385  //delete m_info;
386  //printf("EntryNav::loadEntry: new entry %p: %s\n",m_info,m_name.data());
387  //m_info->tagInfo = m_tagInfo;
388  //if (m_parent)
389  //{
390  // m_info->parent = m_parent->m_info;
391  //}
392  //m_info->parent = 0;
393  //printf("load entry: seek to %llx\n",m_offset);
394  if (!storage->seek(m_offset))
395  {
396  //printf("seek failed!\n");
397  return FALSE;
398  }
399  if (m_info) delete m_info;
400  m_info = unmarshalEntry(storage);
401  m_info->name = m_name;
402  m_info->type = m_type;
404  return TRUE;
405 }
406 
408 {
409  m_offset = storage->pos();
410  //printf("EntryNav::saveEntry offset=%llx\n",m_offset);
411  marshalEntry(storage,e);
412  return TRUE;
413 }
414 
416 {
417  if (!m_noLoad)
418  {
419  //printf("EntryNav::releaseEntry %p\n",m_info);
420  delete m_info;
421  m_info=0;
422  }
423 }
424 
426 {
427  delete m_info;
428  m_info = e;
429  //printf("EntryNav::setEntry %p\n",e);
430  m_noLoad=TRUE;
431 }
432