forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStruct.h
More file actions
executable file
·207 lines (148 loc) · 4.29 KB
/
Struct.h
File metadata and controls
executable file
·207 lines (148 loc) · 4.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
//
// Struct.h
//
// $Id: //poco/1.4/CppParser/include/Poco/CppParser/Struct.h#2 $
//
// Library: CppParser
// Package: SymbolTable
// Module: Struct
//
// Definition of the Struct class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef CppParser_Struct_INCLUDED
#define CppParser_Struct_INCLUDED
#include "Poco/CppParser/CppParser.h"
#include "Poco/CppParser/NameSpace.h"
#include <vector>
#include <set>
namespace Poco {
namespace CppParser {
class Function;
class CppParser_API Struct: public NameSpace
/// This class represents a struct or class declaration.
{
public:
enum Flags
{
FN_TEMPLATE = 1,
FN_INLINE = 2, // when the whole class is inlined in a c++ file
FN_TEMPLATE_SPECIALIZATION = 4,
FN_FINAL = 8
};
struct Base
{
Symbol::Access access;
bool isVirtual;
std::string name;
Struct* pClass;
};
typedef std::vector<Base> BaseClasses;
typedef BaseClasses::const_iterator BaseIterator;
typedef std::vector<Struct*> StructVec;
typedef StructVec::const_iterator DerivedIterator;
typedef std::vector<Function*> Functions;
typedef std::set<Function*> FunctionSet;
typedef std::set<Struct*> StructSet;
Struct(const std::string& decl, bool isClass, NameSpace* pNameSpace);
/// Creates the Struct.
~Struct();
/// Destroys the Struct.
void addBase(const std::string&, Symbol::Access access, bool isVirtual);
/// Adds a base class.
BaseIterator baseBegin() const;
/// Returns an iterator for iterating over all base classes.
BaseIterator baseEnd() const;
/// Returns an iterator for iterating over all base classes.
void fixupBases();
/// Adds pointers for all base classes.
void addDerived(Struct* pClass);
/// Adds a derived class.
DerivedIterator derivedBegin() const;
/// Returns an iterator for iterating over all derived classes.
DerivedIterator derivedEnd() const;
/// Returns an iterator for iterating over all derived classes.
const std::string& declaration() const;
/// Returns the declaration.
int flags() const;
/// Returns the struct's flags.
void makeInline();
/// Changes the class to a inline class, i.e. definition and implementation are hidden in a cpp file.
void makeFinal();
/// Makes the class final.
bool isInline() const;
/// Returns true if the complete class is inlined in a cpp file.
bool isFinal() const;
/// Returns true if the class is final.
void constructors(Functions& functions) const;
/// Returns all constructors, sorted by their parameter count.
Function* destructor() const;
/// Returns the destructor, or NULL if no
/// destructor is defined.
void methods(Symbol::Access access, Functions& functions) const;
/// Returns all functions with the given access.
void inheritedMethods(FunctionSet& functions) const;
/// Returns all inherited methods.
void bases(std::set<std::string>& bases) const;
/// Returns all base classes.
void derived(StructSet& derived) const;
/// Returns all derived classes.
Function* findFunction(const std::string& signature) const;
/// Finds a function with the given signature.
bool hasVirtualDestructor() const;
/// Returns true if the class CppParser_API or one if its base classes
/// has a virtual destructor.
bool isClass() const;
/// Returns true iff the struct was declared as class.
bool isDerived() const;
/// Returns true iff the struct or class is derived from another struct or class.
Symbol::Kind kind() const;
std::string toString() const;
private:
std::string _decl;
BaseClasses _bases;
StructVec _derived;
int _flags;
bool _isClass;
};
//
// inlines
//
inline const std::string& Struct::declaration() const
{
return _decl;
}
inline int Struct::flags() const
{
return _flags;
}
inline bool Struct::isClass() const
{
return _isClass;
}
inline void Struct::makeInline()
{
_flags |= FN_INLINE;
}
inline void Struct::makeFinal()
{
_flags |= FN_FINAL;
}
inline bool Struct::isInline() const
{
return (_flags & FN_INLINE) != 0;
}
inline bool Struct::isFinal() const
{
return (_flags & FN_FINAL) != 0;
}
inline bool Struct::isDerived() const
{
return !_bases.empty();
}
} } // namespace Poco::CppParser
#endif // CppParser_Struct_INCLUDED