#include "TMemberInspector.h"
#include "TInterpreter.h"
#include "TClassEdit.h"
#include "TClass.h"
#include "TError.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():
fObjectPointerState(kUnset)
{
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::Inspect(TClass *, const char *, const char *, const void *)
{
Fatal("Inspect","This version of Inspect is obsolete");
}
void TMemberInspector::GenericShowMembers(const char *topClassName, const void *obj,
Bool_t isTransient) {
if (isTransient) {
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, isTransient);
} else {
}
}
void TMemberInspector::InspectMember(const TObject& obj, const char* name, Bool_t isTransient)
{
InspectMember<TObject>(obj, name, isTransient);
}
void TMemberInspector::InspectMember(const char* topclassname, const void* pobj,
const char* name, Bool_t isTransient)
{
Ssiz_t len = fParent->GetLength();
fParent->Append(name);
GenericShowMembers(topclassname, pobj, isTransient);
fParent->Remove(len);
}
void TMemberInspector::InspectMember(TClass* cl, const void* pobj, const char* name, Bool_t isTransient)
{
Ssiz_t len = fParent->GetLength();
fParent->Append(name);
cl->CallShowMembers(pobj, *this, isTransient);
fParent->Remove(len);
}