Doxygen
Loading...
Searching...
No Matches
reflist.h
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#ifndef REFLIST_H
17#define REFLIST_H
18
19#include <unordered_map>
20#include <vector>
21
22#include "dstring.h"
23#include "linkedmap.h"
24#include "construct.h"
25
26class Definition;
27class RefList;
28
29static inline const DString doxygenList = "Doxygen_List_";
30
31/** This struct represents an item in the list of references. */
33{
34 public:
36
37 void setText (const DString &text) { m_text = text; }
40 void setName (const DString &name) { m_name = name; }
41 void setTitle (const DString &title) { m_title = title; }
42 void setArgs (const DString &args) { m_args = args; }
43 void setGroup (const DString &group) { m_group = group; }
44 void setScope (const Definition *scope) { m_scope = scope; }
45
46 DString text() const { return m_text; }
47 DString anchor() const { return m_anchor; }
48 DString prefix() const { return m_prefix; }
49 DString name() const { return m_name; }
50 DString title() const { return m_title; }
51 DString args() const { return m_args; }
52 DString group() const { return m_group; }
53 int id() const { return m_id; }
54 RefList *list() const { return m_list; }
55 const Definition *scope() const { return m_scope; }
56
57 private:
58 int m_id = 0; //!< unique identifier for this item within its list
59 RefList *m_list; //!< list owning this item
60 DString m_text; //!< text of the item.
61 DString m_anchor; //!< anchor in the list
62 DString m_prefix; //!< type prefix for the name
63 DString m_name; //!< name of the entity containing the reference
64 DString m_title; //!< display name of the entity
65 DString m_args; //!< optional arguments for the entity (if function)
66 DString m_group; //!< group id used to combine item under a single header
67 const Definition *m_scope = nullptr; //!< scope to use for references.
68};
69
70/** List of cross-referenced items
71 *
72 * This class represents a list of items that are put
73 * at a certain point in the documentation by some special command
74 * and are collected in a list. The items cross-reference the
75 * documentation and the list.
76 *
77 * Examples are the todo list, the test list and the bug list,
78 * introduced by the \\todo, \\test, and \\bug commands respectively.
79 */
81{
82 public:
83 /*! Create a list of items that are cross referenced with documentation blocks
84 * @param listName String representing the name of the list.
85 * @param pageTitle String representing the title of the list page.
86 * @param secTitle String representing the title of the section.
87 */
88 RefList(const DString &listName, const DString &pageTitle, const DString &secTitle);
89 bool isEnabled() const;
90
91 /*! Adds a new item to the list.
92 * @returns A unique id for this item.
93 */
94 RefItem *add();
95
96 /*! Returns an item given it's id that is obtained with addRefItem()
97 * @param itemId item's identifier.
98 * @returns A pointer to the todo item's structure.
99 */
100 RefItem *find(int itemId);
101
102 DString listName() const { return m_listName; }
103 DString fileName() const { return m_fileName; }
104 DString pageTitle() const { return m_pageTitle; }
105 DString sectionTitle() const { return m_secTitle; }
106
107 void generatePage();
108
109 private:
110 int m_id = 0;
115 std::vector< std::unique_ptr< RefItem > > m_entries;
116 std::unordered_map< int, RefItem* > m_lookup;
117};
118
119class RefListManager final : public LinkedMap<RefList>
120{
121 public:
123 {
124 static RefListManager rlm;
125 return rlm;
126 }
127
128 private:
129 RefListManager() = default;
130 ~RefListManager() = default;
132};
133
134using RefItemVector = std::vector<RefItem*>;
135
136inline void addRefItem(const RefItemVector &sli,
137 const DString &key, const DString &prefix, const DString &name,
138 const DString &title, const DString &args, const Definition *scope)
139{
140 //printf("addRefItem(sli=%d,key=%s,prefix=%s,name=%s,title=%s,args=%s)\n",(int)sli.size(),key,prefix,name,title,args);
141 if (!key.empty() && key[0]!='@') // check for @ to skip anonymous stuff (see bug427012)
142 {
143 for (RefItem *item : sli)
144 {
145 item->setPrefix(prefix);
146 item->setScope(scope);
147 item->setName(name);
148 item->setTitle(title);
149 item->setArgs(args);
150 item->setGroup(key);
151 }
152 }
153}
154
155
156#endif
constexpr auto prefix
Definition anchor.cpp:47
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
The common base class of all entity definitions found in the sources.
Definition definition.h:77
Container class representing a vector of objects with keys.
Definition linkedmap.h:36
This struct represents an item in the list of references.
Definition reflist.h:33
void setPrefix(const DString &prefix)
Definition reflist.h:39
DString args() const
Definition reflist.h:51
void setTitle(const DString &title)
Definition reflist.h:41
RefItem(int id, RefList *list)
Definition reflist.h:35
DString anchor() const
Definition reflist.h:47
const Definition * scope() const
Definition reflist.h:55
void setGroup(const DString &group)
Definition reflist.h:43
int id() const
Definition reflist.h:53
DString text() const
Definition reflist.h:46
DString m_anchor
anchor in the list
Definition reflist.h:61
DString group() const
Definition reflist.h:52
RefList * m_list
list owning this item
Definition reflist.h:59
DString m_args
optional arguments for the entity (if function)
Definition reflist.h:65
void setText(const DString &text)
Definition reflist.h:37
DString prefix() const
Definition reflist.h:48
DString title() const
Definition reflist.h:50
DString m_prefix
type prefix for the name
Definition reflist.h:62
DString m_text
text of the item.
Definition reflist.h:60
RefList * list() const
Definition reflist.h:54
DString m_title
display name of the entity
Definition reflist.h:64
const Definition * m_scope
scope to use for references.
Definition reflist.h:67
DString m_group
group id used to combine item under a single header
Definition reflist.h:66
DString name() const
Definition reflist.h:49
DString m_name
name of the entity containing the reference
Definition reflist.h:63
void setAnchor(const DString &anchor)
Definition reflist.h:38
void setArgs(const DString &args)
Definition reflist.h:42
void setName(const DString &name)
Definition reflist.h:40
void setScope(const Definition *scope)
Definition reflist.h:44
int m_id
unique identifier for this item within its list
Definition reflist.h:58
List of cross-referenced items.
Definition reflist.h:81
DString m_pageTitle
Definition reflist.h:113
std::unordered_map< int, RefItem * > m_lookup
Definition reflist.h:116
void generatePage()
Definition reflist.cpp:60
std::vector< std::unique_ptr< RefItem > > m_entries
Definition reflist.h:115
DString sectionTitle() const
Definition reflist.h:105
DString listName() const
Definition reflist.h:102
DString m_secTitle
Definition reflist.h:114
DString m_listName
Definition reflist.h:111
int m_id
Definition reflist.h:110
DString pageTitle() const
Definition reflist.h:104
DString fileName() const
Definition reflist.h:103
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:112
bool isEnabled() const
Definition reflist.cpp:51
~RefListManager()=default
RefListManager()=default
static RefListManager & instance()
Definition reflist.h:122
#define NON_COPYABLE(cls)
Macro to help implementing the rule of 5 for a non-copyable & movable class.
Definition construct.h:37
void addRefItem(const RefItemVector &sli, const DString &key, const DString &prefix, const DString &name, const DString &title, const DString &args, const Definition *scope)
Definition reflist.h:136
std::vector< RefItem * > RefItemVector
Definition reflist.h:134
static const DString doxygenList
Definition reflist.h:29