rttr Namespace Reference

Classes

class  argument
 The argument class is used for forwarding arguments to properties or methods. More...
 
struct  array_mapper
 The array_mapper class is a class template to access different array types via one common interface. More...
 
class  constructor
 The constructor class provides several meta information about a constructor and can be invoked. More...
 
class  destructor
 The destructor class provides a destructor for registered types. More...
 
class  enumeration
 The enumeration class provides several meta information about an enum. More...
 
class  instance
 The instance class is used for forwarding the instance of an object to invoke a property or method. More...
 
class  method
 The method class provides several meta information about a method and can be invoked. More...
 
class  parameter_info
 The parameter_info class provides several meta information about a parameter. More...
 
struct  policy
 The policy class contains all policies that can be used during the registration of reflection information. More...
 
class  property
 The property class provides several meta information about a property and gives read/write access to its value. More...
 
class  registration
 The registration class is the entry point for the manual registration of reflection information to the type system. More...
 
class  type
 The type class holds the type information for any arbitrary object. More...
 
class  variant
 The variant class allows to store data of any type and convert between these types transparently. More...
 
class  variant_array_view
 The variant_array_view describes a class that refers to an array inside a variant. More...
 
struct  wrapper_mapper
 The wrapper_mapper class is a class template to access different wrapper types via one common interface. More...
 

Enumerations

enum  access_levels { access_levels::public_access, access_levels::protected_access, access_levels::private_access }
 The access_levels enum represents the three access modifiers, which can be used in classes to encapsulate members access. More...
 

Functions

template<typename... TArgs>
detail::default_args< TArgs... > default_arguments (TArgs &&...args)
 The default_arguments function should be used add default arguments, for constructors or a methods during the registration process of reflection information. More...
 
detail::metadata metadata (variant key, variant value)
 The metadata function can be used to add additional meta data information during the registration process of reflection information. More...
 
template<typename... TArgs>
detail::parameter_names< detail::decay_t< TArgs >... > parameter_names (TArgs &&...args)
 The parameter_names function should be used add human-readable names of the parameters, for constructors or a methods during the registration process of reflection information. More...
 
template<typename Target_Type , typename Source_Type >
Target_Type rttr_cast (Source_Type object)
 Casts the given object of type Source_Type to an object of type Target_Type. More...
 
template<typename ClassType , typename ReturnType , typename... Args>
auto select_const (ReturnType(ClassType::*func)(Args...) const) -> decltype(func)
 This is a helper function to register overloaded const member functions. More...
 
template<typename ClassType , typename ReturnType , typename... Args>
auto select_non_const (ReturnType(ClassType::*func)(Args...)) -> decltype(func)
 This is a helper function to register overloaded const member functions. More...
 
template<typename Signature >
Signature * select_overload (Signature *func)
 This is a helper function to register overloaded functions. More...
 
template<typename Signature , typename ClassType >
auto select_overload (Signature(ClassType::*func)) -> decltype(func)
 This is a helper function to register overloaded member functions. More...
 
template<typename Enum_Type >
detail::enum_data< Enum_Type > value (const char *name, Enum_Type value)
 The value function should be used to add a mapping from enum name to value during the registration process of reflection information. More...
 

Enumeration Type Documentation

enum rttr::access_levels
strong

The access_levels enum represents the three access modifiers, which can be used in classes to encapsulate members access.

In contrast to the three static type values in the registration class, represents this enum the return value to retrieve the access level at runtime.

See also
method::get_access_level(), property::get_access_level(), constructor::get_access_level()
Enumerator
public_access 

Declares that this member was registered with public access.

protected_access 

Declares that this member was registered with protected access.

private_access 

Declares that this member was registered with private access.

Function Documentation

template<typename... TArgs>
detail::default_args<TArgs...> rttr::default_arguments ( TArgs &&...  args)

The default_arguments function should be used add default arguments, for constructors or a methods during the registration process of reflection information.

Use it in the () operator of the returned bind object.

The given arguments must match the signature from the starting position to the right most argument.

See following example code:

void my_function(int a, bool b, const std::string& text);
{
using namespace rttr;
registration::method("my_function", &my_function)
(
default_arguments(true, std::string("default text"))
);
// however setting default arguments like this, will raise a compile time error
registration::method("my_function2", &my_function)
(
default_arguments(true) // does not work!!!; default value for the last argument is missing...
);
}
detail::metadata rttr::metadata ( variant  key,
variant  value 
)

The metadata function can be used to add additional meta data information during the registration process of reflection information.

Use it in the () operator of the returned bind object.

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

The parameter_names function should be used add human-readable names of the parameters, for constructors or a methods during the registration process of reflection information.

Use it in the () operator of the returned bind object.

The names must be provided as string literals (i.e. const char*) arguments.

See following example code:

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")
);
}
See also
parameter_info
template<typename Target_Type , typename Source_Type >
Target_Type rttr::rttr_cast ( Source_Type  object)

Casts the given object of type Source_Type to an object of type Target_Type.

When the given the given object is an instance of type Target_Type, then this function will cast the pointer to the TargetType; otherwise it will return a nullptr. If object is already a nullptr then it will also return a nullptr.

Remarks
Both class types must contain the macro RTTR_ENABLE in the class declaration. Source_Type and Target_Type must be both pointer types.
Returns
A pointer of type Target_Type
template<typename ClassType , typename ReturnType , typename... Args>
auto rttr::select_const ( ReturnType(ClassType::*)(Args...) const  func) -> decltype(func)

This is a helper function to register overloaded const member functions.

Use it like following:

#include <rttr/registration>
using namespace rttr;
struct Foo
{
void func() {}
void func() const {}
};
{
.method("func", select_non_const(&Foo::func))
.method("func", select_const(&Foo::func));
}
Remarks
The method cannot be used with MSVC x86 compiler, because of the different calling convention for global- and member-functions. As workaround you have to explicitly cast to the member function pointer:
{
registration::class_<Foo>("Foo")
.method("func", static_cast<void(Foo::*)()>(&Foo::func))
.method("func", static_cast<void(Foo::*)()const>(&Foo::func));
}
template<typename ClassType , typename ReturnType , typename... Args>
auto rttr::select_non_const ( ReturnType(ClassType::*)(Args...)  func) -> decltype(func)

This is a helper function to register overloaded const member functions.

Use it like following:

#include <rttr/registration>
using namespace rttr;
struct Foo
{
void func() {}
void func() const {}
};
{
registration::class<Foo>("Foo")
.method("func", select_non_const(&Foo::func))
.method("func", select_const(&Foo::func));
}
Remarks
The method cannot be used with MSVC x86 compiler, because of the different calling convention for global- and member-functions. As workaround you have to explicitly cast to the member function pointer:
{
registration::class_<Foo>("Foo")
.method("func", static_cast<void(Foo::*)()>(&Foo::func))
.method("func", static_cast<void(Foo::*)()const>(&Foo::func));
}
template<typename Signature >
Signature* rttr::select_overload ( Signature *  func)

This is a helper function to register overloaded functions.

Use it like following:

#include <rttr/registration>
#include <cmath>
using namespace rttr;
{
registration::method("pow", select_overload<float(float, float)>(&pow));
}
Remarks
The method cannot be used with MSVC x86 compiler, because of the different calling convention for global- and member-functions. As workaround you have to explicitly cast to the function pointer:
{
registration::method("pow", static_cast<float(*)(float, float)>(&pow));
}
template<typename Signature , typename ClassType >
auto rttr::select_overload ( Signature ClassType::*  func) -> decltype(func)

This is a helper function to register overloaded member functions.

Use it like following:

#include <rttr/registration>
#include <cmath>
using namespace rttr;
struct Foo
{
void func(int) {}
void func(int, int) {}
};
{
.method("func", select_overload<void(int)>(&Foo::func))
.method("func", select_overload<void(int, int)>(&Foo::func));
}
Remarks
The method cannot be used with MSVC x86 compiler, because of the different calling convention for global- and member-functions. As workaround you have to explicitly cast to the member function pointer:
{
registration::class_<Foo>("Foo")
.method("func", static_cast<void(Foo::*)(int)>(&Foo::func))
.method("func", static_cast<void(Foo::*)(int, int)>(&Foo::func));
}
template<typename Enum_Type >
detail::enum_data<Enum_Type> rttr::value ( const char *  name,
Enum_Type  value 
)

The value function should be used to add a mapping from enum name to value during the registration process of reflection information.

Use it in the () operator of the returned bind object.

See also
registration::enumeration