Doxygen
Loading...
Searching...
No Matches
memberlist.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 MEMBERLIST_H
17#define MEMBERLIST_H
18
19#include <vector>
20#include <algorithm>
21
22#include "memberdef.h"
23#include "linkedmap.h"
24#include "types.h"
25#include "membergroup.h"
26#include "construct.h"
27
28class GroupDef;
29
30int genericCompareMembers(const MemberDef *c1,const MemberDef *c2);
31
32/** A vector of MemberDef object */
34{
35 public:
36 using T = MemberDef*;
37 using Vec = std::vector<T>;
38 using value_type = Vec::value_type;
39 using allocator_type = Vec::allocator_type;
40 using size_type = Vec::size_type;
41 using difference_type = Vec::difference_type;
42 using reference = Vec::reference;
43 using const_reference = Vec::const_reference;
44 using iterator = Vec::iterator;
45 using const_iterator = Vec::const_iterator;
46
47 void push_back( const T& value ) { m_members.push_back(value); }
48 void push_back( T&& value ) { m_members.push_back(std::move(value)); }
49
50 iterator erase( iterator pos ) { return m_members.erase(pos); }
51 iterator erase( const_iterator pos ) { return m_members.erase(pos); }
52
53 iterator begin() noexcept { return m_members.begin(); }
54 const_iterator begin() const noexcept { return m_members.begin(); }
55 iterator end() noexcept { return m_members.end(); }
56 const_iterator end() const noexcept { return m_members.end(); }
57
58 size_type size() const noexcept { return m_members.size(); }
59 bool empty() const noexcept { return m_members.empty(); }
60
61 reference front() { return m_members.front(); }
62 const_reference front() const { return m_members.front(); }
63
64 reference back() { return m_members.back(); }
65 const_reference back() const { return m_members.back(); }
66
67 reference operator[]( size_type pos ) { return m_members.operator[](pos); }
68 const_reference operator[]( size_type pos ) const { return m_members.operator[](pos); }
69
70
71 static bool lessThan(const MemberDef *md1,const MemberDef *md2)
72 {
73 return genericCompareMembers(md1,md2)<0;
74 }
75 void sort()
76 {
77 std::stable_sort(m_members.begin(),m_members.end(),lessThan);
78 }
79 void inSort(MemberDef *md)
80 {
81 m_members.insert( std::upper_bound( m_members.begin(), m_members.end(), md, lessThan), md);
82 }
83 void remove(const MemberDef *md)
84 {
85 auto it = std::find(m_members.begin(),m_members.end(),md);
86 if (it!=m_members.end()) erase(it);
87 }
88 bool contains(const MemberDef *md) const
89 {
90 return std::find(m_members.begin(),m_members.end(),md)!=m_members.end();
91 }
92 MemberDef *find(const QCString &name)
93 {
94 auto it = std::find_if(m_members.begin(),m_members.end(),[name=name](auto &el) { return el->name()==name; });
95 if (it != m_members.end())
96 {
97 return *it;
98 }
99
100 return nullptr;
101 }
102 protected:
104};
105
106/** A list of MemberDef objects as shown in documentation sections. */
108{
109 public:
110 MemberList(MemberListType lt,MemberListContainer container);
111 ~MemberList();
113 MemberListType listType() const { return m_listType; }
115
117 int numDecEnumValues() const { return m_numDecEnumValues; }
119 int numDocEnumValues() const { return m_numDocEnumValues; }
120 bool needsSorting() const { return m_needsSorting; }
121 void countDecMembers();
122 void countDocMembers();
123 int countInheritableMembers(const ClassDef *inheritedFrom) const;
124 void writePlainDeclarations(OutputList &ol,bool inGroup,
125 const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd, const GroupDef *gd,const ModuleDef *mod,
126 int indentLevel,const ClassDef *inheritedFrom,const QCString &inheritId) const;
127 void writeDeclarations(OutputList &ol,
128 const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd,const GroupDef *gd,const ModuleDef *mod,
129 const QCString &title,const QCString &subtitle,
130 bool showEnumValues=FALSE,bool showInline=FALSE,
131 const ClassDef *inheritedFrom=nullptr,MemberListType lt=MemberListType::PubMethods(),bool showSectionTitle=true) const;
132 void writeDocumentation(OutputList &ol,const QCString &scopeName,
133 const Definition *container,const QCString &title,
134 bool showEnumValues=FALSE,bool showInline=FALSE) const;
135 void writeSimpleDocumentation(OutputList &ol,const Definition *container) const;
136 void writeDocumentationPage(OutputList &ol,
137 const QCString &scopeName, const DefinitionMutable *container, int hierarchyLevel=0) const;
138 void writeTagFile(TextStream &,bool useQualifiedName=false,bool showNamespaceMembers=true);
139 bool declVisible() const;
140 void addMemberGroup(MemberGroup *mg);
141 void addListReferences(Definition *def);
142 void findSectionsInDocumentation(const Definition *d);
143 void setNeedsSorting(bool b);
144 const MemberGroupRefList &getMemberGroupList() const { return m_memberGroupRefList; }
146 void setAnchors();
147
148 private:
149 int countEnumValues(const MemberDef *md) const;
150 int m_numDecMembers; // number of members in the brief part of the memberlist
152 int m_numDocMembers; // number of members in the detailed part of the memberlist
154 MemberGroupRefList m_memberGroupRefList;
156 MemberListType m_listType;
158};
159
160class MemberLinkedRefMap : public LinkedRefMap<const MemberDef>
161{
162};
163
164class MemberLists : public std::vector< std::unique_ptr<MemberList> >
165{
166 public:
167 MemberLists() = default;
168 ~MemberLists() = default;
169 const std::unique_ptr<MemberList> &get(MemberListType lt,MemberListContainer con)
170 {
171 // find the list with the given type
172 auto it = std::find_if(begin(),end(),[&lt](const auto &ml) { return ml->listType()==lt; });
173 if (it!=end()) return *it;
174 // or create a new list if it is not found
175 emplace_back(std::make_unique<MemberList>(lt,con));
176 return back();
177 }
178
179 private:
181};
182
183
184#endif
A model of a group of symbols.
Definition groupdef.h:52
Container class representing a vector of objects with keys.
Definition linkedmap.h:232
A model of a class/file/namespace member symbol.
Definition memberdef.h:48
bool needsSorting() const
Definition memberlist.h:120
int numDecEnumValues() const
Definition memberlist.h:117
int m_numDecEnumValues
Definition memberlist.h:151
int numDocMembers() const
Definition memberlist.h:118
int numDocEnumValues() const
Definition memberlist.h:119
void writeDeclarations(OutputList &ol, const ClassDef *cd, const NamespaceDef *nd, const FileDef *fd, const GroupDef *gd, const ModuleDef *mod, const QCString &title, const QCString &subtitle, bool showEnumValues=FALSE, bool showInline=FALSE, const ClassDef *inheritedFrom=nullptr, MemberListType lt=MemberListType::PubMethods(), bool showSectionTitle=true) const
Writes the list of members to the output.
int countEnumValues(const MemberDef *md) const
int m_numDocMembers
Definition memberlist.h:152
int m_numDecMembers
Definition memberlist.h:150
MemberListContainer container() const
Definition memberlist.h:114
void countDecMembers()
MemberList(MemberListType lt, MemberListContainer container)
int numDecMembers() const
Definition memberlist.h:116
MemberGroupRefList m_memberGroupRefList
Definition memberlist.h:154
bool m_needsSorting
Definition memberlist.h:157
void writePlainDeclarations(OutputList &ol, bool inGroup, const ClassDef *cd, const NamespaceDef *nd, const FileDef *fd, const GroupDef *gd, const ModuleDef *mod, int indentLevel, const ClassDef *inheritedFrom, const QCString &inheritId) const
void setAnonymousEnumType()
int countInheritableMembers(const ClassDef *inheritedFrom) const
int m_numDocEnumValues
Definition memberlist.h:153
MemberListContainer m_container
Definition memberlist.h:155
void setNeedsSorting(bool b)
void writeSimpleDocumentation(OutputList &ol, const Definition *container) const
MemberListType listType() const
Definition memberlist.h:113
void countDocMembers()
MemberListType m_listType
Definition memberlist.h:156
void writeDocumentation(OutputList &ol, const QCString &scopeName, const Definition *container, const QCString &title, bool showEnumValues=FALSE, bool showInline=FALSE) const
void addMemberGroup(MemberGroup *mg)
void setAnchors()
void writeDocumentationPage(OutputList &ol, const QCString &scopeName, const DefinitionMutable *container, int hierarchyLevel=0) const
bool declVisible() const
const MemberGroupRefList & getMemberGroupList() const
Definition memberlist.h:144
MemberLists()=default
const std::unique_ptr< MemberList > & get(MemberListType lt, MemberListContainer con)
Definition memberlist.h:169
~MemberLists()=default
A vector of MemberDef object.
Definition memberlist.h:34
const_reference operator[](size_type pos) const
Definition memberlist.h:68
Vec::difference_type difference_type
Definition memberlist.h:41
iterator erase(const_iterator pos)
Definition memberlist.h:51
std::vector< T > Vec
Definition memberlist.h:37
reference back()
Definition memberlist.h:64
reference operator[](size_type pos)
Definition memberlist.h:67
void remove(const MemberDef *md)
Definition memberlist.h:83
void sort()
Definition memberlist.h:75
Vec::size_type size_type
Definition memberlist.h:40
static bool lessThan(const MemberDef *md1, const MemberDef *md2)
Definition memberlist.h:71
reference front()
Definition memberlist.h:61
const_reference back() const
Definition memberlist.h:65
const_iterator end() const noexcept
Definition memberlist.h:56
bool empty() const noexcept
Definition memberlist.h:59
Vec::allocator_type allocator_type
Definition memberlist.h:39
MemberDef * T
Definition memberlist.h:36
void push_back(T &&value)
Definition memberlist.h:48
const_iterator begin() const noexcept
Definition memberlist.h:54
iterator end() noexcept
Definition memberlist.h:55
iterator erase(iterator pos)
Definition memberlist.h:50
bool contains(const MemberDef *md) const
Definition memberlist.h:88
void inSort(MemberDef *md)
Definition memberlist.h:79
Vec::value_type value_type
Definition memberlist.h:38
size_type size() const noexcept
Definition memberlist.h:58
const_reference front() const
Definition memberlist.h:62
iterator begin() noexcept
Definition memberlist.h:53
void push_back(const T &value)
Definition memberlist.h:47
Vec::const_iterator const_iterator
Definition memberlist.h:45
Vec::iterator iterator
Definition memberlist.h:44
MemberDef * find(const QCString &name)
Definition memberlist.h:92
Vec::reference reference
Definition memberlist.h:42
Vec::const_reference const_reference
Definition memberlist.h:43
#define NON_COPYABLE(cls)
Macro to help implementing the rule of 5 for a non-copyable & movable class.
Definition construct.h:37
#define ONLY_DEFAULT_MOVABLE(cls)
Macro to help implementing the rule of 5 for a class that can be moved but not copied.
Definition construct.h:44
DirIterator begin(DirIterator it) noexcept
Definition dir.cpp:170
DirIterator end(const DirIterator &) noexcept
Definition dir.cpp:175
static void addListReferences()
Definition doxygen.cpp:5312
static void writeTagFile()
static void findSectionsInDocumentation()
Definition doxygen.cpp:9128
int genericCompareMembers(const MemberDef *c1, const MemberDef *c2)
#define FALSE
Definition qcstring.h:34
#define ASSERT(x)
Definition qcstring.h:39
This file contains a number of basic enums and types.
MemberListContainer
Definition types.h:310