Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

RTTI question

Name: Anonymous 2006-01-19 14:12

I've got this problem and I'm not sure how to solve it. I have:

class A {
    public:
        A() {};
        ~A{} {};

        void saveToXML(FILE *out);
        void loadFromXML(xmlNodePtr node);
};

Derived from A, I have several classes that do not reimplement savToXML() because all the member data is the same.  The only reason I have derived classes in the first place is to reimplement various member functions.

Obivously, when I'm ready to read the data back in from a file I do something similar to the following:

A *in = new A();
in->loadFromXML(node);

Of course, this results in me losing my polymorphism after the data structure has been saved and read back in.

So the question is this.  Is there any way to identify exactly what class saved the data in the first place and downcast a pointer to that type when reading the data back in without having to overload loadFromXML() in every derived class?  We're talking about hundreds of derived classes here, so I really don't want to do that.

Thanks!

Name: Anonymous 2006-01-20 0:40

I have a question. Since this thread seems to be solved.
How does one manage to get typeid().name()
return the EXACT class name defined by the programmer?

Coz I'm running into trouble where typeid().name()
gives me an unnecassay looooooooong name
ubtil the OS had to even reject it
when I try to use it to identify my window class.

Btw, I'm not the original author.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List