28 #ifndef __RTTR_TYPE_CONVERTER_H__
29 #define __RTTR_TYPE_CONVERTER_H__
43 type_converter_base(
const type& target_type) : _target_type(target_type) {}
44 virtual variant to_variant(
void* data,
bool& ok)
const = 0;
45 virtual ~type_converter_base() {}
50 template<
typename TargetType>
51 struct type_converter_target : type_converter_base
53 type_converter_target(
const type& target_type) : type_converter_base(target_type) {}
54 virtual ~type_converter_target() {}
55 variant to_variant(
void* data,
bool& ok)
const {
return convert(data, ok); }
56 virtual TargetType convert(
void* data,
bool& ok)
const = 0;
59 template<
typename TargetType,
typename SourceType,
typename F>
60 struct type_converter : type_converter_target<TargetType>
62 type_converter(
const F& acc) : type_converter_target<TargetType>(type::get<TargetType>()), _acc(acc) { }
63 virtual ~type_converter() {}
65 TargetType convert(
void* data,
bool& ok)
const
67 SourceType* obj =
static_cast<SourceType*
>(data);
68 return _acc(*obj, ok);
77 #endif // __RTTR_TYPE_CONVERTER_H__
#define RTTR_LOCAL
Definition: core_prerequisites.h:125