summaryrefslogtreecommitdiff
path: root/src/stringmember.h
blob: 83432e3be7148aeadd3e8e8557f97faf72f3197a (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
/**
 *  StringMember.h
 *
 *  Implementation for a property that is initially set to a strnig value
 *
 *  @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
 *  @copyright 2013 Copernica BV
 */

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

/**
 *  Class definition
 */
class StringMember : public MemberInfo
{
private:
    /**
     *  The value
     *  @var string
     */
    std::string _value;
    
public:
    /**
     *  Constructor
     *  @param  value
     */
    StringMember(const std::string &value) : MemberInfo(), _value(value) {}

    /**
     *  Constructor
     *  @param  value
     *  @param  size
     */
    StringMember(const char *value, int size) : MemberInfo(), _value(value, size) {}

    /**
     *  Destructor
     */
    virtual ~StringMember() {}

    /**
     *  Is this a property member
     *  @return bool
     */
    virtual bool isProperty() { return true; }

    /**
     *  Virtual method to declare the property
     *  @param  entry       Class entry
     *  @param  name        Name of the member
     *  @param  size        Size of the name
     *  @param  flags       Additional flags
     */
    virtual void declare(struct _zend_class_entry *entry, const char *name, int size, int flags)
    {
        zend_declare_property_stringl(entry, name, size, _value.c_str(), _value.size(), flags);
    }
};

/**
 *  End of namespace
 */
}