Doxygen
Toggle main menu visibility
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
#include <algorithm>
17
#include <stdio.h>
18
19
#include "
reflist.h
"
20
#include "
util.h
"
21
#include "
definition.h
"
22
#include "
config.h
"
23
24
RefList::RefList
(
const
QCString
&
listName
,
const
QCString
&
pageTitle
,
const
QCString
&secTitle) :
25
m_listName
(
listName
),
m_fileName
(
convertNameToFile
(
listName
,
FALSE
,
TRUE
)),
26
m_pageTitle
(
pageTitle
),
m_secTitle
(secTitle)
27
{
28
}
29
30
RefItem
*
RefList::add
()
31
{
32
m_id
++;
33
std::unique_ptr<RefItem> item = std::make_unique<RefItem>(
m_id
,
this
);
34
RefItem
*result = item.get();
35
m_entries
.push_back(std::move(item));
36
m_lookup
.emplace(
m_id
,result);
37
return
result;
38
}
39
40
RefItem
*
RefList::find
(
int
itemId)
41
{
42
auto
it =
m_lookup
.find(itemId);
43
return
it!=
m_lookup
.end() ? it->second :
nullptr
;
44
}
45
46
bool
RefList::isEnabled
()
const
47
{
48
if
(
m_listName
==
"todo"
&& !
Config_getBool
(GENERATE_TODOLIST))
return
false
;
49
else
if
(
m_listName
==
"test"
&& !
Config_getBool
(GENERATE_TESTLIST))
return
false
;
50
else
if
(
m_listName
==
"bug"
&& !
Config_getBool
(GENERATE_BUGLIST))
return
false
;
51
else
if
(
m_listName
==
"deprecated"
&& !
Config_getBool
(GENERATE_DEPRECATEDLIST))
return
false
;
52
return
true
;
53
}
54
55
void
RefList::generatePage
()
56
{
57
if
(!
isEnabled
())
return
;
58
59
std::stable_sort(
m_entries
.begin(),
m_entries
.end(),
60
[](
const
std::unique_ptr<RefItem> &left,
const
std::unique_ptr<RefItem> &right)
61
{ return qstricmp_sort(left->title(),right->title()) < 0; });
62
//RefItem *item;
63
QCString
doc;
64
int
cnt = 0;
65
doc +=
"<dl class=\"reflist\">"
;
66
QCString
lastGroup;
67
bool
first=
true
;
68
for
(
const
std::unique_ptr<RefItem> &item :
m_entries
)
69
{
70
if
(item->name().isEmpty())
continue
;
71
cnt++;
72
bool
startNewGroup = item->group()!=lastGroup;
73
if
(startNewGroup)
74
{
75
if
(!first)
76
{
77
doc +=
"</dd>"
;
78
}
79
doc +=
" <dt>"
;
80
doc +=
"\n"
;
81
if
(item->scope())
82
{
83
if
(item->scope()->name() !=
"<globalScope>"
)
84
{
85
doc +=
"\\_setscope "
;
86
doc += item->scope()->name();
87
doc +=
" "
;
88
}
89
}
90
doc += item->prefix();
91
doc +=
" \\_internalref "
;
92
doc += item->name();
93
// escape \'s in title, see issue #5901
94
QCString
escapedTitle =
substitute
(item->title(),
"\\"
,
"\\\\"
);
95
doc +=
" \""
+escapedTitle+
"\" "
;
96
// write declaration in case a function with arguments
97
if
(!item->args().isEmpty())
98
{
99
// escape @'s in argument list, needed for Java annotations (see issue #6208)
100
// escape \'s in argument list (see issue #6533)
101
doc +=
substitute
(
substitute
(item->args(),
"@"
,
"@@"
),
"\\"
,
"\\\\"
);
102
}
103
doc +=
"</dt><dd>"
;
104
}
105
else
106
{
107
doc +=
"<p>"
;
108
}
109
doc +=
" \\anchor "
;
110
doc += item->anchor();
111
doc +=
" "
;
112
doc += item->text();
113
lastGroup = item->group();
114
first =
false
;
115
}
116
if
(!first)
117
{
118
doc +=
"</dd>"
;
119
}
120
doc +=
"</dl>\n"
;
121
//printf("generatePage('%s')\n",doc.data());
122
if
(cnt>0)
123
{
124
addRelatedPage
(
m_listName
,
m_pageTitle
,doc,
m_fileName
,1,1,
RefItemVector
(),
nullptr
,
nullptr
,
TRUE
);
125
}
126
}
QCString
This is an alternative implementation of QCString.
Definition
qcstring.h:101
RefItem
This struct represents an item in the list of references.
Definition
reflist.h:32
RefList::m_lookup
std::unordered_map< int, RefItem * > m_lookup
Definition
reflist.h:115
RefList::m_listName
QCString m_listName
Definition
reflist.h:110
RefList::generatePage
void generatePage()
Definition
reflist.cpp:55
RefList::m_secTitle
QCString m_secTitle
Definition
reflist.h:113
RefList::m_entries
std::vector< std::unique_ptr< RefItem > > m_entries
Definition
reflist.h:114
RefList::RefList
RefList(const QCString &listName, const QCString &pageTitle, const QCString &secTitle)
Definition
reflist.cpp:24
RefList::pageTitle
QCString pageTitle() const
Definition
reflist.h:103
RefList::m_pageTitle
QCString m_pageTitle
Definition
reflist.h:112
RefList::m_id
int m_id
Definition
reflist.h:109
RefList::listName
QCString listName() const
Definition
reflist.h:101
RefList::m_fileName
QCString m_fileName
Definition
reflist.h:111
RefList::add
RefItem * add()
Definition
reflist.cpp:30
RefList::find
RefItem * find(int itemId)
Definition
reflist.cpp:40
RefList::isEnabled
bool isEnabled() const
Definition
reflist.cpp:46
config.h
Config_getBool
#define Config_getBool(name)
Definition
config.h:33
definition.h
addRelatedPage
static void addRelatedPage(Entry *root)
Definition
doxygen.cpp:329
substitute
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
Definition
qcstring.cpp:571
TRUE
#define TRUE
Definition
qcstring.h:37
FALSE
#define FALSE
Definition
qcstring.h:34
reflist.h
RefItemVector
std::vector< RefItem * > RefItemVector
Definition
reflist.h:133
convertNameToFile
QCString convertNameToFile(const QCString &name, bool allowDots, bool allowUnderscore)
Definition
util.cpp:3485
util.h
A bunch of utility functions.
src
reflist.cpp
Generated by
1.17.0