Rice
3.0.0
|
Helper for defining default arguments of a method. More...
#include <Arg_impl.hpp>
Public Member Functions | |
Arg (const char *name) | |
Initialize a new Arg with the name of the argument. More... | |
Arg (const Arg &other) | |
Copy Constructor. | |
template<typename Arg_Type > | |
Arg & | operator= (Arg_Type val) |
Set the default value for this Arg. More... | |
bool | hasDefaultValue () const |
Check if this Arg has a default value associated with it. | |
template<typename Arg_Type > | |
Arg_Type | getDefaultValue () |
Return the default value associated with this Arg. More... | |
const char * | name () const |
Get the name of this Arg. | |
Public Attributes | |
type_base * | defaultValue |
Our saved default value. | |
Helper for defining default arguments of a method.
This class exposes the ability to define the default values of a wrapped method. Inspired by how Boost.Python handles keyword and default arguments, the syntax is simple:
which means "for method &method, it takes 3 arguments [arg1, arg2, arg3]. Of these arguments, arg2's default is 3 and arg3's default is true.
It may be required to explicitly cast the type of the default value to prevent compilation errors.
|
inline |
Initialize a new Arg with the name of the argument.
We require the name of the argument because 1) it makes code easier to read and 2) hopefully Ruby gets keyword arguments in the future and this means Rice will be ready for it.
|
inline |
Return the default value associated with this Arg.
References defaultValue.
|
inline |
Set the default value for this Arg.
Set the default value for this argument. If this isn't called on this Arg, then this Arg is required in the method call.
val | the value to store as default |
References defaultValue.