reflist.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  *
4  *
5  *
6  * Copyright (C) 1997-2015 by Dimitri van Heesch.
7  *
8  * Permission to use, copy, modify, and distribute this software and its
9  * documentation under the terms of the GNU General Public License is hereby
10  * granted. No representations are made about the suitability of this software
11  * for any purpose. It is provided "as is" without express or implied warranty.
12  * See the GNU General Public License for more details.
13  *
14  * Documents produced by Doxygen are derivative works derived from the
15  * input used in their production; they are not affected by this license.
16  *
17  */
18 
19 #include <stdio.h>
20 #include "reflist.h"
21 #include "util.h"
22 #include "ftextstream.h"
23 #include "definition.h"
24 
25 /*! Create a list of items that are cross referenced with documentation blocks
26  * @param listName String representing the name of the list.
27  * @param pageTitle String representing the title of the list page.
28  * @param secTitle String representing the title of the section.
29  */
30 RefList::RefList(const char *listName,
31  const char *pageTitle,
32  const char *secTitle
33  )
34 {
35  m_itemList = 0;
36  m_dict = 0;
37  m_dictIterator = 0;
38  m_id = 0;
42  m_secTitle = secTitle;
43 }
44 
45 /*! Destroy the todo list. Currently not called! */
47 {
48  delete m_dictIterator;
49  delete m_dict;
50  delete m_itemList;
51 }
52 
53 /*! Adds a new item to the list.
54  * \returns A unique id for this item.
55  */
57 {
58  if (m_dict==0)
59  {
60  m_dict = new QIntDict<RefItem>(1009);
63  }
64  RefItem *item = new RefItem;
65  m_id++;
66  m_dict->insert(m_id,item);
67  return m_id;
68 }
69 
70 /*! Returns an item given it's id that is obtained with addRefItem()
71  * \param itemId item's identifier.
72  * \returns A pointer to the todo item's structure.
73  */
75 {
76  return m_dict ? m_dict->find(itemId) : 0;
77 }
78 
79 /*! Returns the first item in the dictionary or 0 if
80  * non is available.
81  * Items are not sorted.
82  */
84 {
85  return m_dictIterator ? m_dictIterator->toFirst() : 0;
86 }
87 
88 /*! Returns the next item in the dictionary or 0 if
89  * we are at the end of the list.
90  * Items are not sorted.
91  */
93 {
94  return m_dictIterator ? m_dictIterator->operator++() : 0;
95 }
96 
97 /*! Returns the name of the list as set in the constructor. */
99 {
100  return m_listName;
101 }
102 
104 {
105  return m_fileName;
106 }
107 
109 {
110  return m_pageTitle;
111 }
112 
114 {
115  return m_secTitle;
116 }
117 
118 void RefList::insertIntoList(const char *key,RefItem *item)
119 {
120  if (m_itemList==0)
121  {
122  m_itemList = new SortedRefItems(1009);
123  }
124  RefItem *ri = m_itemList->find(key);
125  if (ri==0)
126  {
127  m_itemList->append(key,item);
128  }
129  else // item already added to the list (i.e. multiple item for the same
130  // entity)
131  {
132  if (ri!=item)
133  {
134  ri->extraItems.append(item);
135  }
136  }
137 }
138 
139 
141 {
142  if (m_itemList==0) return;
143  m_itemList->sort();
145  RefItem *item;
146  QCString doc;
147  doc += "<dl class=\"reflist\">";
148  for (it.toFirst();(item=it.current());++it)
149  {
150  doc += " <dt>";
151  doc += "\\anchor ";
152  doc += item->listAnchor;
153  doc += "\n";
154  if (item->scope)
155  {
156  if (item->scope->name() != "<globalScope>")
157  {
158  doc += "\\_setscope ";
159  doc += item->scope->name();
160  doc += " ";
161  }
162  }
163  doc += item->prefix;
164  doc += " \\_internalref ";
165  doc += item->name;
166  doc += " \"";
167  doc += item->title;
168  doc += "\" ";
169  // write declaration in case a function with arguments
170  if (!item->args.isEmpty())
171  {
172  doc += item->args;
173  }
174  doc += "</dt><dd> ";
175  doc += item->text;
177  RefItem *extraItem;
178  for (li.toFirst();(extraItem=li.current());++li)
179  {
180  doc += "<p>" + extraItem->text;
181  }
182  doc += "</dd>";
183  }
184  doc += "</dl>\n";
185  //printf("generatePage('%s')\n",doc.data());
187 }
188 
QCString listAnchor
anchor in the list
Definition: reflist.h:33
QCString prefix
type prefix for the name
Definition: reflist.h:35
QCString title
display name of the entity
Definition: reflist.h:38
QCString m_pageTitle
Definition: reflist.h:90
bool isEmpty() const
Definition: qcstring.h:189
~RefList()
Definition: reflist.cpp:46
void generatePage()
Definition: reflist.cpp:140
QCString text
text of the item.
Definition: reflist.h:32
void append(const type *d)
Definition: qlist.h:73
QCString sectionTitle() const
Definition: reflist.cpp:113
QCString listName() const
Definition: reflist.cpp:98
const bool FALSE
Definition: qglobal.h:370
RefList(const char *listName, const char *pageTitle, const char *secTitle)
Definition: reflist.cpp:30
RefItem * getNextRefItem()
Definition: reflist.cpp:92
RefItem * getRefItem(int todoItemId)
Definition: reflist.cpp:74
void append(const char *key, const T *d)
Definition: sortdict.h:135
QCString pageTitle() const
Definition: reflist.cpp:108
Definition: sortdict.h:73
QIntDictIterator< RefItem > * m_dictIterator
Definition: reflist.h:94
void insert(long k, const type *d)
Definition: qintdict.h:57
const QCString & name() const
Definition: definition.h:114
def key(type, name=None)
Definition: graph.py:13
QCString fileName() const
Definition: reflist.cpp:103
A bunch of utility functions.
QCString m_listName
Definition: reflist.h:88
type * current() const
Definition: qlist.h:146
int m_id
Definition: reflist.h:87
QCString name
name of the entity containing the reference
Definition: reflist.h:37
static void addRelatedPage(EntryNav *rootNav)
Definition: doxygen.cpp:577
void setAutoDelete(bool enable)
Definition: qcollection.h:55
void sort()
Definition: sortdict.h:188
RefItem * getFirstRefItem()
Definition: reflist.cpp:83
QCString m_fileName
Definition: reflist.h:89
SortedRefItems * m_itemList
Definition: reflist.h:92
QCString convertNameToFile(const char *name, bool allowDots, bool allowUnderscore)
Definition: util.cpp:5354
QCString doc
Definition * scope
scope to use for references.
Definition: reflist.h:36
type * toFirst()
Definition: qintdict.h:92
QCString m_secTitle
Definition: reflist.h:91
T * find(const char *key)
Definition: sortdict.h:232
QCString args
optional arguments for the entity (if function)
Definition: reflist.h:39
void insertIntoList(const char *key, RefItem *item)
Definition: reflist.cpp:118
QList< RefItem > extraItems
more items belonging to the same entity
Definition: reflist.h:41
const bool TRUE
Definition: qglobal.h:371
type * find(long k) const
Definition: qintdict.h:63
QIntDict< RefItem > * m_dict
Definition: reflist.h:93
int addRefItem()
Definition: reflist.cpp:56
type * toFirst()
Definition: qlist.h:135