diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-02-28 15:17:53 +0100 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-02-28 15:17:53 +0100 |
commit | 7cf89f18d766368dd4a14d35e4e144107ad7be36 (patch) | |
tree | 0bd4e449cbfddc928c25aaa1abac8b44c028c8e2 /include/classbase.h | |
parent | 6072701319a3bf085bbc354c3e3dae9b7d021be0 (diff) |
implemented properties
Diffstat (limited to 'include/classbase.h')
-rw-r--r-- | include/classbase.h | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/include/classbase.h b/include/classbase.h index ad382fb..8b6d3dd 100644 --- a/include/classbase.h +++ b/include/classbase.h @@ -31,6 +31,7 @@ typedef Value (Base::*method_callback_3)(Parameters &); * Forward declarations */ class Method; +class Member; /** * Class definition @@ -115,6 +116,30 @@ protected: void add(const char *name, method_callback_2, int flags=0, const Arguments &args = {}); void add(const char *name, method_callback_3, int flags=0, const Arguments &args = {}); + /** + * Add a property to the class + * + * Every instance of this class will have this property. The property + * can be Php::Public, Php::Protected or Php::Private (altough setting + * private properties is odd as the implementation of the class is in CPP, + * so why use private properties while the whole implementation is already + * hidden) + * + * @param name Name of the property + * @param value Actual property value + * @param flags Optional flags + */ + void add(const char *name, std::nullptr_t value, int flags = Php::Public); + void add(const char *name, int16_t value, int flags = Php::Public); + void add(const char *name, int32_t value, int flags = Php::Public); + void add(const char *name, int64_t value, int flags = Php::Public); + void add(const char *name, bool value, int flags = Php::Public); + void add(const char *name, char value, int flags = Php::Public); + void add(const char *name, const std::string &value, int flags = Php::Public); + void add(const char *name, const char *value, int flags = Php::Public); + void add(const char *name, double value, int flags = Php::Public); + + private: /** * Retrieve an array of zend_function_entry objects that hold the @@ -151,16 +176,16 @@ private: struct _zend_function_entry *_entries = nullptr; /** - * All class methods, this is a map indexed by method name + * All class methods * @var set */ std::set<std::shared_ptr<Method>> _methods; /** - * All class properties, also a map indexed by name - * @var Properties + * All class members (class properties) + * @var set */ -// std::map<std::string,Property> _properties; + std::set<std::shared_ptr<Member>> _members; }; /** |