diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-07-26 17:00:10 +0200 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-07-26 17:00:10 +0200 |
commit | 3f1d5ca94f721cf7feff0fc9cb05a5c1b6d39873 (patch) | |
tree | fe166c06985a968e255cc9ca1687c24704c69c42 /include/value.h | |
parent | 542e8a44708668001e59cf08b61c642da5080825 (diff) |
added Value::subclassOf(), and implemented Php::is_a() and Php::is_subclass_of()
Diffstat (limited to 'include/value.h')
-rw-r--r-- | include/value.h | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/include/value.h b/include/value.h index b3c288c..e6b8d69 100644 --- a/include/value.h +++ b/include/value.h @@ -964,29 +964,39 @@ public: // try casting it return dynamic_cast<T*>(base); } - + /** - * Checks if this object is of the class or has the class as one of its parents - * @param classname - * @param allow_string + * Check whether this object is an instance of a certain class + * + * If you set the parameter 'allowString' to true, and the Value object + * holds a string, the string will be treated as class name. + * + * @param classname The class of which this should be an instance + * @param size Length of the classname string + * @param allowString Is it allowed for 'this' to be a string * @return bool */ - inline bool is(const std::string &classname, bool allow_string=false) const { - return isImpl(classname, allow_string, false); - } + bool instanceOf(const char *classname, size_t size, bool allowString = false) const; + bool instanceOf(const char *classname, bool allowString = false) const { return instanceOf(classname, strlen(classname), allowString); } + bool instanceOf(const std::string &classname, bool allowString = false) const { return instanceOf(classname.c_str(), classname.size(), allowString); } /** - * Checks if this object has the class as one of its parents - * @param classname + * Check whether this object is derived from a certain class. + * + * If you set the parameter 'allowString' to true, and the Value object + * holds a string, the string will be treated as class name. + * + * @param classname The class of which this should be an instance + * @param size Length of the classname string + * @param allowString Is it allowed for 'this' to be a string * @return bool */ - inline bool isSubClassOf(const std::string &classname, bool allow_string=true) const { - return isImpl(classname, allow_string, true); - } + bool subclassOf(const char *classname, size_t size, bool allowString = false) const; + bool subclassOf(const char *classname, bool allowString = false) const { return subclassOf(classname, strlen(classname), allowString); } + bool subclassOf(const std::string &classname, bool allowString = false) const { return subclassOf(classname.c_str(), classname.size(), allowString); } -private: - bool isImpl(const std::string &classname, bool allow_string, bool only_subclass) const; +private: /** * Call function with a number of parameters * @param argc Number of parameters @@ -1070,6 +1080,13 @@ protected: iterator createIterator(bool begin) const; /** + * Retrieve the class entry + * @param allowString Allow the 'this' object to be a string + * @return zend_class_entry + */ + struct _zend_class_entry *classEntry(bool allowString = true) const; + + /** * The Globals and Member classes can access the zval directly */ friend class Globals; |