summaryrefslogtreecommitdiff
path: root/include/arrayaccess.h
blob: 6ee316348bdf2e5ec2a2168d0ac56256e09f8c15 (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
/**
 *  ArrayAccess.h
 * 
 *  "Interface" that can be "implemented" by your class. If you do, you
 *  create your class like this:
 * 
 *  class MyClass : public Php::Base, public Php::ArrayAccess { ... }
 * 
 *  @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
 *  @copyright 2014 Copernica BV
 */

/**
 *  Set up namespace
 */
namespace Php {
    
/**
 *  Class definition
 */
class ArrayAccess
{
public:
    /**
     *  Check if a member is set
     *  @param  key
     *  @return bool
     */
    virtual bool offsetExists(const Php::Value &key) = 0;
    
    /**
     *  Set a member
     *  @param  key
     *  @param  value
     */
    virtual void offsetSet(const Php::Value &key, const Php::Value &value) = 0;
    
    /**
     *  Retrieve a member
     *  @param  key
     *  @return value
     */
    virtual Php::Value offsetGet(const Php::Value &key) = 0;
    
    /**
     *  Remove a member
     *  @param key
     */
    virtual void offsetUnset(const Php::Value &key) = 0;
    
    /**
     *  Alternative offsetExists as it is initially called
     *  @param  params
     *  @return bool
     */
    virtual Php::Value offsetExists(Php::Parameters &params)
    {
        return offsetExists(params[0]);
    }
    
    /**
     *  Alternative set member function as it is initially called
     *  @param  params
     */
    virtual void offsetSet(const Php::Parameters &params)
    {
        offsetSet(params[0], params[1]);
    }
    
    /**
     *  Alternative retrieve member function that is initially called
     *  @param  params
     *  @return value
     */
    virtual Php::Value offsetGet(Php::Parameters &params)
    {
        return offsetGet(params[0]);
    }
    
    /**
     *  Alternative function to remove a member that is initally called
     *  @param params
     */
    virtual void offsetUnset(Php::Parameters &params)
    {
        return offsetUnset(params[0]);
    }
};
    
/**
 *  End namespace
 */
}