summaryrefslogtreecommitdiff
path: root/include/argument.h
blob: c75abc13bc152a6bf427efb6744627b75832d554 (plain)
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
/**
 *  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 Copernica BV
 */

/**
 *  Forward declaration
 */
struct _zend_arg_info;

/**
 *  Set up namespace
 */
namespace Php {

/**
 *  Class definition
 */
class Argument
{
public:
    /**
     *  Copy constructor
     *  @param  argument
     */
    Argument(const Argument &argument);

    /**
     *  Move constructor
     *  @param  argument
     */
    Argument(Argument &&argument);

    /**
     *  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);
    
    /**
     *  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);
    
public:
    /**
     *  Fill an arg_info structure with data
     *  @param  info
     *  @internal
     */
    void fill(struct _zend_arg_info *info) const;

private:
    /**
     *  The argument info
     *  @var    zend_arg_info
     */
    struct _zend_arg_info *_info;
    
    /**
     *  Is this a required argument
     *  @var    bool
     */
    bool _required;
};

/**
 *  A list of arguments can be supplied to methods
 *  @type   Arguments
 */
using Arguments = std::initializer_list<Argument>;
    
/**
 *  End of namespace
 */
}