diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2015-01-11 13:49:15 +0100 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2015-01-11 13:49:15 +0100 |
commit | ae9d580fe7a79052d614b7d48d8feb54836fe334 (patch) | |
tree | 874ed8c758b51a8c6f1b280620d70725f5936ac1 /include | |
parent | 1c663ea116121469e37ad2cb9480387c16c0236b (diff) |
added include(), require(), include_once() and require_once() methods, based on the Php::File class (feature built based on inspiration from pull request #147);
Diffstat (limited to 'include')
-rw-r--r-- | include/call.h | 5 | ||||
-rw-r--r-- | include/file.h | 20 |
2 files changed, 23 insertions, 2 deletions
diff --git a/include/call.h b/include/call.h index 1a0c59f..279cbac 100644 --- a/include/call.h +++ b/include/call.h @@ -19,13 +19,16 @@ extern bool class_exists(const char *classname, size_t size, bool autoload = tr inline bool class_exists(const char *classname, bool autoload = true) { return class_exists(classname, strlen(classname), autoload); } inline bool class_exists(const std::string &classname, bool autoload = true) { return class_exists(classname.c_str(), classname.size(), autoload); } extern Value eval(const std::string &phpCode); +extern Value include(const std::string &filename); +extern Value include_once(const std::string &filename); inline bool is_a(const Value &obj, const char *classname, size_t size, bool allow_string = false) { return obj.instanceOf(classname, size, allow_string); } inline bool is_a(const Value &obj, const char *classname, bool allow_string = false) { return is_a(obj, classname, strlen(classname), allow_string); } inline bool is_a(const Value &obj, const std::string &classname, bool allow_string = false) { return is_a(obj, classname.c_str(), classname.size(), allow_string); } inline bool is_subclass_of(const Value &obj, const char *classname, size_t size, bool allow_string = true) { return obj.derivedFrom(classname, size, allow_string); } inline bool is_subclass_of(const Value &obj, const char *classname, bool allow_string = true) { return is_subclass_of(obj, classname, strlen(classname), allow_string); } inline bool is_subclass_of(const Value &obj, const std::string &classname, bool allow_string = true) { return is_subclass_of(obj, classname.c_str(), classname.size(), allow_string); } - +extern Value require(const std::string &filename); +extern Value require_once(const std::string &filename); /** * Call a function in PHP diff --git a/include/file.h b/include/file.h index 6e24516..7029bb6 100644 --- a/include/file.h +++ b/include/file.h @@ -55,7 +55,19 @@ public: virtual ~File(); /** - * Include the file once + * Does the file exist? + * @return boolean + */ + bool exists(); + + /** + * Is this a valid file? + * @return boolean + */ + bool valid(); + + /** + * Execute the file once (do nothing if the file already was executed) * @return Php::Value */ Value once(); @@ -78,6 +90,12 @@ private: * @var Opcodes */ Opcodes *_opcodes = nullptr; + + /** + * Compile the file + * @return bool + */ + bool compile(); }; |