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 
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:
77  Vec m_members;
78 };
79 
81 class MemberList : public MemberVector
82 {
83  public:
84  MemberList(MemberListType lt,MemberListContainer container);
85  ~MemberList();
86  MemberListType listType() const { return m_listType; }
87  static QCString listTypeAsString(MemberListType type);
88  MemberListContainer container() const { return m_container; }
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;
109  void writeSimpleDocumentation(OutputList &ol,const Definition *container) const;
110  void writeDocumentationPage(OutputList &ol,
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);
116  void findSectionsInDocumentation(const Definition *d);
117  void setNeedsSorting(bool b);
118  const MemberGroupRefList &getMemberGroupList() const { return m_memberGroupRefList; }
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
125  int m_numDecEnumValues;
126  int m_numDocMembers; // number of members in the detailed part of the memberlist
127  int m_numDocEnumValues;
128  MemberGroupRefList m_memberGroupRefList;
129  MemberListContainer m_container;
130  MemberListType m_listType;
131  bool m_needsSorting;
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
This file contains a number of basic enums and types.
The common base class of all entity definitions found in the sources.
Definition: definition.h:76
An abstract interface of a namespace symbol.
Definition: namespacedef.h:54
A model of a class/file/namespace member symbol.
Definition: memberdef.h:45
A vector of MemberDef object.
Definition: memberlist.h:32
Text streaming class that buffers data.
Definition: textstream.h:33
A model of a file symbol.
Definition: filedef.h:73
Definition: memberlist.h:138
A class representing a group of members.
Definition: membergroup.h:41
Definition: definition.h:308
A list of MemberDef objects as shown in documentation sections.
Definition: memberlist.h:81
Definition: memberlist.h:134
Container class representing a vector of objects with keys.
Definition: linkedmap.h:231
Class representing a list of output generators that are written to in parallel.
Definition: outputlist.h:37
This is an alternative implementation of QCString.
Definition: qcstring.h:108
Definition: membergroup.h:105
A model of a group of symbols.
Definition: groupdef.h:49
A abstract class representing of a compound symbol.
Definition: classdef.h:103