Original Post
Hey everyone 
Is it possible to scan a class in code to obtain information about members in that class?
For example, lets pretend I want to make a function that writes all of the data members and member functions of a class to a text file, along with their types, sizes, values, etc.
My calling code would look something like this:
My resulting text file would look something like this:
Is something similar to this possible? My real reason for wanting to do this is to be capable of adding a real game-code structure to a scripting engine more easily. My scripting engine is capable of defining instances of classes, using them to change members, etc, but each class must be defined into the scripting engine by manually defining each structure member.
Thanks for any information
Is it possible to scan a class in code to obtain information about members in that class?
For example, lets pretend I want to make a function that writes all of the data members and member functions of a class to a text file, along with their types, sizes, values, etc.
My calling code would look something like this:
class SomeClass
{
public:
int CanYouSeeMe;
int IBetYouCant;
void MyMethod();
};
template <typename vtype>
void WriteClassInfoToFile(vtype &class_ref); // the parameter might be different
..... in some function somewhere:
SomeClass test;
WriteClassInfoToFile( test );My resulting text file would look something like this:
Class: SomeClass
Size: 8 bytes
Members:
CanYouSeeMe - Type: int
IBetYouCant - Type int
Methods:
1. MyMethod() - return type: voidIs something similar to this possible? My real reason for wanting to do this is to be capable of adding a real game-code structure to a scripting engine more easily. My scripting engine is capable of defining instances of classes, using them to change members, etc, but each class must be defined into the scripting engine by manually defining each structure member.
Thanks for any information