Revert "Added experimental handshaking to IpModem"
[barry.git] / src / s11n-boost.h
blob4047bc8b37739899e0a2ee5af158d2ce6fb71946
1 ///
2 /// \file s11n-boost.h
3 /// Non-intrusive versions of serialization functions for the
4 /// record classes. These template functions make it possible
5 /// to use the record classes with the Boost::Serialization
6 /// library.
7 ///
9 /*
10 Copyright (C) 2005-2009, Net Direct Inc. (http://www.netdirect.ca/)
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU General Public License in the COPYING file at the
22 root directory of this project for more details.
25 #ifndef __BARRY_S11N_BOOST_H__
26 #define __BARRY_S11N_BOOST_H__
28 #include "record.h"
29 #include <boost/serialization/vector.hpp>
31 ///////////////////////////////////////////////////////////////////////////////
32 // special versions
34 // BARRY_BASE_S11N_VERSION - the base version where all record data is
35 // stored so it can be fully retrieved and
36 // uploaded to the handheld device later.
37 // BARRY_POD_MAP_VERSION - if these templates are called with a version
38 // equal or greater than this, only mappable,
39 // POD data is included in the serialization
41 #define BARRY_BASE_S11N_VERSION 0
42 #define BARRY_POD_MAP_VERSION 1000
44 // namespace boost::serialization, for the non-intrusive version
45 namespace boost {
46 namespace serialization {
48 template <class ArchiveT>
49 void serialize(ArchiveT &ar, Barry::UnknownField &uf, const unsigned int ver)
51 ar & make_nvp("type", uf.type);
52 ar & make_nvp("data", uf.data.raw_data);
55 template <class ArchiveT>
56 void serialize(ArchiveT &ar, Barry::Contact::GroupLink &g, const unsigned int ver)
58 ar & make_nvp("Link", g.Link);
59 ar & make_nvp("Unknown", g.Unknown);
62 template <class ArchiveT>
63 void serialize(ArchiveT &ar, Barry::Contact &c, const unsigned int ver)
65 ar & make_nvp("RecType", c.RecType);
66 ar & make_nvp("RecordId", c.RecordId);
68 ar & make_nvp("EmailAddresses", c.EmailAddresses);
69 ar & make_nvp("Phone", c.Phone);
70 ar & make_nvp("Fax", c.Fax);
71 ar & make_nvp("WorkPhone", c.WorkPhone);
72 ar & make_nvp("HomePhone", c.HomePhone);
73 ar & make_nvp("MobilePhone", c.MobilePhone);
74 ar & make_nvp("Pager", c.Pager);
75 ar & make_nvp("PIN", c.PIN);
76 ar & make_nvp("Radio", c.Radio);
77 ar & make_nvp("WorkPhone2", c.WorkPhone2);
78 ar & make_nvp("HomePhone2", c.HomePhone2);
79 ar & make_nvp("OtherPhone", c.OtherPhone);
80 ar & make_nvp("FirstName", c.FirstName);
81 ar & make_nvp("LastName", c.LastName);
82 ar & make_nvp("Company", c.Company);
83 ar & make_nvp("DefaultCommunicationsMethod", c.DefaultCommunicationsMethod);
84 ar & make_nvp("Address1", c.WorkAddress.Address1);
85 ar & make_nvp("Address2", c.WorkAddress.Address2);
86 ar & make_nvp("Address3", c.WorkAddress.Address3);
87 ar & make_nvp("City", c.WorkAddress.City);
88 ar & make_nvp("Province", c.WorkAddress.Province);
89 ar & make_nvp("PostalCode", c.WorkAddress.PostalCode);
90 ar & make_nvp("Country", c.WorkAddress.Country);
91 ar & make_nvp("JobTitle", c.JobTitle);
92 ar & make_nvp("PublicKey", c.PublicKey);
93 ar & make_nvp("URL", c.URL);
94 ar & make_nvp("Prefix", c.Prefix);
95 ar & make_nvp("Categories", c.Categories);
96 ar & make_nvp("HomeAddress1", c.HomeAddress.Address1);
97 ar & make_nvp("HomeAddress2", c.HomeAddress.Address2);
98 ar & make_nvp("HomeAddress3", c.HomeAddress.Address3);
99 ar & make_nvp("Notes", c.Notes);
100 ar & make_nvp("UserDefined1", c.UserDefined1);
101 ar & make_nvp("UserDefined2", c.UserDefined2);
102 ar & make_nvp("UserDefined3", c.UserDefined3);
103 ar & make_nvp("UserDefined4", c.UserDefined4);
104 ar & make_nvp("HomeCity", c.HomeAddress.City);
105 ar & make_nvp("HomeProvince", c.HomeAddress.Province);
106 ar & make_nvp("HomePostalCode", c.HomeAddress.PostalCode);
107 ar & make_nvp("HomeCountry", c.HomeAddress.Country);
108 ar & make_nvp("Image", c.Image);
110 if( ver < BARRY_POD_MAP_VERSION ) {
111 ar & make_nvp("GroupLinks", c.GroupLinks);
112 ar & make_nvp("Unknowns", c.Unknowns);
116 template <class ArchiveT>
117 void serialize(ArchiveT &ar, Barry::EmailAddress &a, const unsigned int ver)
119 ar & make_nvp("Name", a.Name);
120 ar & make_nvp("Email", a.Email);
123 template <class ArchiveT>
124 void serialize(ArchiveT &ar, Barry::Message &m, const unsigned int ver)
126 ar & make_nvp("From", m.From);
127 ar & make_nvp("To", m.To);
128 ar & make_nvp("Cc", m.Cc);
129 ar & make_nvp("Sender", m.Sender);
130 ar & make_nvp("ReplyTo", m.ReplyTo);
131 ar & make_nvp("Subject", m.Subject);
132 ar & make_nvp("Body", m.Body);
133 ar & make_nvp("Attachment", m.Attachment);
134 ar & make_nvp("MessageRecordId", m.MessageRecordId);
135 ar & make_nvp("MessageReplyTo", m.MessageReplyTo);
136 ar & make_nvp("MessageDateSent", m.MessageDateSent);
137 ar & make_nvp("MessageDateReceived", m.MessageDateReceived);
139 ar & make_nvp("MessageTruncated", m.MessageTruncated);
140 ar & make_nvp("MessageRead", m.MessageRead);
141 ar & make_nvp("MessageReply", m.MessageReply);
142 ar & make_nvp("MessageSaved", m.MessageSaved);
143 ar & make_nvp("MessageSavedDeleted", m.MessageSavedDeleted);
145 ar & make_nvp("MessagePriority", m.MessagePriority);
146 ar & make_nvp("MessageSensitivity", m.MessageSensitivity);
148 if( ver < BARRY_POD_MAP_VERSION ) {
149 ar & make_nvp("Unknowns", m.Unknowns);
153 template <class ArchiveT>
154 void serialize(ArchiveT &ar, Barry::Calendar &c, const unsigned int ver)
156 ar & make_nvp("RecType", c.RecType);
157 ar & make_nvp("RecordId", c.RecordId);
159 ar & make_nvp("AllDayEvent", c.AllDayEvent);
161 ar & make_nvp("Subject", c.Subject);
162 ar & make_nvp("Notes", c.Notes);
163 ar & make_nvp("Location", c.Location);
165 ar & make_nvp("NotificationTime", c.NotificationTime);
166 ar & make_nvp("StartTime", c.StartTime);
167 ar & make_nvp("EndTime", c.EndTime);
169 ar & make_nvp("FreeBusyFlag", c.FreeBusyFlag);
170 ar & make_nvp("ClassFlag", c.ClassFlag);
172 ar & make_nvp("Recurring", c.Recurring);
173 ar & make_nvp("RecurringType", c.RecurringType);
174 ar & make_nvp("Interval", c.Interval);
175 ar & make_nvp("RecurringEndTime", c.RecurringEndTime);
176 ar & make_nvp("Perpetual", c.Perpetual);
177 ar & make_nvp("TimeZoneCode", c.TimeZoneCode);
178 ar & make_nvp("TimeZoneValid", c.TimeZoneValid);
180 ar & make_nvp("DayOfWeek", c.DayOfWeek);
181 ar & make_nvp("WeekOfMonth", c.WeekOfMonth);
182 ar & make_nvp("DayOfMonth", c.DayOfMonth);
183 ar & make_nvp("MonthOfYear", c.MonthOfYear);
184 ar & make_nvp("WeekDays", c.WeekDays);
186 if( ver < BARRY_POD_MAP_VERSION ) {
187 ar & make_nvp("Unknowns", c.Unknowns);
191 template <class ArchiveT>
192 void serialize(ArchiveT &ar, Barry::ServiceBookConfig &c, const unsigned int ver)
194 ar & make_nvp("Format", c.Format);
196 if( ver < BARRY_POD_MAP_VERSION ) {
197 ar & make_nvp("Unknowns", c.Unknowns);
201 template <class ArchiveT>
202 void serialize(ArchiveT &ar, Barry::ServiceBook &c, const unsigned int ver)
204 ar & make_nvp("RecType", c.RecType);
205 ar & make_nvp("RecordId", c.RecordId);
207 ar & make_nvp("Name", c.Name);
208 ar & make_nvp("HiddenName", c.HiddenName);
209 ar & make_nvp("Description", c.Description);
210 ar & make_nvp("DSID", c.DSID);
211 ar & make_nvp("BesDomain", c.BesDomain);
212 ar & make_nvp("UniqueId", c.UniqueId);
213 ar & make_nvp("ContentId", c.ContentId);
214 ar & make_nvp("Config", c.Config);
216 if( ver < BARRY_POD_MAP_VERSION ) {
217 ar & make_nvp("Unknowns", c.Unknowns);
221 template <class ArchiveT>
222 void serialize(ArchiveT &ar, Barry::Memo &m, const unsigned int ver)
224 ar & make_nvp("RecType", m.RecType);
225 ar & make_nvp("RecordId", m.RecordId);
227 ar & make_nvp("MemoType", m.MemoType);
228 ar & make_nvp("Title", m.Title);
229 ar & make_nvp("Body", m.Body);
230 ar & make_nvp("Category", m.Category);
232 if( ver < BARRY_POD_MAP_VERSION ) {
233 ar & make_nvp( "Unknowns", m.Unknowns);
237 template <class ArchiveT>
238 void serialize(ArchiveT &ar, Barry::Task &t, const unsigned int ver)
240 ar & make_nvp("RecType", t.RecType);
241 ar & make_nvp("RecordId", t.RecordId);
243 ar & make_nvp("TaskType", t.TaskType);
244 ar & make_nvp("Summary", t.Summary);
245 ar & make_nvp("Notes", t.Notes);
246 ar & make_nvp("Categories", t.Categories);
247 ar & make_nvp("UID", t.UID);
249 ar & make_nvp("StartTime", t.StartTime);
250 ar & make_nvp("DueTime", t.DueTime);
251 ar & make_nvp("AlarmTime", t.AlarmTime);
253 ar & make_nvp("TimeZoneCode", t.TimeZoneCode);
255 ar & make_nvp("AlarmType", t.AlarmType);
256 ar & make_nvp("Interval", t.Interval);
257 ar & make_nvp("RecurringType", t.RecurringType);
258 ar & make_nvp("RecurringEndTime", t.RecurringEndTime);
259 ar & make_nvp("DayOfWeek", t.DayOfWeek);
260 ar & make_nvp("WeekOfMonth", t.WeekOfMonth);
261 ar & make_nvp("DayOfMonth", t.DayOfMonth);
262 ar & make_nvp("MonthOfYear", t.MonthOfYear);
263 ar & make_nvp("WeekDays", t.WeekDays);
265 ar & make_nvp("ClassType", t.ClassType);
266 ar & make_nvp("PriorityFlag", t.PriorityFlag);
267 ar & make_nvp("StatusFlag", t.StatusFlag);
268 ar & make_nvp("Recurring", t.Recurring);
269 ar & make_nvp("Perpetual", t.Perpetual);
270 ar & make_nvp("DueDateFlag", t.DueDateFlag);
272 if( ver < BARRY_POD_MAP_VERSION ) {
273 ar & make_nvp( "Unknowns", t.Unknowns);
277 template<class ArchiveT>
278 void serialize(ArchiveT &ar, Barry::PINMessage &p, const unsigned int ver)
280 ar & make_nvp("RecType", p.RecType);
281 ar & make_nvp("RecordId", p.RecordId);
283 ar & make_nvp("From", p.From);
284 ar & make_nvp("To", p.To);
285 ar & make_nvp("Cc", p.Cc);
286 ar & make_nvp("Bcc", p.Bcc);
287 ar & make_nvp("Subject", p.Subject);
288 ar & make_nvp("Body", p.Body);
289 ar & make_nvp("MessageRecordId", p.MessageRecordId);
290 ar & make_nvp("MessageReplyTo", p.MessageReplyTo);
291 ar & make_nvp("MessageDateSent", p.MessageDateSent);
292 ar & make_nvp("MessageDateReceived", p.MessageDateReceived);
294 ar & make_nvp("MessageTruncated", p.MessageTruncated);
295 ar & make_nvp("MessageRead", p.MessageRead);
296 ar & make_nvp("MessageReply", p.MessageReply);
297 ar & make_nvp("MessageSaved", p.MessageSaved);
298 ar & make_nvp("MessageSavedDeleted", p.MessageSavedDeleted);
300 ar & make_nvp("MessagePriority", p.MessagePriority);
301 ar & make_nvp("MessageSensitivity", p.MessageSensitivity);
303 if(ver < BARRY_POD_MAP_VERSION) {
304 ar & make_nvp("Unknowns", p.Unknowns);
308 template <class ArchiveT>
309 void serialize(ArchiveT &ar, Barry::SavedMessage &m, const unsigned int ver)
311 ar & make_nvp("RecType", m.RecType);
312 ar & make_nvp("RecordId", m.RecordId);
314 ar & make_nvp("From", m.From);
315 ar & make_nvp("To", m.To);
316 ar & make_nvp("Cc", m.Cc);
317 ar & make_nvp("Bcc", m.Bcc);
318 ar & make_nvp("Sender", m.Sender);
319 ar & make_nvp("ReplyTo", m.ReplyTo);
320 ar & make_nvp("Subject", m.Subject);
321 ar & make_nvp("Body", m.Body);
322 ar & make_nvp("Attachment", m.Attachment);
323 ar & make_nvp("MessageRecordId", m.MessageRecordId);
324 ar & make_nvp("MessageReplyTo", m.MessageReplyTo);
325 ar & make_nvp("MessageDateSent", m.MessageDateSent);
326 ar & make_nvp("MessageDateReceived", m.MessageDateReceived);
328 ar & make_nvp("MessageTruncated", m.MessageTruncated);
329 ar & make_nvp("MessageRead", m.MessageRead);
330 ar & make_nvp("MessageReply", m.MessageReply);
331 ar & make_nvp("MessageSaved", m.MessageSaved);
332 ar & make_nvp("MessageSavedDeleted", m.MessageSavedDeleted);
334 ar & make_nvp("MessagePriority", m.MessagePriority);
335 ar & make_nvp("MessageSensitivity", m.MessageSensitivity);
337 if( ver < BARRY_POD_MAP_VERSION ) {
338 ar & make_nvp("Unknowns", m.Unknowns);
342 template <class ArchiveT>
343 void serialize(ArchiveT &ar, Barry::Folder &f, const unsigned int ver)
345 ar & make_nvp("RecType", f.RecType);
346 ar & make_nvp("RecordId", f.RecordId);
348 ar & make_nvp("FolderName", f.FolderName);
349 ar & make_nvp("FolderNumber", f.FolderNumber);
350 ar & make_nvp("FolderLevel", f.FolderLevel);
351 ar & make_nvp("FolderType", f.FolderType);
353 if( ver < BARRY_POD_MAP_VERSION ) {
354 ar & make_nvp( "Unknowns", f.Unknowns);
358 template <class ArchiveT>
359 void serialize(ArchiveT &ar, Barry::Timezone &t, const unsigned int ver)
361 ar & make_nvp("RecType", t.RecType);
362 ar & make_nvp("RecordId", t.RecordId);
364 ar & make_nvp("TZType", t.TZType);
365 ar & make_nvp("DSTOffset", t.DSTOffset);
366 ar & make_nvp("Index", t.Index);
367 ar & make_nvp("Offset", t.Offset);
368 ar & make_nvp("OffsetFraction", t.OffsetFraction);
369 ar & make_nvp("StartMonth", t.StartMonth);
370 ar & make_nvp("EndMonth", t.EndMonth);
371 ar & make_nvp("Left", t.Left);
372 ar & make_nvp("UseDST", t.UseDST);
374 ar & make_nvp("TimeZoneName", t.TimeZoneName);
376 if( ver < BARRY_POD_MAP_VERSION ) {
377 ar & make_nvp("Unknowns", t.Unknowns);
381 }} // namespace boost::serialization
383 #endif