diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2013-10-14 02:46:52 -0700 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2013-10-14 02:46:52 -0700 |
commit | 53272534a76a9d8cbee4ee887e1f360c4a99728b (patch) | |
tree | 54206aca1cfa1461ba365b05e5848f2843be91b9 /src/stringmember.h | |
parent | 777eb276f635c949ccdcf9613ad55d42190cb387 (diff) |
The initial class properties can now only be scalar values, just like in PHP
Diffstat (limited to 'src/stringmember.h')
-rw-r--r-- | src/stringmember.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/stringmember.h b/src/stringmember.h new file mode 100644 index 0000000..8818da4 --- /dev/null +++ b/src/stringmember.h @@ -0,0 +1,63 @@ +/** + * 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() {} + + /** + * 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 + */ +} + |