Doxygen
Loading...
Searching...
No Matches
RefList Class Reference

List of cross-referenced items. More...

#include <src/reflist.h>

Collaboration diagram for RefList:

Public Member Functions

 RefList (const DString &listName, const DString &pageTitle, const DString &secTitle)
bool isEnabled () const
RefItemadd ()
RefItemfind (int itemId)
DString listName () const
DString fileName () const
DString pageTitle () const
DString sectionTitle () const
void generatePage ()

Private Attributes

int m_id = 0
DString m_listName
DString m_fileName
DString m_pageTitle
DString m_secTitle
std::vector< std::unique_ptr< RefItem > > m_entries
std::unordered_map< int, RefItem * > m_lookup

Detailed Description

List of cross-referenced items.

This class represents a list of items that are put at a certain point in the documentation by some special command and are collected in a list. The items cross-reference the documentation and the list.

Examples are the todo list, the test list and the bug list, introduced by the \todo, \test, and \bug commands respectively.

Definition at line 78 of file reflist.h.

Constructor & Destructor Documentation

◆ RefList()

RefList::RefList ( const DString & listName,
const DString & pageTitle,
const DString & secTitle )

Create a list of items that are cross referenced with documentation blocks

Parameters
listNameString representing the name of the list.
pageTitleString representing the title of the list page.
secTitleString representing the title of the section.

Definition at line 29 of file reflist.cpp.

29 :
32{
33}
DString m_pageTitle
Definition reflist.h:111
DString listName() const
Definition reflist.h:100
DString m_secTitle
Definition reflist.h:112
DString m_listName
Definition reflist.h:109
DString pageTitle() const
Definition reflist.h:102
DString m_fileName
Definition reflist.h:110
DString convertNameToFile(const DString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:2863

References convertNameToFile(), listName(), m_fileName, m_listName, m_pageTitle, m_secTitle, and pageTitle().

Member Function Documentation

◆ add()

RefItem * RefList::add ( )

Adds a new item to the list.

Returns
A unique id for this item.

Definition at line 35 of file reflist.cpp.

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}
std::unordered_map< int, RefItem * > m_lookup
Definition reflist.h:114
std::vector< std::unique_ptr< RefItem > > m_entries
Definition reflist.h:113
int m_id
Definition reflist.h:108

References m_entries, m_id, and m_lookup.

Referenced by addXRefItemToEntry().

◆ fileName()

DString RefList::fileName ( ) const
inline

Definition at line 101 of file reflist.h.

101{ return m_fileName; }

References m_fileName.

Referenced by DocXRefItem::parse().

◆ find()

RefItem * RefList::find ( int itemId)

Returns an item given it's id that is obtained with addRefItem()

Parameters
itemIditem's identifier.
Returns
A pointer to the todo item's structure.

Definition at line 45 of file reflist.cpp.

46{
47 auto it = m_lookup.find(itemId);
48 return it!=m_lookup.end() ? it->second : nullptr;
49}

References m_lookup.

Referenced by DocXRefItem::parse().

◆ generatePage()

void RefList::generatePage ( )

Definition at line 60 of file reflist.cpp.

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}
bool isEnabled() const
Definition reflist.cpp:51
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

References addRelatedPage(), isEnabled(), m_entries, m_fileName, m_listName, m_pageTitle, and substitute().

◆ isEnabled()

bool RefList::isEnabled ( ) const

Definition at line 51 of file reflist.cpp.

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}
#define Config_getBool(name)
Definition config.h:33

References Config_getBool, and m_listName.

Referenced by generatePage(), and DocXRefItem::parse().

◆ listName()

DString RefList::listName ( ) const
inline

Definition at line 100 of file reflist.h.

100{ return m_listName; }

References m_listName.

Referenced by DefinitionImpl::_getXRefListId(), addXRefItemToEntry(), and RefList().

◆ pageTitle()

DString RefList::pageTitle ( ) const
inline

Definition at line 102 of file reflist.h.

102{ return m_pageTitle; }

References m_pageTitle.

Referenced by RefList().

◆ sectionTitle()

DString RefList::sectionTitle ( ) const
inline

Definition at line 103 of file reflist.h.

103{ return m_secTitle; }

References m_secTitle.

Referenced by DocXRefItem::parse().

Member Data Documentation

◆ m_entries

std::vector< std::unique_ptr< RefItem > > RefList::m_entries
private

Definition at line 113 of file reflist.h.

Referenced by add(), and generatePage().

◆ m_fileName

DString RefList::m_fileName
private

Definition at line 110 of file reflist.h.

Referenced by fileName(), generatePage(), and RefList().

◆ m_id

int RefList::m_id = 0
private

Definition at line 108 of file reflist.h.

Referenced by add().

◆ m_listName

DString RefList::m_listName
private

Definition at line 109 of file reflist.h.

Referenced by generatePage(), isEnabled(), listName(), and RefList().

◆ m_lookup

std::unordered_map< int, RefItem* > RefList::m_lookup
private

Definition at line 114 of file reflist.h.

Referenced by add(), and find().

◆ m_pageTitle

DString RefList::m_pageTitle
private

Definition at line 111 of file reflist.h.

Referenced by generatePage(), pageTitle(), and RefList().

◆ m_secTitle

DString RefList::m_secTitle
private

Definition at line 112 of file reflist.h.

Referenced by RefList(), and sectionTitle().


The documentation for this class was generated from the following files: