-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathcpp_entity_info_accessor.h
More file actions
190 lines (151 loc) · 4.55 KB
/
Copy pathcpp_entity_info_accessor.h
File metadata and controls
190 lines (151 loc) · 4.55 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
// Copyright (C) 2022 Satya Das and CppParser contributors
// SPDX-License-Identifier: MIT
#ifndef E1C8E022_9208_4EA2_BF0E_482C7ABD2C72
#define E1C8E022_9208_4EA2_BF0E_482C7ABD2C72
#include "cppast/cpp_compound.h"
#include "cppast/cppconst.h"
#include "cppast/cpputil.h"
#include "cppast/helper/cpp_entity_ptr.h"
namespace cppast {
inline bool IsFunction(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::FUNCTION;
}
inline bool IsFunction(const std::unique_ptr<CppEntity>& cppEntity)
{
return IsFunction(*cppEntity);
}
inline bool IsFunctionPtr(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::FUNCTION_PTR;
}
inline bool IsFunctionPtr(const std::unique_ptr<CppEntity>& cppEntity)
{
return IsFunctionPtr(*cppEntity);
}
inline bool IsFunctionLike(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::FUNCTION || cppEntity.entityType() == CppEntityType::CONSTRUCTOR
|| cppEntity.entityType() == CppEntityType::DESTRUCTOR
|| cppEntity.entityType() == CppEntityType::TYPE_CONVERTER;
}
inline bool IsFunctionLike(const std::unique_ptr<CppEntity>& cppEntity)
{
return IsFunctionLike(*cppEntity);
}
inline bool IsDestructor(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::DESTRUCTOR;
}
inline bool IsDestructor(const std::unique_ptr<CppEntity>& cppEntity)
{
return IsDestructor(*cppEntity);
}
inline bool IsEnum(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::ENUM;
}
inline bool IsEnum(const std::unique_ptr<CppEntity> cppEntity)
{
return IsEnum(*cppEntity);
}
inline bool IsTypedefName(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::TYPEDEF_DECL;
}
inline bool IsTypedefName(const std::unique_ptr<CppEntity>& cppEntity)
{
return IsTypedefName(*cppEntity);
}
inline bool IsUsingDecl(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::USING_DECL;
}
inline bool IsUsingDecl(const std::unique_ptr<CppEntity>& cppEntity)
{
return IsUsingDecl(*cppEntity);
}
inline bool IsCompound(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::COMPOUND;
}
inline bool IsCompound(const std::unique_ptr<CppEntity>& cppEntity)
{
return IsCompound(*cppEntity);
}
inline bool IsFwdClsDecl(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::FORWARD_CLASS_DECL;
}
inline bool IsFwdClsDecl(const std::unique_ptr<CppEntity>& cppEntity)
{
return IsFwdClsDecl(*cppEntity);
}
inline bool IsNamespaceLike(const CppEntity& cppEntity)
{
const helper::CppEntityPtr<const CppCompound> compound = &cppEntity;
if (!compound)
{
return false;
}
return (compound->compoundType() >= CppCompoundType::NAMESPACE)
&& (compound->compoundType() <= CppCompoundType::UNION);
}
inline bool IsNamespaceLike(const std::unique_ptr<CppEntity>& cppEntity)
{
return IsNamespaceLike(*cppEntity);
}
bool IsClassLike(const CppEntity& cppEntity);
inline bool IsClassLike(const std::unique_ptr<CppEntity>& cppEntity)
{
return IsClassLike(*cppEntity);
}
inline bool IsTypedefLike(const CppEntity& cppEntity)
{
return (cppEntity.entityType() == CppEntityType::TYPEDEF_DECL)
|| (cppEntity.entityType() == CppEntityType::USING_DECL);
}
inline bool IsTypedefLike(const std::unique_ptr<CppEntity>& cppEntity)
{
return IsTypedefLike(*cppEntity);
}
inline bool IsPreProcessorType(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::PREPROCESSOR;
}
inline bool IsPreProcessorType(const std::unique_ptr<CppEntity>& cppEntity)
{
return IsPreProcessorType(*cppEntity);
}
inline bool IsVar(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::VAR;
}
inline bool IsVar(const std::unique_ptr<CppEntity>& cppEntity)
{
return IsVar(*cppEntity);
}
inline bool IsVarList(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::VAR_LIST;
}
inline bool IsVarList(const std::unique_ptr<CppEntity>& cppEntity)
{
return IsVarList(*cppEntity);
}
inline bool IsExpr(const CppEntity& cppEntity)
{
return cppEntity.entityType() == CppEntityType::EXPRESSION;
}
inline bool IsExpr(const std::unique_ptr<CppEntity>& cppEntity)
{
return IsExpr(*cppEntity);
}
inline CppCompound* Root(const CppEntity& cppEntity)
{
if (cppEntity.owner() == nullptr)
return IsCompound(cppEntity) ? const_cast<CppCompound*>(static_cast<const CppCompound*>(&cppEntity)) : nullptr;
return Root(*cppEntity.owner());
}
} // namespace cppast
#endif /* E1C8E022_9208_4EA2_BF0E_482C7ABD2C72 */