X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b2aef89b7a675805b601e757492c982031f38d21..a3622daa901777a33969d8bc04e2d62dee14d164:/src/common/object.cpp diff --git a/src/common/object.cpp b/src/common/object.cpp index 7085b9bb8b..ed1c78b1a7 100644 --- a/src/common/object.cpp +++ b/src/common/object.cpp @@ -20,7 +20,10 @@ #pragma hdrstop #endif +#ifndef WX_PRECOMP #include "wx/hash.h" +#include "wx/objstrm.h" +#endif #include #include @@ -114,36 +117,6 @@ void wxObject::operator delete[] (void * buf) * Class info: provides run-time class type information. */ -#ifdef USE_STORABLE_CLASSES - -wxClassInfo::wxClassInfo(char *cName, char *baseName1, char *baseName2, int sz, wxObjectConstructorFn fn, - wxStorableConstructorFn stoFn ) -{ - className = cName; - baseClassName1 = baseName1; - baseClassName2 = baseName2; - - objectSize = sz; - objectConstructor = fn; - storableConstructor = stoFn; - - next = first; - first = this; - - baseInfo1 = NULL; - baseInfo2 = NULL; -} - -wxObject* wxClassInfo::CreateObject( istream &stream, char *data ) -{ - if (storableConstructor) - return (wxObject *)(*storableConstructor)( stream, data ); - else - return NULL; -} - -#else - wxClassInfo::wxClassInfo(char *cName, char *baseName1, char *baseName2, int sz, wxObjectConstructorFn constr) { className = cName; @@ -160,8 +133,6 @@ wxClassInfo::wxClassInfo(char *cName, char *baseName1, char *baseName2, int sz, baseInfo2 = NULL; } -#endif - wxObject *wxClassInfo::CreateObject(void) { if (objectConstructor) @@ -250,18 +221,57 @@ wxObject *wxCreateDynamicObject(char *name) #ifdef USE_STORABLE_CLASSES -wxObject* wxCreateStoredObject( char *name, istream &stream, char *data ) +#include "wx/serbase.h" +#include "wx/dynlib.h" +#include "wx/msgdlg.h" + +wxObject* wxCreateStoredObject( wxInputStream &stream ) { - wxClassInfo *info = wxClassInfo::first; - while (info) - { - if (info->className && strcmp(info->className, name) == 0) - return info->CreateObject( stream, data ); - info = info->next; - } - return NULL; + wxObjectInputStream obj_s(stream); + return obj_s.LoadObject(); }; +void wxObject::StoreObject( wxObjectOutputStream& stream ) +{ + wxString obj_name = wxString(GetClassInfo()->GetClassName()) + "_Serialize"; + wxLibrary *lib = wxTheLibraries.LoadLibrary("wxserial"); + WXSERIAL(wxObject) *serial = + (WXSERIAL(wxObject) *)lib->CreateObject( obj_name ); + + if (!serial) { + wxString message; + + message.Printf("Can't find the serialization object (%s) for the object %s", + WXSTRINGCAST obj_name, WXSTRINGCAST GetClassInfo()->GetClassName()); + wxMessageBox(message, "Alert !"); + return; + } + + serial->SetObject(this); + serial->StoreObject(stream); +} + +void wxObject::LoadObject( wxObjectInputStream& stream ) +{ + wxString obj_name = wxString(GetClassInfo()->GetClassName()) + "_Serialize"; + wxLibrary *lib = wxTheLibraries.LoadLibrary("wxserial"); + WXSERIAL(wxObject) *serial = + (WXSERIAL(wxObject) *)lib->CreateObject( obj_name ); + + if (!serial) { + wxString message; + + message.Printf("Can't find the serialization object (%s) for the object %s", + WXSTRINGCAST obj_name, + WXSTRINGCAST GetClassInfo()->GetClassName()); + wxMessageBox(message, "Alert !"); + return; + } + + serial->SetObject(this); + serial->LoadObject(stream); +} + #endif /*