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>;
46  groups = new QList<Grouping>;
48  anchors = new QList<SectionInfo>; // Doxygen::sectionDict takes ownership of the items!
49  argList = new ArgumentList;
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>;
111  groups = new QList<Grouping>;
114  fileName = e.fileName;
115  startLine = e.startLine;
117  if (e.sli)
118  {
119  sli = new QList<ListItemInfo>;
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>;
141 
142  // deep copy of the child entry list
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
152  BaseInfo *bi;
153  for (;(bi=bli.current());++bli)
154  {
155  extends->append(new BaseInfo(*bi));
156  }
157 
158  // deep copy group list
160  Grouping *g;
161  for (;(g=gli.current());++gli)
162  {
163  groups->append(new Grouping(*g));
164  }
165 
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 
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;
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());
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>;
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  {
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 
bool callGraph
do we need to draw the call graph?
Definition: entry.h:249
TagInfo * tagInfo
tag file info
Definition: entry.h:238
Definition: types.h:61
QGString program
the program text
Definition: entry.h:256
TagInfo * m_tagInfo
tag file info
Definition: entry.h:366
bool resize(uint newlen)
Definition: qcstring.h:225
QCString includeName
include name (3 arg of \class)
Definition: entry.h:259
QList< EntryNav > * m_subList
entries that are children of this one
Definition: entry.h:360
void reset()
Definition: entry.cpp:217
This class represents an function or template argument list.
Definition: arguments.h:82
QList< ArgumentList > * copyArgumentLists(const QList< ArgumentList > *srcLists)
Definition: util.cpp:6205
bool proto
prototype ?
Definition: entry.h:247
uint64 spec
class/member specifiers
Definition: entry.h:243
bool stat
static ?
Definition: entry.h:245
bool seek(int64 pos)
Definition: filestorage.h:37
static constexpr double g
Definition: Units.h:144
void append(const type *d)
Definition: qlist.h:73
Definition: entry.h:63
QCString read
property read accessor
Definition: entry.h:271
Definition: types.h:26
static int num
counts the total number of entries
Definition: entry.h:293
int briefLine
line number at which the brief desc. was found
Definition: entry.h:264
Definition: types.h:35
int docLine
line number at which the documentation was found
Definition: entry.h:261
const bool FALSE
Definition: qglobal.h:370
ArgumentList * argList
member arguments as a list
Definition: entry.h:254
QCString m_type
member type
Definition: entry.h:364
void addSubEntry(Entry *e)
Definition: entry.cpp:206
QCString name
member name
Definition: entry.h:237
bool resize(uint newlen)
Definition: qgstring.cpp:96
int initLines
define/variable initializer lines to show
Definition: entry.h:244
Store implementation based on a file. Writing is linear, after that the file is re-opened for reading...
Definition: filestorage.h:28
Definition: entry.h:50
void addSpecialListItem(const char *listName, int index)
Definition: entry.cpp:309
QCString id
libclang id
Definition: entry.h:290
int find(const type *d) const
Definition: qlist.h:88
void setFileDef(FileDef *fd)
Definition: entry.h:344
Entry * unmarshalEntry(StorageIntf *s)
Definition: marshal.cpp:727
bool hidden
does this represent an entity that is hidden from the output
Definition: entry.h:287
void setEntry(Entry *e)
Definition: entry.cpp:425
Entry * parent() const
Definition: entry.h:205
Definition: types.h:29
int mGrpId
member group id
Definition: entry.h:278
Entry()
Definition: entry.cpp:36
QList< ArgumentList > * tArgLists
template argument declarations
Definition: entry.h:255
QCString anchor
Definition: entry.h:54
int startColumn
start column of entry in the source
Definition: entry.h:284
void releaseEntry()
Definition: entry.cpp:415
int itemId
Definition: types.h:101
QCString tagName
Definition: entry.h:52
QCString includeFile
include file (2 arg of \class, must be unique)
Definition: entry.h:258
bool subGrouping
automatically group class members?
Definition: entry.h:248
const double e
bool callerGraph
do we need to draw the caller graph?
Definition: entry.h:250
QList< Grouping > * groups
list of groups this entry belongs to
Definition: entry.h:280
QGString initializer
initial value (for variables)
Definition: entry.h:257
QCString inbodyFile
file in which the body doc was found
Definition: entry.h:268
~Entry()
Definition: entry.cpp:187
QCString brief
brief description (doc block)
Definition: entry.h:263
int endBodyLine
line number where the definition ends
Definition: entry.h:277
ArgumentList * typeConstr
where clause (C#) for type constraints
Definition: entry.h:275
Definition: types.h:32
Entry * m_parent
parent node in the tree
Definition: entry.h:323
int64 pos() const
Definition: filestorage.h:38
QList< SectionInfo > * anchors
list of anchors defined in this entry
Definition: entry.h:281
QCString exception
throw specification
Definition: entry.h:274
int getSize()
Definition: entry.cpp:279
int startLine
start line of entry in the source
Definition: entry.h:283
bool saveEntry(Entry *e, FileStorage *storage)
Definition: entry.cpp:407
QCString args
member argument string
Definition: entry.h:252
QCString write
property write accessor
Definition: entry.h:272
A bunch of utility functions.
void clear()
Definition: qlist.h:82
static Entry * current
Entry * m_info
Definition: entry.h:370
QList< Entry > * m_sublist
entries that are children of this one
Definition: entry.h:324
General LArSoft Utilities.
type * current() const
Definition: qlist.h:146
Protection protection
class protection
Definition: entry.h:241
#define Config_getBool(val)
Definition: config.cpp:664
QCString m_name
member name
Definition: entry.h:365
void marshalEntry(StorageIntf *s, Entry *e)
Definition: marshal.cpp:347
bool loadEntry(FileStorage *storage)
Definition: entry.cpp:374
RelatesType relatesType
how relates is handled
Definition: entry.h:270
QCString inbodyDocs
documentation inside the body of a function
Definition: entry.h:266
QCString doc
documentation block (partly parsed)
Definition: entry.h:260
Specifier virt
virtualness of the entry
Definition: entry.h:251
bool artificial
Artificially introduced item.
Definition: entry.h:288
GroupDocType groupDocType
Definition: entry.h:289
QCString fileName
Definition: entry.h:53
QCString fileName
file this entry was extracted from
Definition: entry.h:282
bool explicitExternal
explicitly defined as external?
Definition: entry.h:246
QCString bitfields
member&#39;s bit fields
Definition: entry.h:253
QCString type
Definition: types.h:100
QCString inside
name of the class in which documents are found
Definition: entry.h:273
EntryNav(EntryNav *parent, Entry *e)
Definition: entry.cpp:331
int64 m_offset
Definition: entry.h:371
ArgumentList * deepCopy() const
Definition: arguments.cpp:20
QCString docFile
file in which the documentation was found
Definition: entry.h:262
MethodTypes mtype
signal, slot, (dcop) method, or property?
Definition: entry.h:242
QCString relates
related class (doc block)
Definition: entry.h:269
void createNavigationIndex(EntryNav *rootNav, FileStorage *storage, FileDef *fd)
Definition: entry.cpp:304
type * take(uint i)
Definition: qlist.h:81
SrcLangExt lang
programming language in which this entry was found
Definition: entry.h:286
int inbodyLine
line number at which the body doc was found
Definition: entry.h:267
Definition: entry.h:37
Entry * removeSubEntry(Entry *e)
Definition: entry.cpp:322
void setAutoDelete(bool enable)
Definition: qlist.h:99
void addChild(EntryNav *)
Definition: entry.cpp:364
static QCString * s
Definition: config.cpp:1042
const bool TRUE
Definition: qglobal.h:371
QList< BaseInfo > * extends
list of base classes
Definition: entry.h:279
~EntryNav()
Definition: entry.cpp:357
int m_section
entry type (see Sections);
Definition: entry.h:363
QCString type
member type
Definition: entry.h:236
int section
entry type (see Sections);
Definition: entry.h:235
void createSubtreeIndex(EntryNav *nav, FileStorage *storage, FileDef *fd)
Definition: entry.cpp:284
bool m_noLoad
Definition: entry.h:372
int bodyLine
line number of the definition in the source
Definition: entry.h:276
QCString briefFile
file in which the brief desc. was found
Definition: entry.h:265
QList< ListItemInfo > * sli
special lists (test/todo/bug/deprecated/..) this entry is in
Definition: entry.h:285
type * toFirst()
Definition: qlist.h:135