@@ -31,17 +31,26 @@ class MRDOCS_VISIBLE
31
31
Corpus
32
32
{
33
33
protected:
34
-
35
34
explicit
36
35
Corpus (
37
36
Config const & config_) noexcept
38
37
: config(config_)
39
38
{
40
39
}
40
+ public:
41
+ /* * The iterator type for the index of all symbols.
41
42
43
+ The iterator is a forward iterator that
44
+ iterates over all symbols in the index.
45
+ It dereferences to a reference to a
46
+ const @ref Info.
42
47
48
+ The logic for incrementing the iterator is
49
+ provided by the Corpus implementation via
50
+ a function that retuns the next Info in the
51
+ index, or nullptr if there are no more.
52
+ */
43
53
class iterator ;
44
- public:
45
54
46
55
/* * Destructor.
47
56
*/
@@ -69,12 +78,6 @@ class MRDOCS_VISIBLE
69
78
iterator
70
79
end () const noexcept = 0 ;
71
80
72
- /* * Return the metadata for the global namespace.
73
- */
74
- MRDOCS_DECL
75
- NamespaceInfo const &
76
- globalNamespace () const noexcept ;
77
-
78
81
/* * Return the Info with the matching ID, or nullptr.
79
82
*/
80
83
MRDOCS_DECL
@@ -83,6 +86,10 @@ class MRDOCS_VISIBLE
83
86
find (SymbolID const & id) const noexcept = 0 ;
84
87
85
88
/* * Return true if an Info with the specified symbol ID exists.
89
+
90
+ This function uses the @ref find function to locate
91
+ the Info with the specified symbol ID and returns
92
+ true if it exists, otherwise false.
86
93
*/
87
94
bool
88
95
exists (
@@ -93,49 +100,92 @@ class MRDOCS_VISIBLE
93
100
94
101
/* * Return the Info with the specified symbol ID.
95
102
103
+ This function uses the @ref find function to locate
104
+ the Info with the specified symbol ID. The result
105
+ is converted to the specified type T and returned.
106
+
107
+ The function @ref exists can be used to determine
108
+ if an Info with the specified symbol ID exists.
96
109
If the id does not exist, the behavior is undefined.
110
+
111
+ If the Info is not of type T, the behavior is undefined.
97
112
*/
98
113
template <class T = Info>
114
+ requires std::derived_from<T, Info>
99
115
T const &
100
116
get (
101
117
SymbolID const & id) const noexcept ;
102
118
103
- // --------------------------------------------
119
+ /* * Return the metadata for the global namespace.
104
120
105
- // KRYSTIAN FIXME: this could just be a single
106
- // overload constrained with std::derived_from<ScopeInfo>
107
- template <class F , class ... Args>
108
- void traverse (
109
- NamespaceInfo const & I,
110
- F&& f, Args&&... args) const ;
111
-
112
- template <class F , class ... Args>
113
- void traverse (
114
- RecordInfo const & I,
115
- F&& f, Args&&... args) const ;
116
-
117
- template <class F , class ... Args>
118
- void traverse (
119
- EnumInfo const & I,
120
- F&& f, Args&&... args) const ;
121
-
122
- template <class F , class ... Args>
123
- void traverse (
124
- SpecializationInfo const & I,
125
- F&& f, Args&&... args) const ;
126
-
127
- template <class F , class ... Args>
128
- void traverse (
129
- OverloadSet const & OS,
130
- F&& f, Args&&... args) const ;
131
-
132
- template <class F , class ... Args>
121
+ This function is equivalent to calling
122
+ @ref get with the symbol ID for the
123
+ global namespace.
124
+ */
125
+ MRDOCS_DECL
126
+ NamespaceInfo const &
127
+ globalNamespace () const noexcept ;
128
+
129
+ /* * Visit the members of specified Info.
130
+
131
+ This function invokes the specified function `f`
132
+ for each member of the specified Info `I`.
133
+
134
+ For each member of `I`, the function will invoke
135
+ the function object `fn` with a type derived from
136
+ `Info` as the first argument, followed by `args...`.
137
+
138
+ The type of the first argument is determined
139
+ by the `InfoKind` of the `Info` object.
140
+
141
+ @param info The Info to visit.
142
+ @param f The function to invoke.
143
+ @param args The arguments to pass to the function.
144
+ */
145
+ template <InfoParent T, class F , class ... Args>
146
+ void
147
+ traverse (
148
+ T const & I, F&& f, Args&&... args) const
149
+ {
150
+ for (auto const & id : I.Members )
151
+ {
152
+ visit (get (id), std::forward<F>(f),
153
+ std::forward<Args>(args)...);
154
+ }
155
+ }
156
+
157
+ /* * Visit the function members of specified Info.
158
+
159
+ This function iterates the members of the specified
160
+ ScopeInfo `S`. For each member associated with a
161
+ function with the same name as the member, the
162
+ function object `f` is invoked with the member
163
+ as the first argument, followed by `args...`.
164
+
165
+ When there are more than one member function
166
+ with the same name, the function object `f` is
167
+ invoked with an @ref OverloadSet as the first
168
+ argument, followed by `args...`.
169
+ */
170
+ template <class F , class ... Args>
133
171
void traverseOverloads (
134
172
ScopeInfo const & S,
135
- F&& f, Args&&... args) const ;
173
+ F&& f,
174
+ Args&&... args) const ;
136
175
137
176
// --------------------------------------------
138
177
178
+ /* * Return the fully qualified name of the specified Info.
179
+
180
+ This function returns the fully qualified name
181
+ of the specified Info `I` as a string.
182
+
183
+ The `Info` parents are traversed to construct
184
+ the fully qualified name which is stored in
185
+ the string `temp`.
186
+
187
+ @return A reference to the string `temp`.
188
+ */
139
189
// KRYSTIAN NOTE: temporary
140
190
MRDOCS_DECL
141
191
std::string&
@@ -147,6 +197,7 @@ class MRDOCS_VISIBLE
147
197
// ------------------------------------------------
148
198
149
199
template <class T >
200
+ requires std::derived_from<T, Info>
150
201
T const &
151
202
Corpus::
152
203
get (
@@ -166,67 +217,7 @@ get(
166
217
}
167
218
}
168
219
169
- template <class F , class ... Args>
170
- void
171
- Corpus::
172
- traverse (
173
- NamespaceInfo const & I,
174
- F&& f, Args&&... args) const
175
- {
176
- for (auto const & id : I.Members )
177
- visit (get (id), std::forward<F>(f),
178
- std::forward<Args>(args)...);
179
- }
180
-
181
- template <class F , class ... Args>
182
- void
183
- Corpus::
184
- traverse (
185
- RecordInfo const & I,
186
- F&& f, Args&&... args) const
187
- {
188
- for (auto const & id : I.Members )
189
- visit (get (id), std::forward<F>(f),
190
- std::forward<Args>(args)...);
191
- }
192
-
193
- template <class F , class ... Args>
194
- void
195
- Corpus::
196
- traverse (
197
- EnumInfo const & I,
198
- F&& f, Args&&... args) const
199
- {
200
- for (auto const & id : I.Members )
201
- visit (get (id), std::forward<F>(f),
202
- std::forward<Args>(args)...);
203
- }
204
-
205
- template <class F , class ... Args>
206
- void
207
- Corpus::
208
- traverse (
209
- SpecializationInfo const & I,
210
- F&& f, Args&&... args) const
211
- {
212
- for (auto const & id : I.Members )
213
- visit (get (id), std::forward<F>(f),
214
- std::forward<Args>(args)...);
215
- }
216
-
217
- template <class F , class ... Args>
218
- void
219
- Corpus::
220
- traverse (
221
- OverloadSet const & OS,
222
- F&& f, Args&&... args) const
223
- {
224
- for (auto const & id : OS.Members )
225
- visit (get (id), std::forward<F>(f),
226
- std::forward<Args>(args)...);
227
- }
228
-
229
- template <class F , class ... Args>
220
+ template <class F , class ... Args>
230
221
void
231
222
Corpus::
232
223
traverseOverloads (
0 commit comments