]> git.saurik.com Git - wxWidgets.git/blob - src/common/serbase.cpp
removed wxDialog::SetSize() which just called wxWindow::SetSize()
[wxWidgets.git] / src / common / serbase.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: serbase.cpp
3 // Purpose: wxStream base classes
4 // Author: Robert Roebling
5 // Modified by:
6 // Created: 11/07/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "serbase.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #include "wx/serbase.h"
20 #include "wx/datstrm.h"
21 #include "wx/objstrm.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 // ----------------------------------------------------------------------------
28 // wxObject_Serialize
29 // ----------------------------------------------------------------------------
30
31 #if !USE_SHARED_LIBRARY
32 IMPLEMENT_DYNAMIC_CLASS(wxObject_Serialize,wxObject)
33 IMPLEMENT_SERIAL_CLASS(wxList, wxObject)
34 IMPLEMENT_SERIAL_CLASS(wxHashTable, wxObject)
35 #endif
36
37 void WXSERIAL(wxList)::StoreObject(wxObjectOutputStream& s)
38 {
39 wxList *lst_object = (wxList *)Object();
40 wxNode *node = lst_object->First();
41
42 if (s.FirstStage()) {
43 while (node) {
44 s.AddChild(node->Data());
45 node = node->Next();
46 }
47 return;
48 }
49
50 wxDataOutputStream data_s(s);
51
52 data_s.Write8(lst_object->GetDeleteContents());
53 data_s.Write8(lst_object->GetKeyType());
54 data_s.Write32( lst_object->Number() );
55
56 if (lst_object->GetKeyType() == wxKEY_INTEGER) {
57 while (node) {
58 data_s.Write32(node->GetKeyInteger());
59 node = node->Next();
60 }
61 } else {
62 while (node) {
63 data_s.WriteString(node->GetKeyString());
64 node = node->Next();
65 }
66 }
67 }
68
69 void WXSERIAL(wxList)::LoadObject(wxObjectInputStream& s)
70 {
71 wxDataInputStream data_s(s);
72 wxList *list = (wxList *)Object();
73 int number, i;
74
75 list->DeleteContents( data_s.Read8() );
76 list->SetKeyType( (wxKeyType) data_s.Read8() );
77 number = data_s.Read32();
78
79 if (list->GetKeyType() == wxKEY_INTEGER) {
80 for (i=0;i<number;i++)
81 list->Append( data_s.Read32(), s.GetChild() );
82 } else {
83 for (i=0;i<number;i++)
84 list->Append( data_s.ReadString(), s.GetChild() );
85 }
86 }
87
88 // ----------------------------------------------------------------------------
89
90 void WXSERIAL(wxHashTable)::StoreObject(wxObjectOutputStream& s)
91 {
92 wxHashTable *table = (wxHashTable *)Object();
93 int i;
94
95 if (s.FirstStage()) {
96 for (i=0;i<table->n;i++)
97 s.AddChild(table->hash_table[i]);
98 return;
99 }
100
101 wxDataOutputStream data_s(s);
102
103 data_s.Write8(table->key_type);
104 data_s.Write32(table->n);
105 }
106
107 void WXSERIAL(wxHashTable)::LoadObject(wxObjectInputStream& s)
108 {
109 wxHashTable *table = (wxHashTable *)Object();
110 wxDataInputStream data_s(s);
111 int i, key, n;
112
113 key = data_s.Read8();
114 n = data_s.Read32();
115
116 table->Create(key, n);
117
118 for (i=0;i<n;i++)
119 table->hash_table[i] = (wxList *)s.GetChild();
120 }