summaryrefslogtreecommitdiff
path: root/src/argument.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/argument.cpp')
-rw-r--r--src/argument.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/argument.cpp b/src/argument.cpp
new file mode 100644
index 0000000..153da9c
--- /dev/null
+++ b/src/argument.cpp
@@ -0,0 +1,60 @@
+/**
+ * Argument.cpp
+ *
+ * Implementation for the Argument class
+ *
+ * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
+ * @copyright 2013 Copernica BV
+ */
+#include "includes.h"
+
+/**
+ * Set up namespace
+ */
+namespace PhpCpp {
+
+/**
+ * Constructor if this argument should be an instance of a certain class
+ * @param name Name of the argument
+ * @param classname If a specific class is required, the class type
+ * @param null Are NULL values allowed in stead of an instance?
+ * @param ref Is this a pass-by-reference argument?
+ */
+Argument::Argument(const std::string &name, const std::string &classname, bool null, bool ref)
+{
+ _refcount = new int[1];
+ _info = new ArgInfo(name, classname, null, ref);
+}
+
+/**
+ * Constructor if the argument can be anything
+ * @param name Name of the argument
+ * @param type Type hint
+ * @param ref Is this a pass-by-reference argument?
+ */
+Argument::Argument(const std::string &name, Type type, bool ref)
+{
+ _refcount = new int[1];
+ _info = new ArgInfo(name, type, ref);
+}
+
+/**
+ * Clean up the object
+ */
+void Argument::cleanup()
+{
+ // one reference less
+ (*_refcount)--;
+
+ // leap out if still in use
+ if (*_refcount > 0) return;
+
+ // release memory
+ delete _refcount;
+ delete _info;
+}
+
+/**
+ * End of namespace
+ */
+}