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#include <utility>
22
23#include "memberdef.h"
24#include "linkedmap.h"
25#include "types.h"
26#include "membergroup.h"
27#include "construct.h"
28
29class GroupDef;
30
31int genericCompareMembers(const MemberDef *c1,const MemberDef *c2);
32
33/** A vector of MemberDef object */
35{
36 public:
37 using T = MemberDef*;
38 using Vec = std::vector<T>;
39 using value_type = Vec::value_type;
40 using allocator_type = Vec::allocator_type;
41 using size_type = Vec::size_type;
42 using difference_type = Vec::difference_type;
43 using reference = Vec::reference;
44 using const_reference = Vec::const_reference;
45 using iterator = Vec::iterator;
46 using const_iterator = Vec::const_iterator;
47
48 void push_back( const T& value ) { m_members.push_back(value); }
49 void push_back( T&& value ) { m_members.push_back(std::move(value)); }
50
51 iterator erase( iterator pos ) { return m_members.erase(pos); }
52 iterator erase( const_iterator pos ) { return m_members.erase(pos); }
53
54 iterator begin() noexcept { return m_members.begin(); }
55 const_iterator begin() const noexcept { return m_members.begin(); }
56 iterator end() noexcept { return m_members.end(); }
57 const_iterator end() const noexcept { return m_members.end(); }
58
59 size_type size() const noexcept { return m_members.size(); }
60 bool empty() const noexcept { return m_members.empty(); }
61
62 reference front() { return m_members.front(); }
63 const_reference front() const { return m_members.front(); }
64
65 reference back() { return m_members.back(); }
66 const_reference back() const { return m_members.back(); }
67
68 reference operator[]( size_type pos ) { return m_members.operator[](pos); }
69 const_reference operator[]( size_type pos ) const { return m_members.operator[](pos); }
70
71
72 static bool lessThan(const MemberDef *md1,const MemberDef *md2)
73 {
74 return genericCompareMembers(md1,md2)<0;
75 }
76 void sort()
77 {
78 std::stable_sort(m_members.begin(),m_members.end(),lessThan);
79 }
80 void inSort(MemberDef *md)
81 {
82 m_members.insert( std::upper_bound( m_members.begin(), m_members.end(), md, lessThan), md);
83 }
84 void remove(const MemberDef *md)
85 {
86 auto it = std::find(m_members.begin(),m_members.end(),md);
87 if (it!=m_members.end()) erase(it);
88 }
89 bool contains(const MemberDef *md) const
90 {
91 return std::find(m_members.begin(),m_members.end(),md)!=m_members.end();
92 }
93 MemberDef *find(const QCString &name)
94 {
95 auto it = std::find_if(m_members.begin(),m_members.end(),[name=name](auto &el) { return el->name()==name; });
96 if (it != m_members.end())
97 {
98 return *it;
99 }
100
101 return nullptr;
102 }
103 protected:
105};
106
107/** A list of MemberDef objects as shown in documentation sections. */
109{
110 public:
112 ~MemberList();
116
117 int numDecMembers(const ClassDef *inheritedFrom) const
118 { return countDecMembers(inheritedFrom).first; }
119 int numDecMembers() const
120 { ASSERT(m_numDecMembers!=-1); return m_numDecMembers; }
121 int numDecEnumValues() const { return m_numDecEnumValues; }
123 int numDocEnumValues() const { return m_numDocEnumValues; }
124 bool needsSorting() const { return m_needsSorting; }
125 void countDecMembers() const;
126 std::pair<int,int> countDecMembers(const ClassDef *inheritedFrom) const;
127 void countDocMembers();
128 int countInheritableMembers(const ClassDef *inheritedFrom) const;
129 void writePlainDeclarations(OutputList &ol,bool inGroup,
130 const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd, const GroupDef *gd,const ModuleDef *mod,
131 int indentLevel,const ClassDef *inheritedFrom,const QCString &inheritId) const;
133 const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd,const GroupDef *gd,const ModuleDef *mod,
134 const QCString &title,const QCString &subtitle,
135 bool showEnumValues=FALSE,bool showInline=FALSE,
136 const ClassDef *inheritedFrom=nullptr,MemberListType lt=MemberListType::PubMethods(),bool showSectionTitle=true) const;
137 void writeDocumentation(OutputList &ol,const QCString &scopeName,
138 const Definition *container,const QCString &title,
139 bool showEnumValues=FALSE,bool showInline=FALSE) const;
142 const QCString &scopeName, const DefinitionMutable *container, int hierarchyLevel=0) const;
143 void writeTagFile(TextStream &,bool useQualifiedName=false,bool showNamespaceMembers=true);
144 bool declVisible() const;
145 void addMemberGroup(MemberGroup *mg);
146 void addListReferences(Definition *def);
148 void setNeedsSorting(bool b);
151 void setAnchors();
152
153 private:
154 int countEnumValues(const MemberDef *md) const;
155 mutable int m_numDecMembers; // number of members in the brief part of the memberlist
157 int m_numDocMembers; // number of members in the detailed part of the memberlist
163};
164
165class MemberLinkedRefMap : public LinkedRefMap<const MemberDef>
166{
167};
168
169class MemberLists : public std::vector< std::unique_ptr<MemberList> >
170{
171 public:
172 MemberLists() = default;
173 ~MemberLists() = default;
174 const std::unique_ptr<MemberList> &get(MemberListType lt,MemberListContainer con)
175 {
176 // find the list with the given type
177 auto it = std::find_if(begin(),end(),[&lt](const auto &ml) { return ml->listType()==lt; });
178 if (it!=end()) return *it;
179 // or create a new list if it is not found
180 emplace_back(std::make_unique<MemberList>(lt,con));
181 return back();
182 }
183
184 private:
186};
187
188
189#endif
A abstract class representing of a compound symbol.
Definition classdef.h:104
The common base class of all entity definitions found in the sources.
Definition definition.h:76
A model of a file symbol.
Definition filedef.h:99
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
A class representing a group of members.
Definition membergroup.h:43
bool needsSorting() const
Definition memberlist.h:124
int numDecEnumValues() const
Definition memberlist.h:121
int m_numDecEnumValues
Definition memberlist.h:156
int numDocMembers() const
Definition memberlist.h:122
int numDocEnumValues() const
Definition memberlist.h:123
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:157
int m_numDecMembers
Definition memberlist.h:155
MemberListContainer container() const
Definition memberlist.h:115
MemberList(MemberListType lt, MemberListContainer container)
int numDecMembers() const
Definition memberlist.h:119
MemberGroupRefList m_memberGroupRefList
Definition memberlist.h:159
bool m_needsSorting
Definition memberlist.h:162
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:158
MemberListContainer m_container
Definition memberlist.h:160
void setNeedsSorting(bool b)
void writeSimpleDocumentation(OutputList &ol, const Definition *container) const
MemberListType listType() const
Definition memberlist.h:114
void countDecMembers() const
void countDocMembers()
MemberListType m_listType
Definition memberlist.h:161
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()
int numDecMembers(const ClassDef *inheritedFrom) const
Definition memberlist.h:117
void writeDocumentationPage(OutputList &ol, const QCString &scopeName, const DefinitionMutable *container, int hierarchyLevel=0) const
bool declVisible() const
const MemberGroupRefList & getMemberGroupList() const
Definition memberlist.h:149
Wrapper class for the MemberListType type.
Definition types.h:184
MemberLists()=default
const std::unique_ptr< MemberList > & get(MemberListType lt, MemberListContainer con)
Definition memberlist.h:174
~MemberLists()=default
A vector of MemberDef object.
Definition memberlist.h:35
const_reference operator[](size_type pos) const
Definition memberlist.h:69
Vec::difference_type difference_type
Definition memberlist.h:42
iterator erase(const_iterator pos)
Definition memberlist.h:52
std::vector< T > Vec
Definition memberlist.h:38
reference back()
Definition memberlist.h:65
reference operator[](size_type pos)
Definition memberlist.h:68
void remove(const MemberDef *md)
Definition memberlist.h:84
void sort()
Definition memberlist.h:76
Vec::size_type size_type
Definition memberlist.h:41
static bool lessThan(const MemberDef *md1, const MemberDef *md2)
Definition memberlist.h:72
reference front()
Definition memberlist.h:62
const_reference back() const
Definition memberlist.h:66
const_iterator end() const noexcept
Definition memberlist.h:57
bool empty() const noexcept
Definition memberlist.h:60
Vec::allocator_type allocator_type
Definition memberlist.h:40
MemberDef * T
Definition memberlist.h:37
void push_back(T &&value)
Definition memberlist.h:49
const_iterator begin() const noexcept
Definition memberlist.h:55
iterator end() noexcept
Definition memberlist.h:56
iterator erase(iterator pos)
Definition memberlist.h:51
bool contains(const MemberDef *md) const
Definition memberlist.h:89
void inSort(MemberDef *md)
Definition memberlist.h:80
Vec::value_type value_type
Definition memberlist.h:39
size_type size() const noexcept
Definition memberlist.h:59
const_reference front() const
Definition memberlist.h:63
iterator begin() noexcept
Definition memberlist.h:54
void push_back(const T &value)
Definition memberlist.h:48
Vec::const_iterator const_iterator
Definition memberlist.h:46
Vec::iterator iterator
Definition memberlist.h:45
MemberDef * find(const QCString &name)
Definition memberlist.h:93
Vec::reference reference
Definition memberlist.h:43
Vec::const_reference const_reference
Definition memberlist.h:44
An abstract interface of a namespace symbol.
Class representing a list of output generators that are written to in parallel.
Definition outputlist.h:314
This is an alternative implementation of QCString.
Definition qcstring.h:101
Text streaming class that buffers data.
Definition textstream.h:36
#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:5444
static void writeTagFile()
static void findSectionsInDocumentation()
Definition doxygen.cpp:9277
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