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 | |
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')
-rw-r--r-- | include/fastcall.h | 18 | ||||
-rw-r--r-- | include/value.h | 21 |
2 files changed, 39 insertions, 0 deletions
diff --git a/include/fastcall.h b/include/fastcall.h new file mode 100644 index 0000000..778a9b2 --- /dev/null +++ b/include/fastcall.h @@ -0,0 +1,18 @@ +/** + * fastcall.h + * + * This file holds some PHP functions implementation in C directly. + * + */ + +namespace Php { + + inline bool is_a(const Value &obj, const std::string classname, bool allow_string = false) { + return obj.is(classname, allow_string); + } + inline bool is_subclass_of(const Value &obj, const std::string classname, bool allow_string = true) { + return obj.isSubClassOf(classname, allow_string); + } + +} + 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 |