diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2013-09-08 16:26:11 -0700 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2013-09-08 16:26:11 -0700 |
commit | df2520e4b2c87e2302ee4c6cec1e672091efebfb (patch) | |
tree | f3bcd4fa7c4d0c6ee601268ceca4d6841ed90d0d /include/argument.h | |
parent | eb86ac350756afeffa0e2db8be87876d35bc40a8 (diff) |
Refactoring function class, and making it even more easy to directly enable native C functions in PHP
Diffstat (limited to 'include/argument.h')
-rw-r--r-- | include/argument.h | 127 |
1 files changed, 47 insertions, 80 deletions
diff --git a/include/argument.h b/include/argument.h index 5c0c23f..7a95f7d 100644 --- a/include/argument.h +++ b/include/argument.h @@ -9,14 +9,14 @@ */ /** - * Set up namespace + * Forward declaration */ -namespace PhpCpp { +struct _zend_arg_info; /** - * Forward definitions + * Set up namespace */ -class ArgInfo; +namespace Php { /** * Class definition @@ -25,105 +25,72 @@ 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? + * Prevent copying + * @param argument */ - Argument(const std::string &name, const std::string &classname, bool null = true, bool ref = false); - + Argument(const Argument &argument) = delete; + /** - * Constructor if the argument can be anything - * Note that only arrayType and callableType are supported type-hints - * @param name Name of the argument - * @param type Type hint (arrayType or callableType) - * @param ref Is this a pass-by-reference argument? + * Move constructor + * @param argument */ - Argument(const std::string &name, Type type = nullType, bool ref = false); - + Argument(Argument &&argument); + /** - * Constructor if the argument can be anything - * @param name Name of the argument - * @param ref Is this a pass-by-reference argument? + * Destructor */ - Argument(const std::string &name, bool ref = false); + virtual ~Argument() {}; /** - * Copy constructor - * @param argument The argument to copy + * Change the name + * @param name + * @return Argument */ - Argument(const Argument &argument) - { - // copy members - _refcount = argument._refcount; - _info = argument._info; - - // increase references - (*_refcount)++; - } + Argument &name(const char *name); /** - * Destructor + * Change the type + * @param type + * @return Argument */ - virtual ~Argument() - { - // cleanup current object - cleanup(); - } - + Argument &type(Type type = nullType); + /** - * Copy operator - * @param argument The argument to copy + * Require the parameter to be a certain class + * @param name Name of the class + * @param null Are null values allowed? * @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; - } + Argument &object(const char *classname, bool null = true); /** - * Retrieve argument info - * @return ArgInfo - * @internal + * Is this a by-ref argument? + * @param bool Mark as by-ref variable + * @return Argument */ - ArgInfo *internal() const - { - return _info; - } - -private: + Argument &byref(bool value = true); + /** - * Number of references - * @var int + * Prevent copy + * @param argument The argument to copy + * @return Argument */ - int *_refcount; - + Argument &operator=(const Argument &argument) = delete; + +protected: /** - * Pointer to the implementation - * @var ArgInfo + * Protected constructor, to prevent that users can instantiate the + * argument object themselves + * @param info */ - ArgInfo *_info; - + Argument(struct _zend_arg_info *info) : _info(info) {} + +private: /** - * Remove one reference from the object + * The argument info + * @var zend_arg_info */ - void cleanup(); - + struct _zend_arg_info *_info; }; /** |