summaryrefslogtreecommitdiff
path: root/include/argument.h
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-08-25 17:40:03 +0200
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-08-25 17:40:03 +0200
commite14055694478d70e58b5fc653b08a9a514bbc455 (patch)
treeab47d723699a7fe86f47f68c182ab695bf9b3bab /include/argument.h
parente838e180f5bbcf19e7235f30311645e942ff92d2 (diff)
{more work in progress: the function that was defined with c++ now gets calls, but it does not yet call the actual implementation
Diffstat (limited to 'include/argument.h')
-rw-r--r--include/argument.h125
1 files changed, 125 insertions, 0 deletions
diff --git a/include/argument.h b/include/argument.h
new file mode 100644
index 0000000..862b677
--- /dev/null
+++ b/include/argument.h
@@ -0,0 +1,125 @@
+/**
+ * Argument.h
+ *
+ * Class holds information about an argument that is passed to a function.
+ * You'll need this class when you're defining your own functions.
+ *
+ * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
+ * @copyright 2013 Copernica BV
+ */
+
+/**
+ * Set up namespace
+ */
+namespace PhpCpp {
+
+/**
+ * Forward definitions
+ */
+class ArgInfo;
+
+/**
+ * Class definition
+ */
+class Argument
+{
+public:
+ /**
+ * 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(const std::string &name, const std::string &classname, bool null = true, bool ref = false);
+
+ /**
+ * 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(const std::string &name, Type type = nullType, bool ref = false);
+
+ /**
+ * Copy constructor
+ * @param argument The argument to copy
+ */
+ Argument(const Argument &argument)
+ {
+ // copy members
+ _refcount = argument._refcount;
+ _info = argument._info;
+
+ // increase references
+ (*_refcount)++;
+ }
+
+ /**
+ * Destructor
+ */
+ virtual ~Argument()
+ {
+ // cleanup current object
+ cleanup();
+ }
+
+ /**
+ * Copy operator
+ * @param argument The argument to copy
+ * @return Argument
+ */
+ Argument &operator=(const Argument &argument)
+ {
+ // skip self assignment
+ if (this == &argument) return *this;
+
+ // clean up current object
+ cleanup();
+
+ // copy members
+ _refcount = argument._refcount;
+ _info = argument._info;
+
+ // increase references
+ (*_refcount)++;
+
+ // done
+ return *this;
+ }
+
+ /**
+ * Retrieve argument info
+ * @return ArgInfo
+ * @internal
+ */
+ ArgInfo *internal() const
+ {
+ return _info;
+ }
+
+private:
+ /**
+ * Number of references
+ * @var int
+ */
+ int *_refcount;
+
+ /**
+ * Pointer to the implementation
+ * @var ArgInfo
+ */
+ ArgInfo *_info;
+
+ /**
+ * Remove one reference from the object
+ */
+ void cleanup();
+
+};
+
+/**
+ * End of namespace
+ */
+}
+