summaryrefslogtreecommitdiff
path: root/src/stringmember.h
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-02-28 15:17:53 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-02-28 15:17:53 +0100
commit7cf89f18d766368dd4a14d35e4e144107ad7be36 (patch)
tree0bd4e449cbfddc928c25aaa1abac8b44c028c8e2 /src/stringmember.h
parent6072701319a3bf085bbc354c3e3dae9b7d021be0 (diff)
implemented properties
Diffstat (limited to 'src/stringmember.h')
-rw-r--r--src/stringmember.h43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/stringmember.h b/src/stringmember.h
index c5e2a45..c80e0a1 100644
--- a/src/stringmember.h
+++ b/src/stringmember.h
@@ -15,7 +15,7 @@ namespace Php {
/**
* Class definition
*/
-class StringMember : public MemberInfo
+class StringMember : public Member
{
private:
/**
@@ -27,16 +27,28 @@ private:
public:
/**
* Constructor
+ * @param name
* @param value
+ * @param size
+ * @param flags
*/
- StringMember(const std::string &value) : MemberInfo(), _value(value) {}
+ StringMember(const char *name, const char *value, size_t size, int flags) : Member(name, flags), _value(value, size) {}
/**
* Constructor
+ * @param name
* @param value
- * @param size
+ * @param flags
+ */
+ StringMember(const char *name, const char *value, int flags) : StringMember(name, value, strlen(value), flags) {}
+
+ /**
+ * Constructor
+ * @param name
+ * @param value
+ * @param flags
*/
- StringMember(const char *value, int size) : MemberInfo(), _value(value, size) {}
+ StringMember(const char *name, const std::string &value, int flags) : Member(name, flags), _value(value) {}
/**
* Destructor
@@ -44,27 +56,22 @@ public:
virtual ~StringMember() {}
/**
- * Is this a property member
- * @return bool
+ * Virtual method to declare class constant
+ * @param entry Class entry
*/
- virtual bool isProperty() { return true; }
+ virtual void constant(struct _zend_class_entry *entry) override
+ {
+ zend_declare_class_constant_stringl(entry, _name.c_str(), _name.size(), _value.c_str(), _value.size());
+ }
/**
* Virtual method to declare the property
* @param entry Class entry
- * @param name Name of the member
- * @param size Size of the name
- * @param flags Additional flags
*/
- virtual void declare(struct _zend_class_entry *entry, const char *name, int size, MemberModifier flags) override
+ virtual void declare(struct _zend_class_entry *entry) override
{
-#if PHP_VERSION_ID >= 50400
- if (flags == constMember) zend_declare_class_constant_stringl(entry, name, size, _value.c_str(), _value.size());
- else zend_declare_property_stringl(entry, name, size, _value.c_str(), _value.size(), flags);
-#else
- if (flags == constMember) zend_declare_class_constant_stringl(entry, (char*) name, size, (char *) _value.c_str(), _value.size());
- else zend_declare_property_stringl(entry, (char*) name, size, (char *) _value.c_str(), _value.size(), flags);
-#endif
+ // cast to char* is necessary for php 5.3
+ zend_declare_property_stringl(entry, (char *)_name.c_str(), _name.size(), (char *)_value.c_str(), _value.size(), _flags);
}
};