acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
___serialization_draft001.h
1// 2020-01-11 - Curitiba, ca2
2
3// "pluggable" non-member non-virtual global serializers
4
5
6::i32 main2()
7{
8
9 ::file pfile = file()->get_file("C:\\window.window");
10
11 in_addr addr;
12
13 ::stream stream(pfile);
14
15 stream >> addr;
16
17 window::in_addr();
18
19}
20
21
22stream & operator __exchange (stream & stream, in_addr & o)
23{
24
25 string str = to_string(o);
26
27 stream.exchange(atom, s);
28
29}
30
31
32void window::exchange(stream & stream)
33{
34 e.exchange("a", m_a);
35 e.exchange("c", m_b);
36 e.exchange("b", m_c);
37 e.exchange("b", m_inaddr);
38
39}
40
41void __exchange(stream & s, const ::atom & atom,)
42
43
44::i32 main()
45{
46
47 ::file pfile = file()->get_file("C:\\window.window");
48
49 auto pinteraction = allocateø window();
50
51 ::stream stream(pfile);
52
53 stream >> *pinteraction;
54
55 pinteraction ->show();
56
57 pui2 = new_frame_window();
58
59 ::stream stream(pfile);
60
61 stream >> *pinteraction;
62
63
65
66
67 id_stream idstream(set);
68
69 idstream >> * pinteraction;
70
71}
72
73
74void __exchange(stream & stream, ::i8 & i) { __exchange_blt(stream, i); }
75void __exchange(stream & stream, string & str) { __exchange_string(stream, str); }
76void __exchange(stream & stream, in_addr & addr) { __exchange_stringable(stream, addr); }
77
78void __exchange(payload_stream & stream, ::i8 & i) { __exchange_blt(stream, i); }
79void __exchange(payload_stream & stream, string & str) { __exchange_string(stream, str); }
80void __exchange(payload_stream & stream, in_addr & addr) { __exchange_stringable(stream, addr); }
81
82class window
83{
84public:
85
86 ::i8 m_iVisible;
87 string m_strTitle;
88 in_addr m_addr;
89 ::matter m_pobject;
90
91 void exchange(stream & s);
92
93};
94virtual void window::exchange(exchanger & e)
95{
96 e.exchange("a", m_a);
97 e.exchange("c", m_b);
98 e.exchange("b", m_c);
99
100}
101
102
103
104class exchanger
105{
106
107 stream * m_pstream;
108
109template
110exchange(atom, value) read/write value
111{
112 if(is_storing)
113 m_pstream->write(atom value)
114 else
115 m_pstream->read(atom, value)
116
117}
118template
119exchange(value) read/write value
120{
121 if(is_storing)
122 m_pstream->write(value)
123 else
124 m_pstream->read(value)
125
126}
127
128
129stream
130{
131
132
133read(atom, ::i8) throw not_implemented;
134read(atom, ::i16) throw not_implemented;
135read(atom, ::i32) throw not_implemented;
136read(atom, ::i64) throw not_implemented;
137read(atom, ::u8) throw not_implemented;
138read(atom, ::u16) throw not_implemented;
139read(atom, ::u32) throw not_implemented;
140read(atom, ::u64) throw not_implemented;
141
142read(::i8) throw not_implemented;
143read(::i16) throw not_implemented;
144read(::i32) throw not_implemented;
145read(::i64) throw not_implemented;
146read(::u8) throw not_implemented;
147read(::u16) throw not_implemented;
148read(::u32) throw not_implemented;
149read(::u64) throw not_implemented;
150
151write(atom, ::i8) throw not_implemented;
152write(atom, ::i16) throw not_implemented;
153write(atom, ::i32) throw not_implemented;
154write(atom, ::i64) throw not_implemented;
155write(atom, ::u8) throw not_implemented;
156write(atom, ::u16) throw not_implemented;
157write(atom, ::u32) throw not_implemented;
158write(atom, ::u64) throw not_implemented;
159
160write(::i8) throw not_implemented;
161write(::i16) throw not_implemented;
162write(::i32) throw not_implemented;
163write(::i64) throw not_implemented;
164write(::u8) throw not_implemented;
165write(::u16) throw not_implemented;
166write(::u32) throw not_implemented;
167write(::u64) throw not_implemented;
168
169
170}
171
172
173binary_stream
174{
175
176
177read(atom, ::i8) read(::i8)
178read(atom, ::i16) read(::i16)
179read(atom, ::i32) read(::i32)
180read(atom, ::i64) read(::i64)
181read(atom, ::u8) read(::u8)
182read(atom, ::u16) read(::u16)
183read(atom, ::u32) read(::u32)
184read(atom, ::u64) read(::u64)
185
186read(::i8) m_pfile->read(::i8)
187read(::i16) m_pfile->read(::i16)
188read(::i32) m_pfile->read(::i32)
189read(::i64) m_pfile->read(::i64)
190read(::u8) m_pfile->read(::u8)
191read(::u16) m_pfile->read(::u16)
192read(::u32) m_pfile->read(::u32)
193read(::u64) m_pfile->read(::u64)
194
195write(atom, ::i8) write(::i8)
196write(atom, ::i16) write(::i16)
197write(atom, ::i32) write(::i32)
198write(atom, ::i64) write(::i64)
199write(atom, ::u8) write(::u8)
200write(atom, ::u16) write(::u16)
201write(atom, ::u32) write(::u32)
202write(atom, ::u64) write(::u64)
203
204write(::i8) m_pfile->write(::i8)
205write(::i16) m_pfile->write(::i16)
206write(::i32) m_pfile->write(::i32)
207write(::i64) m_pfile->write(::i64)
208write(::u8) m_pfile->write(::u8)
209write(::u16) m_pfile->write(::u16)
210write(::u32) m_pfile->write(::u32)
211write(::u64) m_pfile->write(::u64)
212
213
214}
215
216text_stream
217{
218
219
220write(atom, ::i8) write(::i8)
221write(atom, ::i16) write(::i16)
222write(atom, ::i32) write(::i32)
223write(atom, ::i64) write(::i64)
224write(atom, ::u8) write(::u8)
225write(atom, ::u16) write(::u16)
226write(atom, ::u32) write(::u32)
227write(atom, ::u64) write(::u64)
228
229write(::i8) m_pfile->write(::i8)
230write(::i16) m_pfile->write(::i16)
231write(::i32) m_pfile->write(::i32)
232write(::i64) m_pfile->write(::i64)
233write(::u8) m_pfile->write(::u8)
234write(::u16) m_pfile->write(::u16)
235write(::u32) m_pfile->write(::u32)
236write(::u64) m_pfile->write(::u64)
237
238
239}
240
241
242template < typename CONTAINER >
243id_stream :
244 stream
245{
246
247read(atom, ::i8)::i8 = m_ppayload->operator[](atom);
248read(atom, ::i16) ::i16= m_ppayload->operator[](atom);
249read(atom, ::i32) ::i32= m_ppayload->operator[](atom);
250read(atom, ::i64) ::i64= m_ppayload->operator[](atom);
251read(atom, ::u8) ::u8= m_ppayload->operator[](atom);
252read(atom, ::u16) ::u16= m_ppayload->operator[](atom);
253read(atom, ::u32) ::u32= m_ppayload->operator[](atom);
254read(atom, ::u64) ::u64= m_ppayload->operator[](atom);
255
256read(::i8) ::i8 = *m_ppayload
257read(::i16) ::i16 = *m_ppayload
258read(::i32) ::i32 = *m_ppayload
259read(::i64) ::i64 = *m_ppayload
260read(::u8) uch = *m_ppayload
261read(::u16) ::u16 = *m_ppayload
262read(::u32) ::u32 = *m_ppayload
263read(::u64) ::u64 = *m_ppayload
264
265write(atom, ::i8) write(::i8)
266write(atom, ::i16) write(::i16)
267write(atom, ::i32) write(::i32)
268write(atom, ::i64) write(::i64)
269write(atom, ::u8) write(::u8)
270write(atom, ::u16) write(::u16)
271write(atom, ::u32) write(::u32)
272write(atom, ::u64) write(::u64)
273
274write(::i8) m_pfile->write(::i8)
275write(::i16) m_pfile->write(::i16)
276write(::i32) m_pfile->write(::i32)
277write(::i64) m_pfile->write(::i64)
278write(::u8) m_pfile->write(::u8)
279write(::u16) m_pfile->write(::u16)
280write(::u32) m_pfile->write(::u32)
281write(::u64) m_pfile->write(::u64)
282
283}
284
285
286
287
288stream & operator >> (stream & stream, matter & o)
289{
290
291 exchange e(stream);
292
293 e.defer_set_loading();
294
295 e.exchange(s);
296
297}
298
299stream & operator >> (stream & s, matter & o)
300{
301
302 o.exchange(stream);
303
304}
305
306
307window new_frame_window()
308{
309 return allocateø frame_window();
310}
Definition atom.h:237
Definition aaa_acme.h:15
Definition ___serialization_draft.h:93
Definition property_set.h:512
Definition ___serialization_draft.h:42
Definition ___serialization_draft.h:150
Definition filesystem.h:16
Definition sockets.h:32