diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-02 12:00:11 +0100 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-02 12:00:11 +0100 |
commit | 41bd759f31d625b5f73dd3a31d76a91efbde8ad7 (patch) | |
tree | b995cc0c295c031c6cf130fe0f4f51b286a0511e /include | |
parent | 52fe0c39457421e075959179ee6b64a20b96f0d9 (diff) |
working implementation for Base::value()
Diffstat (limited to 'include')
-rw-r--r-- | include/base.h | 22 | ||||
-rw-r--r-- | include/classbase.h | 17 |
2 files changed, 39 insertions, 0 deletions
diff --git a/include/base.h b/include/base.h index 93ee66e..04f0c0e 100644 --- a/include/base.h +++ b/include/base.h @@ -52,6 +52,28 @@ public: { return value()[name]; } + +private: + /** + * The zend_object + * @var zend_object + */ + struct _zend_object *_object = nullptr; + + /** + * Private method to assign the zend object + * @param zend_object + */ + void assign(struct _zend_object *object) + { + // copy pointer + _object = object; + } + + /** + * ClassBase has access to private data + */ + friend class ClassBase; }; diff --git a/include/classbase.h b/include/classbase.h index 249122a..a9d9ef5 100644 --- a/include/classbase.h +++ b/include/classbase.h @@ -76,6 +76,23 @@ public: * Destructor */ virtual ~ClassBase(); + + /** + * Construct a new instance of the object + * @return Base + */ + Base* construct(struct _zend_object *object) + { + // construct the base + auto *result = construct(); + if (!result) return nullptr; + + // assign the zend object to it + result->assign(object); + + // done + return result; + } /** * Construct a new instance of the object |