#include "TMemberInspector.h"
#include "TInterpreter.h"
#include "TClassEdit.h"
#include "TClass.h"
class TMemberInspector::TParentBuf {
private:
std::vector<char> fBuf;
Ssiz_t fLen;
public:
TParentBuf(): fBuf(1024), fLen(0) {}
Ssiz_t GetLength() const { return fLen; }
void Append(const char*);
void Remove(Ssiz_t startingAt);
operator const char*() const { return &fBuf[0]; }
};
void TMemberInspector::TParentBuf::Append(const char* add)
{
if (!add || !add[0]) return;
Ssiz_t addlen = strlen(add);
fBuf.reserve(fLen + addlen);
const char* i = add;
while (*i) {
fBuf[fLen++] = *i;
++i;
}
fBuf[fLen] = 0;
}
void TMemberInspector::TParentBuf::Remove(Ssiz_t startingAt)
{
fLen = startingAt;
fBuf[startingAt] = 0;
}
ClassImp(TMemberInspector)
TMemberInspector::TMemberInspector() {
fParent = new TParentBuf();
}
TMemberInspector::~TMemberInspector() {
delete fParent;
}
const char* TMemberInspector::GetParent() const
{
return *fParent;
}
Ssiz_t TMemberInspector::GetParentLen() const
{
return fParent->GetLength();
}
void TMemberInspector::AddToParent(const char* name)
{
fParent->Append(name);
}
void TMemberInspector::RemoveFromParent(Ssiz_t startingAt)
{
fParent->Remove(startingAt);
}
void TMemberInspector::GenericShowMembers(const char *topClassName, void *obj,
Bool_t transientMember) {
if (transientMember) {
if (!TClassEdit::IsSTLCont(topClassName)) {
ClassInfo_t *b = gInterpreter->ClassInfo_Factory(topClassName);
Bool_t isloaded = gInterpreter->ClassInfo_IsLoaded(b);
gInterpreter->ClassInfo_Delete(b);
if (!isloaded) return;
}
}
TClass *top = TClass::GetClass(topClassName);
if (top) {
top->CallShowMembers(obj, *this);
} else {
}
}
void TMemberInspector::InspectMember(TObject& obj, const char* name)
{
InspectMember<TObject>(obj, name);
}
void TMemberInspector::InspectMember(const char* topclassname, void* pobj,
const char* name, Bool_t transient)
{
Ssiz_t len = fParent->GetLength();
fParent->Append(name);
GenericShowMembers(topclassname, pobj, transient);
fParent->Remove(len);
}
void TMemberInspector::InspectMember(TClass* cl, void* pobj, const char* name)
{
Ssiz_t len = fParent->GetLength();
fParent->Append(name);
cl->CallShowMembers(pobj, *this);
fParent->Remove(len);
}