summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-13 09:50:10 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-13 09:50:10 +0100
commit9df186180f25313d2182ef7a0bb807875888892c (patch)
tree723d667aef52ef4e57ea252bb780145f651490aa /include
parent01fa31d24d6669ee30ccb897a0a7f438bcbe59f0 (diff)
added serializable class (but not yet implemented it)
Diffstat (limited to 'include')
-rw-r--r--include/class.h12
-rw-r--r--include/classbase.h20
-rw-r--r--include/interface.h10
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;