From 51f4788b2b51a21894ae49821abc67c2fab4a68a Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Sun, 2 Mar 2014 15:49:55 +0100 Subject: fixed settings Base::_self variable to a valid, editable value object --- include/base.h | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 84 insertions(+), 11 deletions(-) (limited to 'include/base.h') diff --git a/include/base.h b/include/base.h index 04f0c0e..7d7be98 100644 --- a/include/base.h +++ b/include/base.h @@ -29,45 +29,118 @@ public: /** * Convert the object to a Php::Value object (how it is used externally) + * @return Object + */ + Object &value() + { + return _self; + } + + /** + * Convert the object to a Php::Value object (how it is used externally) + * @return Object + */ + const Object &value() const + { + return _self; + } + + /** + * Get access to a property by name using the [] operator + * @param string * @return Value */ - Value value() const; + Value operator[](const char *name) + { + return _self[name]; + } + + /** + * Alternative way to access a property using the [] operator + * @param string + * @return Value + */ + Value operator[](const std::string &name) + { + return _self[name]; + } /** - * Get access to a property by name + * Retrieve a property by name + * @param string + * @return Value + */ + Value property(const char *name) + { + return _self[name]; + } + + /** + * Retrieve a property by name + * @param string + * @return Value + */ + Value property(const std::string &name) + { + return _self[name]; + } + + /** + * Get access to a property by name using the [] operator * @param string * @return Value */ Value operator[](const char *name) const { - return value()[name]; + return _self[name]; } /** - * Alternative way to access a property + * Alternative way to access a property using the [] operator * @param string * @return Value */ Value operator[](const std::string &name) const { - return value()[name]; + return _self[name]; } -private: /** - * The zend_object - * @var zend_object + * Retrieve a property by name + * @param string + * @return Value + */ + Value property(const char *name) const + { + return _self[name]; + } + + /** + * Retrieve a property by name + * @param string + * @return Value */ - struct _zend_object *_object = nullptr; + Value property(const std::string &name) const + { + return _self[name]; + } +protected: + /** + * The zend_object + * @var Value + */ + Object _self; + +private: /** * Private method to assign the zend object * @param zend_object */ - void assign(struct _zend_object *object) + void assign(Value &&object) { // copy pointer - _object = object; + _self = std::move(object); } /** -- cgit v1.2.3