My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
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;
40  m_fileName = convertNameToFile(listName,FALSE,TRUE);
42  m_secTitle = secTitle;
43 }
44 
47 {
48  delete m_dictIterator;
49  delete m_dict;
50  delete m_itemList;
51 }
52 
57 {
58  if (m_dict==0)
59  {
60  m_dict = new QIntDict<RefItem>(1009);
61  m_dict->setAutoDelete(TRUE);
62  m_dictIterator = new QIntDictIterator<RefItem>(*m_dict);
63  }
64  RefItem *item = new RefItem;
65  m_id++;
66  m_dict->insert(m_id,item);
67  return m_id;
68 }
69 
75 {
76  return m_dict ? m_dict->find(itemId) : 0;
77 }
78 
84 {
85  return m_dictIterator ? m_dictIterator->toFirst() : 0;
86 }
87 
93 {
94  return m_dictIterator ? m_dictIterator->operator++() : 0;
95 }
96 
98 QCString RefList::listName() const
99 {
100  return m_listName;
101 }
102 
103 QCString RefList::fileName() const
104 {
105  return m_fileName;
106 }
107 
108 QCString RefList::pageTitle() const
109 {
110  return m_pageTitle;
111 }
112 
113 QCString RefList::sectionTitle() const
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;
176  QListIterator<RefItem> li(item->extraItems);
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