From 01fa31d24d6669ee30ccb897a0a7f438bcbe59f0 Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Thu, 13 Mar 2014 09:45:02 +0100 Subject: introduced serializable interface, and first setup for callback methods --- include/serializable.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 include/serializable.h (limited to 'include/serializable.h') diff --git a/include/serializable.h b/include/serializable.h new file mode 100644 index 0000000..67934a9 --- /dev/null +++ b/include/serializable.h @@ -0,0 +1,51 @@ +/** + * Serializable interface + * + * This interface can be implemented to make an object that can be passed to + * the PHP serialize() and unserialize() methods. + * + * @author Emiel Bruijntjes + * @copyright 2014 Copernica BV + */ + +/** + * Set up namespace + */ +namespace Php { + +/** + * Class definition + */ +class Serializable +{ +public: + /** + * Method to serialize the object + * + * This method should return a string representation of the object that + * can be passed to the serialize() method and that will revive the object + * + * @return Php::Value + */ + virtual Php::Value serialize() = 0; + + /** + * Unserialize the object + * + * This method is called as an alternative __construct() method to initialize + * the object. The passed in string parameter in in the format earlier returned + * by a call to serialize() + * + * @param input String to parse + * @param size Size of the string + */ + virtual void unserialize(const char *input, size_t size) = 0; +}; + +/** + * End namespace + */ +} + + + \ No newline at end of file -- cgit v1.2.3