Doxygen
Loading...
Searching...
No Matches
reflist.cpp
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2020 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16// own header
17#include "reflist.h"
18
19// standard includes
20#include <algorithm>
21#include <memory>
22
23// other includes
24#include "config.h"
25#include "definition.h"
26#include "pagedef.h"
27#include "util.h"
28
34
36{
37 m_id++;
38 std::unique_ptr<RefItem> item = std::make_unique<RefItem>(m_id,this);
39 RefItem *result = item.get();
40 m_entries.push_back(std::move(item));
41 m_lookup.emplace(m_id,result);
42 return result;
43}
44
46{
47 auto it = m_lookup.find(itemId);
48 return it!=m_lookup.end() ? it->second : nullptr;
49}
50
52{
53 if (m_listName=="todo" && !Config_getBool(GENERATE_TODOLIST)) return false;
54 else if (m_listName=="test" && !Config_getBool(GENERATE_TESTLIST)) return false;
55 else if (m_listName=="bug" && !Config_getBool(GENERATE_BUGLIST)) return false;
56 else if (m_listName=="deprecated" && !Config_getBool(GENERATE_DEPRECATEDLIST)) return false;
57 return true;
58}
59
61{
62 if (!isEnabled()) return;
63
64 std::stable_sort(m_entries.begin(),m_entries.end(),
65 [](const std::unique_ptr<RefItem> &left,const std::unique_ptr<RefItem> &right)
66 { return dstricmp_sort(left->title(),right->title()) < 0; });
67 //RefItem *item;
68 DString doc;
69 int cnt = 0;
70 doc += "<dl class=\"reflist\">";
71 DString lastGroup;
72 bool first=true;
73 for (const std::unique_ptr<RefItem> &item : m_entries)
74 {
75 if (item->name().empty()) continue;
76 cnt++;
77 bool startNewGroup = item->group()!=lastGroup;
78 if (startNewGroup)
79 {
80 if (!first)
81 {
82 doc += "</dd>";
83 }
84 doc += " <dt>";
85 doc += "\n";
86 if (item->scope())
87 {
88 if (item->scope()->name() != "<globalScope>")
89 {
90 doc += "\\_setscope ";
91 doc += item->scope()->name();
92 doc += " ";
93 }
94 }
95 doc += item->prefix();
96 doc += " \\_internalref ";
97 doc += item->name();
98 // escape \'s in title, see issue #5901
99 DString escapedTitle = substitute(item->title(),"\\","\\\\");
100 doc += " \""+escapedTitle+"\" ";
101 // write declaration in case a function with arguments
102 if (!item->args().empty())
103 {
104 // escape @'s in argument list, needed for Java annotations (see issue #6208)
105 // escape \'s in argument list (see issue #6533)
106 doc += substitute(substitute(item->args(),"@","@@"),"\\","\\\\");
107 }
108 doc += "</dt><dd>";
109 }
110 else
111 {
112 doc += "<p>";
113 }
114 doc += " \\anchor ";
115 doc += item->anchor();
116 doc += " ";
117 doc += item->text();
118 lastGroup = item->group();
119 first = false;
120 }
121 if (!first)
122 {
123 doc += "</dd>";
124 }
125 doc += "</dl>\n";
126 //printf("generatePage('%s')\n",doc.data());
127 if (cnt>0)
128 {
129 addRelatedPage(m_listName,m_pageTitle,doc,m_fileName,1,1,RefItemVector(),nullptr,nullptr,true);
130 }
131}
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
This struct represents an item in the list of references.
Definition reflist.h:31
DString m_pageTitle
Definition reflist.h:111
std::unordered_map< int, RefItem * > m_lookup
Definition reflist.h:114
void generatePage()
Definition reflist.cpp:60
std::vector< std::unique_ptr< RefItem > > m_entries
Definition reflist.h:113
DString listName() const
Definition reflist.h:100
DString m_secTitle
Definition reflist.h:112
DString m_listName
Definition reflist.h:109
int m_id
Definition reflist.h:108
DString pageTitle() const
Definition reflist.h:102
RefItem * add()
Definition reflist.cpp:35
RefList(const DString &listName, const DString &pageTitle, const DString &secTitle)
Definition reflist.cpp:29
RefItem * find(int itemId)
Definition reflist.cpp:45
DString m_fileName
Definition reflist.h:110
bool isEnabled() const
Definition reflist.cpp:51
#define Config_getBool(name)
Definition config.h:33
DString substitute(const DString &s, const DString &src, const DString &dst)
substitute all occurrences of src in s by dst
Definition dstring.cpp:485
PageDef * addRelatedPage(const DString &name, const DString &ptitle, const DString &doc, const DString &fileName, int docLine, int startLine, const RefItemVector &sli, GroupDef *gd, const TagInfo *tagInfo, bool xref, SrcLangExt lang)
Definition pagedef.cpp:524
std::vector< RefItem * > RefItemVector
Definition reflist.h:132
DString convertNameToFile(const DString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:2863
A bunch of utility functions.