Open TonyBeen opened 1 year ago
struct PV_RANGE_INT { int32_t nMin = 0; int32_t nMax = 0; }; RTTR_REGISTRATION { rttr::registration::class_<PV_RANGE_INT>("PV_RANGE_INT") .constructor<>() .property("nMin", &PV_RANGE_INT::nMin) .property("nMax", &PV_RANGE_INT::nMax); } int main(int argc, char *argv[]) { rttr::type type = rttr::type::get_by_name("PV_RANGE_INT"); if (type.is_valid()) { rttr::variant range = type.create(); type.set_property_value("nMin", range, 10); type.set_property_value("nMax", range, 20); rttr::property property_nMin = type.get_property("nMin"); if (property_nMin.is_valid()) { property_nMin.get_value(range).get_value<PV_RANGE_INT>().nMin; } rttr::property property_nMax = type.get_property("nMax"); if (property_nMax.is_valid()) { property_nMax.get_value(range).get_value<PV_RANGE_INT>().nMax; } int32_t min_value = range.get_value<PV_RANGE_INT>().nMin; int32_t max_value = range.get_value<PV_RANGE_INT>().nMax; std::cout << "nMin: " << min_value << std::endl; std::cout << "nMax: " << max_value << std::endl; } return 0; }