X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1678ad780265f08fc8b84d180c04ae3a9900b1bb..c6cdf16c933251be1670f611ba28e48885610b23:/src/common/object.cpp diff --git a/src/common/object.cpp b/src/common/object.cpp index 272e88a21f..ed1c78b1a7 100644 --- a/src/common/object.cpp +++ b/src/common/object.cpp @@ -221,12 +221,57 @@ wxObject *wxCreateDynamicObject(char *name) #ifdef USE_STORABLE_CLASSES +#include "wx/serbase.h" +#include "wx/dynlib.h" +#include "wx/msgdlg.h" + wxObject* wxCreateStoredObject( wxInputStream &stream ) { 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 /*