forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunction.h
More file actions
168 lines (121 loc) · 3.74 KB
/
Function.h
File metadata and controls
168 lines (121 loc) · 3.74 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
//
// Function.h
//
// $Id: //poco/1.4/CppParser/include/Poco/CppParser/Function.h#2 $
//
// Library: CppParser
// Package: SymbolTable
// Module: Function
//
// Definition of the Function class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef CppParser_Function_INCLUDED
#define CppParser_Function_INCLUDED
#include "Poco/CppParser/CppParser.h"
#include "Poco/CppParser/Decl.h"
#include <vector>
namespace Poco {
namespace CppParser {
class Parameter;
class CppParser_API Function: public Decl
/// This class represents a (member) function declaration.
{
public:
enum Flags
{
FN_STATIC = 1, /// The function is static.
FN_VIRTUAL = 2, /// The function is virtual.
FN_INLINE = 4, /// The function is inline.
FN_CONST = 8, /// The function is const.
FN_TEMPLATE = 16, /// The function is a template.
FN_PURE_VIRTUAL = 32, /// The function is pure virtual.
FN_FINAL = 64, /// The function is final.
FN_OVERRIDE = 128, /// The function is override.
FN_NOEXCEPT = 256, /// The function is noexcept.
FN_DEFAULT = 512, /// The function is default.
FN_DELETE = 1024 /// The function has been deleted.
};
typedef std::vector<Parameter*> Parameters;
typedef Parameters::const_iterator Iterator;
Function(const std::string& decl, NameSpace* pNameSpace);
/// Creates the Function.
~Function();
/// Destroys the Function.
void addParameter(Parameter* pParam);
/// Adds a parameter to the function.
const std::string& getReturnParameter() const;
Iterator begin() const;
/// Returns an iterator for iterating over the Function's Parameter's.
Iterator end() const;
/// Returns an iterator for iterating over the Function's Parameter's.
void makeInline();
/// Sets the FN_INLINE flag.
void makeConst();
/// Sets the FN_CONST flag.
void makePureVirtual();
/// Sets the FN_PURE_VIRTUAL flag.
void makeFinal();
/// Sets the FN_FINAL flag.
void makeOverride();
/// Sets the FN_OVERRIDE flag.
void makeNoexcept();
/// Sets the FN_NOEXCEPT flag.
void makeDefault();
/// Sets the FN_DEFAULT flag.
void makeDelete();
/// Sets the FN_DELETE flag.
int flags() const;
/// Returns the function's flags.
bool isConstructor() const;
/// Returns true iff the function is a constructor.
bool isDestructor() const;
/// Returns true iff the function is a destructor.
bool isMethod() const;
/// Returns true iff the function is a method (it's part of
/// a Struct and it's neither a constructor nor a destructor).
bool isFunction() const;
/// Returns true iff the function is not a member of a class
/// (a freestanding function).
bool isConst() const;
/// Returns true iff the method is const.
int countParameters() const;
/// Returns the number of parameters.
std::string signature() const;
/// Returns the signature of the function.
bool isVirtual() const;
/// Returns true if the method is virtual. Also examines base
/// classes to check for a virtual function with the same
/// signature.
Function* getOverridden() const;
/// If the function is virtual and overrides a function in a
/// base class, the base class function is returned.
/// Otherwise, null is returned.
Symbol::Kind kind() const;
std::string toString() const;
private:
Parameters _params;
int _flags;
std::string _retParam;
};
//
// inlines
//
inline int Function::flags() const
{
return _flags;
}
inline const std::string& Function::getReturnParameter() const
{
return _retParam;
}
inline bool Function::isConst() const
{
return (flags() & FN_CONST) != 0;
}
} } // namespace Poco::CppParser
#endif // CppParser_Function_INCLUDED