summaryrefslogtreecommitdiff
path: root/zend/compileroptions.h
diff options
context:
space:
mode:
Diffstat (limited to 'zend/compileroptions.h')
-rw-r--r--zend/compileroptions.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/zend/compileroptions.h b/zend/compileroptions.h
new file mode 100644
index 0000000..798cb59
--- /dev/null
+++ b/zend/compileroptions.h
@@ -0,0 +1,57 @@
+/**
+ * CompilerOptions.h
+ *
+ * Helper class to temporarily set compiler options
+ *
+ * When an object is destructed, it automatically restored the previous compiler settings
+ *
+ * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
+ * @copyright 2014 Copernica BV
+ */
+
+/**
+ * Open PHP namespace
+ */
+namespace Php {
+
+/**
+ * Class definition
+ */
+class CompilerOptions
+{
+private:
+ /**
+ * The original compiler options
+ * @var int
+ */
+ zend_uint _original;
+
+public:
+ /**
+ * Constructor
+ * @param options
+ */
+ CompilerOptions(zend_uint options)
+ {
+ // remember the old compiler options before we set temporary compile options
+ _original = CG(compiler_options);
+
+ // we're going to evaluate only once
+ CG(compiler_options) = options;
+ }
+
+ /**
+ * Destructor
+ */
+ virtual ~CompilerOptions()
+ {
+ // restore original options
+ CG(compiler_options) = _original;
+ }
+};
+
+/**
+ * End of namespace
+ */
+}
+