Doxygen
memberlist.h
浏览该文件的文档.
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 
27 class GroupDef;
28 
29 int genericCompareMembers(const MemberDef *c1,const MemberDef *c2);
30 
31 /** A vector of MemberDef object */
33 {
34  public:
35  /* --- standard vector interface ---- */
36  using Ptr = const MemberDef *;
37  using Vec = std::vector<Ptr>;
38  using iterator = typename Vec::iterator;
39  using const_iterator = typename Vec::const_iterator;
40  using value_type = const MemberDef *;
41  using const_reference = const value_type&;
42  void push_back(const MemberDef *md) { m_members.push_back(md); }
43  iterator begin() { return m_members.begin(); }
44  iterator end() { return m_members.end(); }
45  const_iterator begin() const { return m_members.cbegin(); }
46  const_iterator end() const { return m_members.cend(); }
47  bool empty() const { return m_members.empty(); }
48  size_t size() const { return m_members.size(); }
49  const_reference front() const { return m_members.front(); }
50  const_reference back() const { return m_members.back(); }
51  const_reference operator[](int index) const { return m_members[index]; }
52  const_reference operator[](size_t index) const { return m_members[index]; }
53 
54  static bool lessThan(const MemberDef *md1,const MemberDef *md2)
55  {
56  return genericCompareMembers(md1,md2)<0;
57  }
58  void sort()
59  {
60  std::sort(m_members.begin(),m_members.end(),lessThan);
61  }
62  void inSort(const MemberDef *md)
63  {
64  m_members.insert( std::upper_bound( m_members.begin(), m_members.end(), md, lessThan), md);
65  }
66  void remove(const MemberDef *md)
67  {
68  auto it = std::find(m_members.begin(),m_members.end(),md);
69  if (it!=m_members.end()) m_members.erase(it);
70  }
71  bool contains(const MemberDef *md)
72  {
73  auto it = std::find(m_members.begin(),m_members.end(),md);
74  return it!=m_members.end();
75  }
76  protected:
78 };
79 
80 /** A list of MemberDef objects as shown in documentation sections. */
81 class MemberList : public MemberVector
82 {
83  public:
85  ~MemberList();
86  MemberListType listType() const { return m_listType; }
89 
90  int numDecMembers() const { ASSERT(m_numDecMembers!=-1); return m_numDecMembers; }
91  int numDecEnumValues() const { return m_numDecEnumValues; }
92  int numDocMembers() const { ASSERT(m_numDocMembers!=-1); return m_numDocMembers; }
93  int numDocEnumValues() const { return m_numDocEnumValues; }
94  bool needsSorting() const { return m_needsSorting; }
95  void countDecMembers();
96  void countDocMembers();
97  int countInheritableMembers(const ClassDef *inheritedFrom) const;
98  void writePlainDeclarations(OutputList &ol,bool inGroup,
99  const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd, const GroupDef *gd,
100  int indentLevel,const ClassDef *inheritedFrom,const QCString &inheritId) const;
101  void writeDeclarations(OutputList &ol,
102  const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd,const GroupDef *gd,
103  const QCString &title,const QCString &subtitle,
104  bool showEnumValues=FALSE,bool showInline=FALSE,
105  const ClassDef *inheritedFrom=0,MemberListType lt=MemberListType_pubMethods) const;
106  void writeDocumentation(OutputList &ol,const QCString &scopeName,
107  const Definition *container,const QCString &title,
108  bool showEnumValues=FALSE,bool showInline=FALSE) const;
111  const QCString &scopeName, const DefinitionMutable *container) const;
112  void writeTagFile(TextStream &);
113  bool declVisible() const;
114  void addMemberGroup(MemberGroup *mg);
115  void addListReferences(Definition *def);
117  void setNeedsSorting(bool b);
119  void setAnonymousEnumType();
120  void setAnchors();
121 
122  private:
123  int countEnumValues(const MemberDef *md) const;
124  int m_numDecMembers; // number of members in the brief part of the memberlist
126  int m_numDocMembers; // number of members in the detailed part of the memberlist
132 };
133 
134 class MemberLinkedRefMap : public LinkedRefMap<const MemberDef>
135 {
136 };
137 
138 class MemberLists : public std::vector< std::unique_ptr<MemberList> >
139 {
140  public:
141  MemberLists() = default;
142  const std::unique_ptr<MemberList> &get(MemberListType lt,MemberListContainer con)
143  {
144  // find the list with the given type
145  auto it = std::find_if(begin(),end(),[&lt](const auto &ml) { return ml->listType()==lt; });
146  if (it!=end()) return *it;
147  // or create a new list if it is not found
148  emplace_back(std::make_unique<MemberList>(lt,con));
149  return back();
150  }
151 
152  private:
153  MemberLists(const MemberLists &) = delete;
154  MemberLists &operator=(const MemberLists &) = delete;
155 };
156 
157 
158 #endif
MemberVector::end
iterator end()
Definition: memberlist.h:44
MemberList::numDecMembers
int numDecMembers() const
Definition: memberlist.h:90
LinkedRefMap
Container class representing a vector of objects with keys.
Definition: linkedmap.h:231
MemberVector::begin
const_iterator begin() const
Definition: memberlist.h:45
MemberVector::Vec
std::vector< Ptr > Vec
Definition: memberlist.h:37
membergroup.h
MemberList::writeSimpleDocumentation
void writeSimpleDocumentation(OutputList &ol, const Definition *container) const
Definition: memberlist.cpp:725
MemberListType
MemberListType
Definition: types.h:100
MemberList::setAnonymousEnumType
void setAnonymousEnumType()
Definition: memberlist.cpp:226
Definition
The common base class of all entity definitions found in the sources.
Definition: definition.h:76
NamespaceDef
An abstract interface of a namespace symbol.
Definition: namespacedef.h:54
types.h
This file contains a number of basic enums and types.
MemberList::getMemberGroupList
const MemberGroupRefList & getMemberGroupList() const
Definition: memberlist.h:118
MemberVector::operator[]
const_reference operator[](size_t index) const
Definition: memberlist.h:52
MemberList::m_numDecEnumValues
int m_numDecEnumValues
Definition: memberlist.h:125
MemberVector::front
const_reference front() const
Definition: memberlist.h:49
memberdef.h
MemberLists::get
const std::unique_ptr< MemberList > & get(MemberListType lt, MemberListContainer con)
Definition: memberlist.h:142
MemberVector::sort
void sort()
Definition: memberlist.h:58
MemberList::countInheritableMembers
int countInheritableMembers(const ClassDef *inheritedFrom) const
Definition: memberlist.cpp:79
MemberVector::push_back
void push_back(const MemberDef *md)
Definition: memberlist.h:42
MemberList::countDecMembers
void countDecMembers()
Definition: memberlist.cpp:116
MemberList::m_needsSorting
bool m_needsSorting
Definition: memberlist.h:131
MemberLists
Definition: memberlist.h:138
TextStream
Text streaming class that buffers data.
Definition: textstream.h:33
MemberList::container
MemberListContainer container() const
Definition: memberlist.h:88
MemberList::m_numDocMembers
int m_numDocMembers
Definition: memberlist.h:126
MemberListType_pubMethods
@ MemberListType_pubMethods
Definition: types.h:107
MemberList::m_numDecMembers
int m_numDecMembers
Definition: memberlist.h:124
MemberVector::iterator
typename Vec::iterator iterator
Definition: memberlist.h:38
linkedmap.h
MemberList::declVisible
bool declVisible() const
Definition: memberlist.cpp:279
MemberList::m_memberGroupRefList
MemberGroupRefList m_memberGroupRefList
Definition: memberlist.h:128
begin
DirIterator begin(DirIterator it) noexcept
Definition: dir.cpp:123
MemberVector::m_members
Vec m_members
Definition: memberlist.h:77
end
DirIterator end(const DirIterator &) noexcept
Definition: dir.cpp:128
GroupDef
A model of a group of symbols.
Definition: groupdef.h:49
MemberList::listTypeAsString
static QCString listTypeAsString(MemberListType type)
Definition: memberlist.cpp:882
OutputList
Class representing a list of output generators that are written to in parallel.
Definition: outputlist.h:37
MemberDef
A model of a class/file/namespace member symbol.
Definition: memberdef.h:45
MemberList::writeTagFile
void writeTagFile(TextStream &)
Definition: memberlist.cpp:940
MemberList::findSectionsInDocumentation
void findSectionsInDocumentation(const Definition *d)
Definition: memberlist.cpp:861
ClassDef
A abstract class representing of a compound symbol.
Definition: classdef.h:103
MemberList::MemberList
MemberList(MemberListType lt, MemberListContainer container)
Definition: memberlist.cpp:33
MemberVector::inSort
void inSort(const MemberDef *md)
Definition: memberlist.h:62
MemberVector::empty
bool empty() const
Definition: memberlist.h:47
MemberList::listType
MemberListType listType() const
Definition: memberlist.h:86
MemberList::writePlainDeclarations
void writePlainDeclarations(OutputList &ol, bool inGroup, const ClassDef *cd, const NamespaceDef *nd, const FileDef *fd, const GroupDef *gd, int indentLevel, const ClassDef *inheritedFrom, const QCString &inheritId) const
Definition: memberlist.cpp:327
MemberGroupRefList
Definition: membergroup.h:105
MemberVector::const_iterator
typename Vec::const_iterator const_iterator
Definition: memberlist.h:39
DefinitionMutable
Definition: definition.h:308
MemberList::numDocMembers
int numDocMembers() const
Definition: memberlist.h:92
MemberList::writeDocumentationPage
void writeDocumentationPage(OutputList &ol, const QCString &scopeName, const DefinitionMutable *container) const
Definition: memberlist.cpp:749
MemberVector::remove
void remove(const MemberDef *md)
Definition: memberlist.h:66
MemberLinkedRefMap
Definition: memberlist.h:134
MemberListContainer
MemberListContainer
Definition: types.h:196
MemberLists::operator=
MemberLists & operator=(const MemberLists &)=delete
MemberVector
A vector of MemberDef object
Definition: memberlist.h:32
MemberList::m_container
MemberListContainer m_container
Definition: memberlist.h:129
MemberList::m_listType
MemberListType m_listType
Definition: memberlist.h:130
MemberList::m_numDocEnumValues
int m_numDocEnumValues
Definition: memberlist.h:127
MemberList::needsSorting
bool needsSorting() const
Definition: memberlist.h:94
MemberLists::MemberLists
MemberLists()=default
MemberList::writeDeclarations
void writeDeclarations(OutputList &ol, const ClassDef *cd, const NamespaceDef *nd, const FileDef *fd, const GroupDef *gd, const QCString &title, const QCString &subtitle, bool showEnumValues=FALSE, bool showInline=FALSE, const ClassDef *inheritedFrom=0, MemberListType lt=MemberListType_pubMethods) const
Writes the list of members to the output.
Definition: memberlist.cpp:526
MemberList::~MemberList
~MemberList()
Definition: memberlist.cpp:43
MemberVector::size
size_t size() const
Definition: memberlist.h:48
MemberList::countEnumValues
int countEnumValues(const MemberDef *md) const
Definition: memberlist.cpp:259
MemberVector::lessThan
static bool lessThan(const MemberDef *md1, const MemberDef *md2)
Definition: memberlist.h:54
MemberList::setAnchors
void setAnchors()
Definition: memberlist.cpp:975
MemberVector::end
const_iterator end() const
Definition: memberlist.h:46
MemberList::numDocEnumValues
int numDocEnumValues() const
Definition: memberlist.h:93
genericCompareMembers
int genericCompareMembers(const MemberDef *c1, const MemberDef *c2)
Definition: memberlist.cpp:47
MemberList::writeDocumentation
void writeDocumentation(OutputList &ol, const QCString &scopeName, const Definition *container, const QCString &title, bool showEnumValues=FALSE, bool showInline=FALSE) const
Definition: memberlist.cpp:658
MemberVector::back
const_reference back() const
Definition: memberlist.h:50
MemberList::addMemberGroup
void addMemberGroup(MemberGroup *mg)
Definition: memberlist.cpp:826
MemberList::countDocMembers
void countDocMembers()
Definition: memberlist.cpp:201
MemberVector::contains
bool contains(const MemberDef *md)
Definition: memberlist.h:71
ASSERT
#define ASSERT(x)
Definition: qcstring.h:44
MemberList::setNeedsSorting
void setNeedsSorting(bool b)
Definition: memberlist.cpp:877
FileDef
A model of a file symbol.
Definition: filedef.h:73
MemberGroup
A class representing a group of members.
Definition: membergroup.h:41
MemberVector::begin
iterator begin()
Definition: memberlist.h:43
MemberList::numDecEnumValues
int numDecEnumValues() const
Definition: memberlist.h:91
MemberVector::operator[]
const_reference operator[](int index) const
Definition: memberlist.h:51
MemberList::addListReferences
void addListReferences(Definition *def)
Definition: memberlist.cpp:831
MemberList
A list of MemberDef objects as shown in documentation sections.
Definition: memberlist.h:81
FALSE
#define FALSE
Definition: qcstring.h:33
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108