diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-15 01:32:22 +0100 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-15 01:32:22 +0100 |
commit | 3300d64c4dd61e71b62d5b55b1f16e34d6335680 (patch) | |
tree | c2bd999ba1a2a1320acba20fb99acf0defb9651e /src/numericmember.h | |
parent | 681d1e6aa735568a492140d2307a89063e7aadb9 (diff) | |
parent | cda98dc0dea7144941a46ff20598f3c095d7a6d0 (diff) |
implemented __clone method
Diffstat (limited to 'src/numericmember.h')
-rw-r--r-- | src/numericmember.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/numericmember.h b/src/numericmember.h new file mode 100644 index 0000000..99889c6 --- /dev/null +++ b/src/numericmember.h @@ -0,0 +1,65 @@ +/** + * NumericMember.h + * + * Implementation for a property that is initially set to a numeric value + * + * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com> + * @copyright 2013, 2014 Copernica BV + */ + +/** + * Set up namespace + */ +namespace Php { + +/** + * Class definition + */ +class NumericMember : public Member +{ +private: + /** + * The value + * @var long + */ + long _value; + +public: + /** + * Constructor + * @param name + * @param value + * @param flags + */ + NumericMember(const char *name, long value, int flags) : Member(name, flags), _value(value) {} + + /** + * Destructor + */ + virtual ~NumericMember() {} + + /** + * Declare class constant + * @param entry Class entry + */ + virtual void constant(struct _zend_class_entry *entry) override + { + zend_declare_class_constant_long(entry, _name.c_str(), _name.size(), _value); + } + + /** + * Virtual method to declare the property + * @param entry Class entry + */ + virtual void declare(struct _zend_class_entry *entry) override + { + // char* cast is necessary for php 5.3 + zend_declare_property_long(entry, (char *)_name.c_str(), _name.size(), _value, _flags); + } +}; + +/** + * End of namespace + */ +} + |