The win32 debugger shows the class name in question in the inspector window that means the information must be available, it's only in question wether the microsoft developers made the function public.
For Debug/Diagnostic/development purpose i wanna write a function to get the instanciated class name of a c++ object as an output and as an input the pointer to the base class.
For example:
const char* GetNameOfInstanciatedClassByVoidPtr(void* pBaseClassOrInstanciatedClass);
class B { public: B(){
assert(StringIsEqual(GetNameOfInstanciatedClassByVoidPtr(this), "C")); } };
class C : B {} c;
So please provide a solution for implementation of function GetNameOfInstanciatedClassByVoidPtr.
So question is: Whats the required lib/header/function ? I guess a API for the win32 Debug info would help?
Writing virtual functions which return strings or type_info is not an acceptable solution in my situation.
As i said before: this is for diagnostic/debug/development purpose only, NOT for production code so please avoid discussions about clean code purposes. I could also collect the information manually but since it's about 260 classes i might be faster this way. ;)
EDIT: As i observed the information is not yet available in the constructor time. But i have a Init method which is always called. In this method the debugger shows the name of the instanciated class so if i put the function GetNameOfInstanciatedClassByVoidPtr into my init method the information can be obtained.
Aucun commentaire:
Enregistrer un commentaire