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 /src | |
parent | 9c2c6bbb77974344d3f1e344716391e4e5aa5345 (diff) |
Added method to retrieve the implementation class from a Value object
Diffstat (limited to 'src')
-rw-r--r-- | src/value.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/value.cpp b/src/value.cpp index 4170404..fd300d5 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -1554,6 +1554,27 @@ HashMember<std::string> Value::operator[](const char *key) } /** + * 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 *Value::implementation() const +{ + // must be an object + if (!isObject()) return nullptr; + + // retrieve the mixed object that contains the base + MixedObject *object = (MixedObject *)zend_object_store_get_object(_val); + if (!object) return nullptr; + + // retrieve the associated C++ class + return object->cpp; +} + +/** * Custom output stream operator * @param stream * @param value |