I'm trying to do a rather "simple" travels through nested structs, defined as follows:
struct State{
float time = 0.0;
int sequence = 0;
int version = 1;
Player player = Player();
State(){};
};
struct Player{
int level = 0;
Player(){};
};
I am able to do this at "type level" but I would also like to set values along the way.
How can I achieve this?
So far, I've been able to set up the following, which successfully traverse as I want, however, I also want to access properties of the objects along the way and set/get values.
std::vector<std::string> types = {};
std::list<rttr::type> queue = {rttr::type::get(state)};
while(!queue.empty()){
auto& cls = queue.front();
queue.pop_front();
for (auto& prop : cls.get_properties()){
if(prop.get_type().is_class()){
queue.push_back(rttr::type::get(prop));
// Here I find that the type is a class and I then wish to visit this and set values
}else{
types.emplace_back(prop.get_type().get_name());
// Here I would like to set values. First check its type, then set values accordingly.
}
}
}
Hi,
I'm trying to do a rather "simple" travels through nested structs, defined as follows:
whereas I've defined the following registration
Now, I would like to traverse from State and visit all properties along the way:
I am able to do this at "type level" but I would also like to set values along the way. How can I achieve this?
So far, I've been able to set up the following, which successfully traverse as I want, however, I also want to access properties of the objects along the way and set/get values.