I have a C-header file with 100s of data structs. I want to make a superclass that each data struct inherits from. How to do that? Should I parse the header file? Reflection?
Because each C data struct is a public class, I could just make a superclass and… then what? I should not go in manually and explicitly make every struct inherit from the superclass?
If you have a bunch of structs:
The obvious answer is to make clever use of search and replace to make them inherit from the new base class. It wouldn’t be able to access the members of the structs, but you could store pointers to them all in containers
If making the base class thing is too hard, you might try adding functions via a wrapper class instead. You won’t be able to store pointers to these in a container, but they can access members, as long as the structs have similar members.
Or, if you’re just adding methods, make them separate functions: