Parameter Names

As additional meta information it is possible to provide the names of arguments for methods or constructors. This information is then accessible via an object of type parameter_info.

Please take a look at following example:

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")
);
}
The array_range class provides a view into an underlying data structure with lower and upper limits.
Definition array_range.h:64
Definition access_levels.h:34
#define RTTR_REGISTRATION
Use this macro to automatically register your reflection information to RTTR before main is called.
Definition registration.h:745

The names has to a string literal (i.e. const char*) and provided via the function: parameter_names(). Place the call in the () operator of the returned bind object.

Remarks
It is not possible to provide just one name, when you use this function, you have to provide names for all arguments.

The function has following synopsis:

template<typename...TArgs>
detail::parameter_names<detail::decay_t<TArgs>...> parameter_names(TArgs&&...args)

The names can be retrieved via the parameter_info class. Take a look at the following example:

int main()
{
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;
}
}
The method class provides several meta information about a method and can be invoked.
Definition method.h:122
array_range< parameter_info > get_parameter_infos() const noexcept
Returns an ordered range of parameter_info objects, which matches the signature of the method.

Output:

 name: 'window name'
index: 0
 name: 'width'
index: 1
 name: 'height'
index: 2