diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-07-26 15:37:59 +0200 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-07-26 15:37:59 +0200 |
commit | 542e8a44708668001e59cf08b61c642da5080825 (patch) | |
tree | 8e9abf3fbd3cee887cbc096c76daea1be4b99027 /include/value.h | |
parent | 4104abb21a40fa0057c488199769b24519aa1da7 (diff) | |
parent | b6cc95e9a96edf3a1733c4f562d42eed79dd8946 (diff) |
Merge branch 'is_a' of https://github.com/andot/PHP-CPP
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 |