rttr::parameter_info Class Reference

The parameter_info class provides several meta information about a parameter. More...

#include <parameter_info.h>

Public Member Functions

variant get_default_value () const
 Returns the default value as variant for this parameter; or an invalid variant to indicate that no default value is available. More...
 
uint32_t get_index () const
 Returns the zero-based position of the parameter in the formal parameter list. More...
 
std::string get_name () const
 Returns the name of this parameter. More...
 
type get_type () const
 Returns type of this parameter. More...
 
bool has_default_value () const
 Returns true when this parameter has a default value; otherwise false. More...
 
bool operator!= (const parameter_info &other) const
 Returns true if this property is the not the same like the other. More...
 
bool operator== (const parameter_info &other) const
 Returns true if this property is the same like the other. More...
 

Detailed Description

The parameter_info class provides several meta information about a parameter.

A instance of a parameter_info class can be obtained from the method or constructor class. See method::get_parameter_infos() and constructor::get_parameter_infos().

For registration additional parameter infos, see parameter_names().

Meta Information

Copying and Assignment

A parameter_info object is lightweight and can be copied by value. However, each copy will refer to the same underlying parameter_info.

Typical Usage

using namespace rttr;
void set_window_geometry(const char* name, int w, int h) {...}
{
registration::method("set_window_geometry", &set_window_geometry)
(
parameter_names("window name", "width", "height")
);
}
//...
method meth = type::get_global_method("set_window_geometry");
std::vector<parameter_info> param_list = meth.get_parameter_infos();
for (const auto& info : param_list)
{
// print all names of the parameter types and its position in the paramter list
std::cout << " name: '" << info.get_type().get_name() << "'\n"
<< "index: " << info.get_index()
<< std::endl;
}

Output:

 name: 'window name'
index: 0
 name: 'width'
index: 1
 name: 'height'
index: 2
See also
method and constructor

Member Function Documentation

variant rttr::parameter_info::get_default_value ( ) const

Returns the default value as variant for this parameter; or an invalid variant to indicate that no default value is available.

Returns
Default value as variant.
uint32_t rttr::parameter_info::get_index ( ) const

Returns the zero-based position of the parameter in the formal parameter list.

Returns
An integer representing the position this parameter occupies in the parameter list.
std::string rttr::parameter_info::get_name ( ) const

Returns the name of this parameter.

When no name was provided during registration via parameter_names(), then an empty string is returned.

Returns
The name of the parameter.
type rttr::parameter_info::get_type ( ) const

Returns type of this parameter.

Returns
Parameter type.
bool rttr::parameter_info::has_default_value ( ) const

Returns true when this parameter has a default value; otherwise false.

Returns
Bool to indicate that this parameter has a default value.
bool rttr::parameter_info::operator!= ( const parameter_info other) const

Returns true if this property is the not the same like the other.

Returns
True if both properties are different, otherwise false.
bool rttr::parameter_info::operator== ( const parameter_info other) const

Returns true if this property is the same like the other.

Returns
True if both properties are equal, otherwise false.

The documentation for this class was generated from the following file: