I have a class for which I generated a cint dictionary. I would like to access its public data members from their names, i.e, not using “class_inst.member” but something like “get(class_inst, member_name)”.
I read a solution in the header of the class TDataMember, although this rather seems to be designed for private data members, and implies to write a “getter” method for each of them.
Is it possible to retrieve the value of the public members using their names without having to write a “getter”? Perhaps via a call to the interpreter, but I wasn’t successful trying in this way.
It depends a bit of the tradeoff development time vs resulting performance of the code that you need.
For example the following works fine:Long_t myvalue = gROOT->ProcessLineFast(TString::Format("((MyClass*)%p)->%s", class_inst,member_name));
Thank you for you answer. What you propose is working from my side.
Though, there is still the case where “myvalue” is not an integer. I thought to do the following: