summaryrefslogtreecommitdiff
path: root/src/classbase.cpp
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 /src/classbase.cpp
parent01fa31d24d6669ee30ccb897a0a7f438bcbe59f0 (diff)
added serializable class (but not yet implemented it)
Diffstat (limited to 'src/classbase.cpp')
-rw-r--r--src/classbase.cpp41
1 files changed, 39 insertions, 2 deletions
diff --git a/src/classbase.cpp b/src/classbase.cpp
index 03c5512..0e39ae1 100644
--- a/src/classbase.cpp
+++ b/src/classbase.cpp
@@ -1004,6 +1004,36 @@ zend_object_iterator *ClassBase::getIterator(zend_class_entry *entry, zval *obje
}
/**
+ * Method that is called to serialize an object
+ * @param object The object to be serialized
+ * @param buffer Buffer in which to store the data
+ * @param buf_len Size of the bufffer
+ * @param data ??
+ * @return int
+ */
+int ClassBase::serialize(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data)
+{
+ std::cout << "serialize is called" << std::endl;
+
+ return SUCCESS;
+}
+
+/**
+ * Method that is called to unserialize an object
+ * @param object The object to be unserialized
+ * @param entry The class entry to which is belongs
+ * @param buffer Buffer holding the unserialized data
+ * @param data All the unserialize data
+ * @return int
+ */
+int ClassBase::unserialize(zval **object, zend_class_entry *entry, const unsigned char *buffer, zend_uint buf_len, zend_unserialize_data *data)
+{
+ std::cout << "unserialize is called" << std::endl;
+
+ return SUCCESS;
+}
+
+/**
* Destructor
*/
ClassBase::~ClassBase()
@@ -1081,10 +1111,17 @@ void ClassBase::initialize(const std::string &prefix)
// we need a special constructor
entry.create_object = &ClassBase::createObject;
- // and a special function for retrieving the iterator (but only if this is
- // a traversable class)
+ // for traversable classes we install a special method to get the iterator
if (traversable()) entry.get_iterator = &ClassBase::getIterator;
+ // for serializable classes, we install callbacks for serializing and unserializing
+ if (serializable())
+ {
+ // add handlers to serialize and unserialize
+ entry.serialize = &ClassBase::serialize;
+ entry.unserialize = &ClassBase::unserialize;
+ }
+
// register the class
_entry = zend_register_internal_class(&entry TSRMLS_CC);