diff options
author | andot <mabingyao@gmail.com> | 2014-07-10 13:06:22 +0800 |
---|---|---|
committer | andot <mabingyao@gmail.com> | 2014-07-10 13:06:22 +0800 |
commit | b6cc95e9a96edf3a1733c4f562d42eed79dd8946 (patch) | |
tree | b3e8e711ec17ef33699c1d2679da9560d7cf93c4 /include/value.h | |
parent | 28578382589dab25ea5fbd35b7754687706abc07 (diff) |
Add Php::is_a implementation.
Add is, isSubClassOf for Php::Value.
Add Php::is_a implementation.
Add Php::is_subclass_of implementation.
Diffstat (limited to 'include/value.h')
-rw-r--r-- | include/value.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/value.h b/include/value.h index f72304c..b3c288c 100644 --- a/include/value.h +++ b/include/value.h @@ -965,7 +965,28 @@ public: 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 + * @return bool + */ + inline bool is(const std::string &classname, bool allow_string=false) const { + return isImpl(classname, allow_string, false); + } + + /** + * Checks if this object has the class as one of its parents + * @param classname + * @return bool + */ + inline bool isSubClassOf(const std::string &classname, bool allow_string=true) const { + return isImpl(classname, allow_string, true); + } + private: + + bool isImpl(const std::string &classname, bool allow_string, bool only_subclass) const; /** * Call function with a number of parameters * @param argc Number of parameters |