diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/class.h | 12 | ||||
-rw-r--r-- | include/classbase.h | 20 | ||||
-rw-r--r-- | include/interface.h | 10 |
3 files changed, 41 insertions, 1 deletions
diff --git a/include/class.h b/include/class.h index d1afab2..bb05fdd 100644 --- a/include/class.h +++ b/include/class.h @@ -204,9 +204,19 @@ private: */ virtual bool traversable() const override { - // check if the templated class overrides from the base + // check if the templated class overrides from the Traversable class return std::is_base_of<Traversable,T>::value; } + + /** + * Is this a serializable class? + * @return bool + */ + virtual bool serializable() const override + { + // check if the templated class overrides from the Serializable class + return std::is_base_of<Serializable,T>::value; + } /** * Compare two objects diff --git a/include/classbase.h b/include/classbase.h index 814feaf..cc69a91 100644 --- a/include/classbase.h +++ b/include/classbase.h @@ -20,6 +20,8 @@ struct _zend_object_value; struct _zend_object_handlers; struct _zend_class_entry; +struct _zend_serialize_data; +struct _zend_unserialize_data; union _zend_function; /** @@ -132,6 +134,12 @@ public: virtual bool traversable() const = 0; /** + * Is this a serializable class? + * @return bool + */ + virtual bool serializable() const = 0; + + /** * Initialize the class, given its name * * The module functions are registered on module startup, but classes are @@ -426,6 +434,18 @@ private: static int compare(struct _zval_struct *object1, struct _zval_struct *object2); /** + * Methods that are called to serialize/unserialize an object + * @param object The object to be serialized + * @param entry The class entry to which the object belongs + * @param buffer Buffer in which to store the data + * @param buf_len Size of the bufffer + * @param data Structure describing the serialize/unserialize data + * @return int + */ + static int serialize(struct _zval_struct *object, unsigned char **buffer, zend_uint *buf_len, struct _zend_serialize_data *data); + static int unserialize(struct _zval_struct **object, struct _zend_class_entry *entry, const unsigned char *buffer, zend_uint buf_len, struct _zend_unserialize_data *data); + + /** * Name of the class * @var string */ diff --git a/include/interface.h b/include/interface.h index 52d1a97..f7ef387 100644 --- a/include/interface.h +++ b/include/interface.h @@ -83,6 +83,16 @@ private: } /** + * Is this a serializable class? + * @return bool + */ + virtual bool serializable() const override + { + // not called for interfaces + return false; + } + + /** * Namespaces have access to the private base class */ friend class Namespace; |