]> git.saurik.com Git - wxWidgets.git/blame - utils/serialize/sercore.cpp
Fixed popup menu processing
[wxWidgets.git] / utils / serialize / sercore.cpp
CommitLineData
9fdd8384
GL
1#ifdef __GNUG__
2#pragma implementation "sercore.h"
3#endif
4#include <wx/objstrm.h>
5#include <wx/datstrm.h>
6#include "sercore.h"
7
8IMPLEMENT_SERIAL_CLASS(wxList,wxObject)
9
10void WXSERIAL(wxList)::StoreObject(wxObjectOutputStream& s)
11{
12 wxList *lst_object = (wxList *)Object();
13 wxNode *node = lst_object->First();
14
15 if (s.FirstStage()) {
16 while (node) {
17 s.AddChild(node->Data());
18 node = node->Next();
19 }
20 return;
21 }
22
23 wxDataOutputStream data_s(s);
24
25 data_s.Write8(lst_object->destroy_data);
26 data_s.Write8(lst_object->key_type);
27 data_s.Write32( lst_object->Number() );
28
29 if (lst_object->key_type == wxKEY_INTEGER) {
30 while (node) {
31 data_s.Write32(node->key.integer);
32 node = node->Next();
33 }
34 } else {
35 while (node) {
36 data_s.WriteString(node->key.string);
37 node = node->Next();
38 }
39 }
40}
41
42void WXSERIAL(wxList)::LoadObject(wxObjectInputStream& s)
43{
44 wxDataInputStream data_s(s);
45 wxList *list = (wxList *)Object();
46 int number, i;
47
48 list->DeleteContents( data_s.Read8() );
49 list->key_type = data_s.Read8();
50 number = data_s.Read32();
51
52 if (list->key_type == wxKEY_INTEGER) {
53 for (i=0;i<number;i++)
54 list->Append( data_s.Read32(), s.GetChild(i) );
55 } else {
56 for (i=0;i<number;i++)
57 list->Append( data_s.ReadString(), s.GetChild(i) );
58 }
59}