Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The value obtained is incorrect. #361

Open
TonyBeen opened this issue Aug 3, 2023 · 0 comments
Open

The value obtained is incorrect. #361

TonyBeen opened this issue Aug 3, 2023 · 0 comments

Comments

@TonyBeen
Copy link

TonyBeen commented Aug 3, 2023

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant