]>
git.saurik.com Git - wxWidgets.git/blob - utils/serialize/sercore.cpp
8c83acbe021e62db267e870ef00752536151ae81
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Serialization: core classes
4 // Author: Guilhem Lavaux
8 // Copyright: (c) 1998 Guilhem Lavaux
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "sercore.h"
15 #include <wx/objstrm.h>
16 #include <wx/datstrm.h>
19 IMPLEMENT_SERIAL_CLASS(wxList
,wxObject
)
21 void WXSERIAL(wxList
)::StoreObject(wxObjectOutputStream
& s
)
23 wxList
*lst_object
= (wxList
*)Object();
24 wxNode
*node
= lst_object
->First();
28 s
.AddChild(node
->Data());
34 wxDataOutputStream
data_s(s
);
36 data_s
.Write8(lst_object
->destroy_data
);
37 data_s
.Write8(lst_object
->key_type
);
38 data_s
.Write32( lst_object
->Number() );
40 if (lst_object
->key_type
== wxKEY_INTEGER
) {
42 data_s
.Write32(node
->key
.integer
);
47 data_s
.WriteString(node
->key
.string
);
53 void WXSERIAL(wxList
)::LoadObject(wxObjectInputStream
& s
)
55 wxDataInputStream
data_s(s
);
56 wxList
*list
= (wxList
*)Object();
59 list
->DeleteContents( data_s
.Read8() );
60 list
->key_type
= data_s
.Read8();
61 number
= data_s
.Read32();
63 if (list
->key_type
== wxKEY_INTEGER
) {
64 for (i
=0;i
<number
;i
++)
65 list
->Append( data_s
.Read32(), s
.GetChild(i
) );
67 for (i
=0;i
<number
;i
++)
68 list
->Append( data_s
.ReadString(), s
.GetChild(i
) );