diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-02-24 06:05:22 -0800 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-02-24 06:05:22 -0800 |
commit | 22a4772fa7ce98d9cda73f0a0c50e69b9ff8f8d2 (patch) | |
tree | 55699fea16ca1edd37e01667034e35b0c685c489 /include/value.h | |
parent | 9c2c6bbb77974344d3f1e344716391e4e5aa5345 (diff) |
Added method to retrieve the implementation class from a Value object
Diffstat (limited to 'include/value.h')
-rw-r--r-- | include/value.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/include/value.h b/include/value.h index ff18d4e..9eddf40 100644 --- a/include/value.h +++ b/include/value.h @@ -31,6 +31,7 @@ namespace Php { /** * Forward definitions */ +class Base; template <class Type> class HashMember; /** @@ -599,6 +600,35 @@ public: Value call(const std::string &name, Value p0, Value p1, Value p2, Value p3, Value p4, Value p5, Value p6, Value p7, Value p8); Value call(const std::string &name, Value p0, Value p1, Value p2, Value p3, Value p4, Value p5, Value p6, Value p7, Value p8, Value p9); + /** + * Retrieve the original implementation + * + * This only works for classes that were implemented using PHP-CPP, + * it returns nullptr for all other classes + * + * @return Base* + */ + Base *implementation() const; + + /** + * Retrieve the original implementation + * + * This only works for classes that were implemented using PHP-CPP, + * it returns nullptr for all other classes + * + * @return mixed + */ + template <typename T> + T *implementation() const + { + // retrieve the implementation + Base *base = implementation(); + if (!base) return nullptr; + + // try casting it + return dynamic_cast<T*>(base); + } + private: /** * Call function with a number of parameters |