ponder 3.2
C++ reflection library
ponder::Args Class Reference

Wrapper for packing an arbitrary number of arguments into a single object. More...

#include <args.hpp>

Public Member Functions

template<typename... V>
 Args (V &&... args)
 Construct the list with variable arguments. More...
 
 Args (std::initializer_list< Value > il)
 Initialise the list with an initialisation list. More...
 
size_t count () const
 Return the number of arguments contained in the list. More...
 
const Valueoperator[] (size_t index) const
 Overload of operator [] to access an argument from its index. More...
 
Args operator+ (const Value &arg) const
 Overload of operator + to concatenate a list and a new argument. More...
 
Argsoperator+= (const Value &arg)
 Overload of operator += to append a new argument to the list. More...
 
Argsinsert (size_t index, const Value &arg)
 Insert an argument into the list at a given index. More...
 

Static Public Attributes

static const Args empty
 Special instance representing an empty set of arguments.
 

Detailed Description

Wrapper for packing an arbitrary number of arguments into a single object.

ponder::Args is defined as a list of arguments of any type (wrapped in ponder::Value instances), which can be passed to all the Ponder entities which may need an arbitrary number of arguments in a uniform way.

Arguments lists can be constructed on the fly:

ponder::Args args(1, true, "hello", 5.24, &myObject);

or appended one by one using the + and += operators:

args += 1;
args += true;
args += "hello";
args += 5.24;
args = args + myObject;

Constructor & Destructor Documentation

◆ Args() [1/2]

template<typename... V>
ponder::Args::Args ( V &&...  args)
inline

Construct the list with variable arguments.

Parameters
argsParameter pack to be used.

◆ Args() [2/2]

ponder::Args::Args ( std::initializer_list< Value il)
inline

Initialise the list with an initialisation list.

Parameters
ilArguments to put in the list.

Member Function Documentation

◆ count()

size_t ponder::Args::count ( ) const

Return the number of arguments contained in the list.

Returns
Size of the arguments list

◆ insert()

Args& ponder::Args::insert ( size_t  index,
const Value arg 
)

Insert an argument into the list at a given index.

Parameters
indexIndex at which to insert the argument
argArgument to append to the list
Returns
Reference to this

◆ operator+()

Args ponder::Args::operator+ ( const Value arg) const

Overload of operator + to concatenate a list and a new argument.

Parameters
argArgument to concatenate to the list
Returns
New list

◆ operator+=()

Args& ponder::Args::operator+= ( const Value arg)

Overload of operator += to append a new argument to the list.

Parameters
argArgument to append to the list
Returns
Reference to this

◆ operator[]()

const Value& ponder::Args::operator[] ( size_t  index) const

Overload of operator [] to access an argument from its index.

Parameters
indexIndex of the argument to get
Returns
Value of the index-th argument
Exceptions
OutOfRangeindex is out of range

The documentation for this class was generated from the following file:
ponder::Args
Wrapper for packing an arbitrary number of arguments into a single object.
Definition: args.hpp:68