summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-07-26 15:37:59 +0200
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-07-26 15:37:59 +0200
commit542e8a44708668001e59cf08b61c642da5080825 (patch)
tree8e9abf3fbd3cee887cbc096c76daea1be4b99027 /include
parent4104abb21a40fa0057c488199769b24519aa1da7 (diff)
parentb6cc95e9a96edf3a1733c4f562d42eed79dd8946 (diff)
Merge branch 'is_a' of https://github.com/andot/PHP-CPP
Diffstat (limited to 'include')
-rw-r--r--include/fastcall.h18
-rw-r--r--include/value.h21
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