summaryrefslogtreecommitdiff
path: root/include/argument.h
blob: 7a95f7dfa0f27e8a856fa0bb565e8c61763ff7a8 (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
100
/**
 *  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.
 *
 *  @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:
    /**
     *  Prevent copying
     *  @param  argument
     */
    Argument(const Argument &argument) = delete;
    
    /**
     *  Move constructor
     *  @param  argument
     */
    Argument(Argument &&argument);
    
    /**
     *  Destructor
     */
    virtual ~Argument() {};
    
    /**
     *  Change the name
     *  @param  name
     *  @return Argument
     */
    Argument &name(const char *name);
    
    /**
     *  Change the type
     *  @param  type
     *  @return Argument
     */
    Argument &type(Type type = nullType);
    
    /**
     *  Require the parameter to be a certain class
     *  @param  name        Name of the class
     *  @param  null        Are null values allowed?
     *  @return Argument
     */
    Argument &object(const char *classname, bool null = true);
    
    /**
     *  Is this a by-ref argument?
     *  @param  bool        Mark as by-ref variable
     *  @return Argument
     */
    Argument &byref(bool value = true);
    
    /**
     *  Prevent copy
     *  @param  argument    The argument to copy
     *  @return Argument
     */
    Argument &operator=(const Argument &argument) = delete;

protected:
    /**
     *  Protected constructor, to prevent that users can instantiate the
     *  argument object themselves
     *  @param  info
     */
    Argument(struct _zend_arg_info *info) : _info(info) {}

private:
    /**
     *  The argument info
     *  @var    zend_arg_info
     */
    struct _zend_arg_info *_info;
};
    
/**
 *  End of namespace
 */
}