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
|
/**
* Argument.h
*
* Class holds information about an argument that is passed to a function.
* You'll need this class when you're defining your own functions.
*
* The constructor of the argument is protected. Use the ByVal or ByRef
* classes instead.
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2013, 2014 Copernica BV
*/
/**
* Set up namespace
*/
namespace Php {
/**
* Class definition
*/
class Argument
{
public:
/**
* Destructor
*/
virtual ~Argument() {}
protected:
/**
* Constructor
* @param name Name of the argument
* @param type Argument type
* @param required Is this argument required?
* @param byref Is this a reference argument
*/
Argument(const char *name, Type type, bool required = true, bool byref = false) :
_name(name), _type(type), _required(required), _byReference(byref) {}
/**
* Constructor
* @param name Name of the argument
* @param classname Name of the class
* @param nullable Can it be null?
* @param required Is this argument required?
* @param byref Is this a reference argument?
*/
Argument(const char *name, const char *classname, bool nullable = true, bool required = true, bool byref = false) :
_name(name), _type(Type::Object), _classname(classname), _nullable(nullable), _required(required), _byReference(byref) {}
public:
/**
* Is this a required argument?
* @return bool
* @internal
*/
bool required() const
{
return _required;
}
/**
* Name of the argument
* @return std::string
*/
const std::string &name() const
{
return _name;
}
/**
* Type-hint for the argument
* @return Type
*/
Type type() const
{
return _type;
}
/**
* If the type is a class, the name of the class
* @return std::string
*/
const std::string &classname() const
{
return _classname;
}
/**
* Is it allowed to pass parameter with a null value?
* @return bool
*/
bool allowNull() const
{
return _nullable;
}
/**
* Is this a parameter-by-reference?
* @return bool
*/
bool byReference() const
{
return _byReference;
}
private:
/**
* Name of the argument
* @var std::string
*/
std::string _name;
/**
* Type of argument
* @var Type
*/
Type _type;
/**
* Classname, if this is a parameter that is supposed to be an instance of a class
* @var std::string
*/
std::string _classname;
/**
* May the parameter be null?
* @var bool
*/
bool _nullable;
/**
* Is this a required argument
* @var bool
*/
bool _required;
/**
* Is this a 'by-reference' parameter?
* @var bool
*/
bool _byReference;
};
/**
* A list of arguments can be supplied to methods
* @type Arguments
*/
using Arguments = std::initializer_list<Argument>;
/**
* End of namespace
*/
}
|