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
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__
29 #include <boost/serialization/vector.hpp>
31 ///////////////////////////////////////////////////////////////////////////////
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
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::CategoryList
&cl
, const unsigned int ver
)
65 std::vector
<std::string
> &sl
= cl
;
66 ar
& make_nvp("CategoryList", sl
);
69 template <class ArchiveT
>
70 void serialize(ArchiveT
&ar
, Barry::Contact
&c
, const unsigned int ver
)
72 ar
& make_nvp("RecType", c
.RecType
);
73 ar
& make_nvp("RecordId", c
.RecordId
);
75 ar
& make_nvp("EmailAddresses", c
.EmailAddresses
);
76 ar
& make_nvp("Phone", c
.Phone
);
77 ar
& make_nvp("Fax", c
.Fax
);
78 ar
& make_nvp("WorkPhone", c
.WorkPhone
);
79 ar
& make_nvp("HomePhone", c
.HomePhone
);
80 ar
& make_nvp("MobilePhone", c
.MobilePhone
);
81 ar
& make_nvp("Pager", c
.Pager
);
82 ar
& make_nvp("PIN", c
.PIN
);
83 ar
& make_nvp("Radio", c
.Radio
);
84 ar
& make_nvp("WorkPhone2", c
.WorkPhone2
);
85 ar
& make_nvp("HomePhone2", c
.HomePhone2
);
86 ar
& make_nvp("OtherPhone", c
.OtherPhone
);
87 ar
& make_nvp("FirstName", c
.FirstName
);
88 ar
& make_nvp("LastName", c
.LastName
);
89 ar
& make_nvp("Company", c
.Company
);
90 ar
& make_nvp("DefaultCommunicationsMethod", c
.DefaultCommunicationsMethod
);
91 ar
& make_nvp("Address1", c
.WorkAddress
.Address1
);
92 ar
& make_nvp("Address2", c
.WorkAddress
.Address2
);
93 ar
& make_nvp("Address3", c
.WorkAddress
.Address3
);
94 ar
& make_nvp("City", c
.WorkAddress
.City
);
95 ar
& make_nvp("Province", c
.WorkAddress
.Province
);
96 ar
& make_nvp("PostalCode", c
.WorkAddress
.PostalCode
);
97 ar
& make_nvp("Country", c
.WorkAddress
.Country
);
98 ar
& make_nvp("JobTitle", c
.JobTitle
);
99 ar
& make_nvp("PublicKey", c
.PublicKey
);
100 ar
& make_nvp("URL", c
.URL
);
101 ar
& make_nvp("Prefix", c
.Prefix
);
102 ar
& make_nvp("Categories", c
.Categories
);
103 ar
& make_nvp("HomeAddress1", c
.HomeAddress
.Address1
);
104 ar
& make_nvp("HomeAddress2", c
.HomeAddress
.Address2
);
105 ar
& make_nvp("HomeAddress3", c
.HomeAddress
.Address3
);
106 ar
& make_nvp("Notes", c
.Notes
);
107 ar
& make_nvp("UserDefined1", c
.UserDefined1
);
108 ar
& make_nvp("UserDefined2", c
.UserDefined2
);
109 ar
& make_nvp("UserDefined3", c
.UserDefined3
);
110 ar
& make_nvp("UserDefined4", c
.UserDefined4
);
111 ar
& make_nvp("HomeCity", c
.HomeAddress
.City
);
112 ar
& make_nvp("HomeProvince", c
.HomeAddress
.Province
);
113 ar
& make_nvp("HomePostalCode", c
.HomeAddress
.PostalCode
);
114 ar
& make_nvp("HomeCountry", c
.HomeAddress
.Country
);
115 ar
& make_nvp("Image", c
.Image
);
117 if( ver
< BARRY_POD_MAP_VERSION
) {
118 ar
& make_nvp("GroupLinks", c
.GroupLinks
);
119 ar
& make_nvp("Unknowns", c
.Unknowns
);
123 template <class ArchiveT
>
124 void serialize(ArchiveT
&ar
, Barry::EmailAddress
&a
, const unsigned int ver
)
126 ar
& make_nvp("Name", a
.Name
);
127 ar
& make_nvp("Email", a
.Email
);
130 template <class ArchiveT
>
131 void serialize(ArchiveT
&ar
, Barry::Message
&m
, const unsigned int ver
)
133 ar
& make_nvp("From", m
.From
);
134 ar
& make_nvp("To", m
.To
);
135 ar
& make_nvp("Cc", m
.Cc
);
136 ar
& make_nvp("Sender", m
.Sender
);
137 ar
& make_nvp("ReplyTo", m
.ReplyTo
);
138 ar
& make_nvp("Subject", m
.Subject
);
139 ar
& make_nvp("Body", m
.Body
);
140 ar
& make_nvp("Attachment", m
.Attachment
);
141 ar
& make_nvp("MessageRecordId", m
.MessageRecordId
);
142 ar
& make_nvp("MessageReplyTo", m
.MessageReplyTo
);
143 ar
& make_nvp("MessageDateSent", m
.MessageDateSent
);
144 ar
& make_nvp("MessageDateReceived", m
.MessageDateReceived
);
146 ar
& make_nvp("MessageTruncated", m
.MessageTruncated
);
147 ar
& make_nvp("MessageRead", m
.MessageRead
);
148 ar
& make_nvp("MessageReply", m
.MessageReply
);
149 ar
& make_nvp("MessageSaved", m
.MessageSaved
);
150 ar
& make_nvp("MessageSavedDeleted", m
.MessageSavedDeleted
);
152 ar
& make_nvp("MessagePriority", m
.Priority
);
153 ar
& make_nvp("MessageSensitivity", m
.Sensitivity
);
155 if( ver
< BARRY_POD_MAP_VERSION
) {
156 ar
& make_nvp("Unknowns", m
.Unknowns
);
160 template <class ArchiveT
>
161 void serialize(ArchiveT
&ar
, Barry::Calendar
&c
, const unsigned int ver
)
163 ar
& make_nvp("RecType", c
.RecType
);
164 ar
& make_nvp("RecordId", c
.RecordId
);
166 ar
& make_nvp("AllDayEvent", c
.AllDayEvent
);
168 ar
& make_nvp("Subject", c
.Subject
);
169 ar
& make_nvp("Notes", c
.Notes
);
170 ar
& make_nvp("Location", c
.Location
);
172 ar
& make_nvp("NotificationTime", c
.NotificationTime
);
173 ar
& make_nvp("StartTime", c
.StartTime
);
174 ar
& make_nvp("EndTime", c
.EndTime
);
176 ar
& make_nvp("Organizer", c
.Organizer
);
177 ar
& make_nvp("AcceptedBy", c
.AcceptedBy
);
178 ar
& make_nvp("Invited", c
.Invited
);
180 ar
& make_nvp("FreeBusyFlag", c
.FreeBusyFlag
);
181 ar
& make_nvp("ClassFlag", c
.ClassFlag
);
183 ar
& make_nvp("Recurring", c
.Recurring
);
184 ar
& make_nvp("RecurringType", c
.RecurringType
);
185 ar
& make_nvp("Interval", c
.Interval
);
186 ar
& make_nvp("RecurringEndTime", c
.RecurringEndTime
);
187 ar
& make_nvp("Perpetual", c
.Perpetual
);
188 ar
& make_nvp("TimeZoneCode", c
.TimeZoneCode
);
189 ar
& make_nvp("TimeZoneValid", c
.TimeZoneValid
);
191 ar
& make_nvp("DayOfWeek", c
.DayOfWeek
);
192 ar
& make_nvp("WeekOfMonth", c
.WeekOfMonth
);
193 ar
& make_nvp("DayOfMonth", c
.DayOfMonth
);
194 ar
& make_nvp("MonthOfYear", c
.MonthOfYear
);
195 ar
& make_nvp("WeekDays", c
.WeekDays
);
197 if( ver
< BARRY_POD_MAP_VERSION
) {
198 ar
& make_nvp("Unknowns", c
.Unknowns
);
202 template <class ArchiveT
>
203 void serialize(ArchiveT
&ar
, Barry::CallLog
&c
, const unsigned int ver
)
205 ar
& make_nvp("RecType", c
.RecType
);
206 ar
& make_nvp("RecordId", c
.RecordId
);
208 ar
& make_nvp("Duration", c
.Duration
);
209 ar
& make_nvp("Timestamp", c
.Timestamp
);
210 ar
& make_nvp("ContactName", c
.ContactName
);
211 ar
& make_nvp("PhoneNumber", c
.PhoneNumber
);
213 ar
& make_nvp("DirectionFlag", c
.DirectionFlag
);
214 ar
& make_nvp("StatusFlag", c
.StatusFlag
);
215 ar
& make_nvp("PhoneTypeFlag", c
.PhoneTypeFlag
);
216 ar
& make_nvp("PhoneInfoFlag", c
.PhoneInfoFlag
);
218 if( ver
< BARRY_POD_MAP_VERSION
) {
219 ar
& make_nvp("Unknowns", c
.Unknowns
);
223 template <class ArchiveT
>
224 void serialize(ArchiveT
&ar
, Barry::ServiceBookConfig
&c
, const unsigned int ver
)
226 ar
& make_nvp("Format", c
.Format
);
228 if( ver
< BARRY_POD_MAP_VERSION
) {
229 ar
& make_nvp("Unknowns", c
.Unknowns
);
233 template <class ArchiveT
>
234 void serialize(ArchiveT
&ar
, Barry::ServiceBook
&c
, const unsigned int ver
)
236 ar
& make_nvp("RecType", c
.RecType
);
237 ar
& make_nvp("RecordId", c
.RecordId
);
239 ar
& make_nvp("Name", c
.Name
);
240 ar
& make_nvp("HiddenName", c
.HiddenName
);
241 ar
& make_nvp("Description", c
.Description
);
242 ar
& make_nvp("DSID", c
.DSID
);
243 ar
& make_nvp("BesDomain", c
.BesDomain
);
244 ar
& make_nvp("UniqueId", c
.UniqueId
);
245 ar
& make_nvp("ContentId", c
.ContentId
);
246 ar
& make_nvp("Config", c
.Config
);
248 if( ver
< BARRY_POD_MAP_VERSION
) {
249 ar
& make_nvp("Unknowns", c
.Unknowns
);
253 template <class ArchiveT
>
254 void serialize(ArchiveT
&ar
, Barry::Memo
&m
, const unsigned int ver
)
256 ar
& make_nvp("RecType", m
.RecType
);
257 ar
& make_nvp("RecordId", m
.RecordId
);
259 ar
& make_nvp("Title", m
.Title
);
260 ar
& make_nvp("Body", m
.Body
);
261 ar
& make_nvp("Categories", m
.Categories
);
263 if( ver
< BARRY_POD_MAP_VERSION
) {
264 ar
& make_nvp( "Unknowns", m
.Unknowns
);
268 template <class ArchiveT
>
269 void serialize(ArchiveT
&ar
, Barry::Task
&t
, const unsigned int ver
)
271 ar
& make_nvp("RecType", t
.RecType
);
272 ar
& make_nvp("RecordId", t
.RecordId
);
274 ar
& make_nvp("Summary", t
.Summary
);
275 ar
& make_nvp("Notes", t
.Notes
);
276 ar
& make_nvp("Categories", t
.Categories
);
277 ar
& make_nvp("UID", t
.UID
);
279 ar
& make_nvp("StartTime", t
.StartTime
);
280 ar
& make_nvp("DueTime", t
.DueTime
);
281 ar
& make_nvp("AlarmTime", t
.AlarmTime
);
283 ar
& make_nvp("TimeZoneCode", t
.TimeZoneCode
);
284 ar
& make_nvp("TimeZoneValid", t
.TimeZoneValid
);
286 ar
& make_nvp("AlarmType", t
.AlarmType
);
287 ar
& make_nvp("Interval", t
.Interval
);
288 ar
& make_nvp("RecurringType", t
.RecurringType
);
289 ar
& make_nvp("RecurringEndTime", t
.RecurringEndTime
);
290 ar
& make_nvp("DayOfWeek", t
.DayOfWeek
);
291 ar
& make_nvp("WeekOfMonth", t
.WeekOfMonth
);
292 ar
& make_nvp("DayOfMonth", t
.DayOfMonth
);
293 ar
& make_nvp("MonthOfYear", t
.MonthOfYear
);
294 ar
& make_nvp("WeekDays", t
.WeekDays
);
296 ar
& make_nvp("PriorityFlag", t
.PriorityFlag
);
297 ar
& make_nvp("StatusFlag", t
.StatusFlag
);
298 ar
& make_nvp("Recurring", t
.Recurring
);
299 ar
& make_nvp("Perpetual", t
.Perpetual
);
300 ar
& make_nvp("DueDateFlag", t
.DueDateFlag
);
302 if( ver
< BARRY_POD_MAP_VERSION
) {
303 ar
& make_nvp( "Unknowns", t
.Unknowns
);
307 template<class ArchiveT
>
308 void serialize(ArchiveT
&ar
, Barry::PINMessage
&p
, const unsigned int ver
)
310 ar
& make_nvp("RecType", p
.RecType
);
311 ar
& make_nvp("RecordId", p
.RecordId
);
313 ar
& make_nvp("From", p
.From
);
314 ar
& make_nvp("To", p
.To
);
315 ar
& make_nvp("Cc", p
.Cc
);
316 ar
& make_nvp("Bcc", p
.Bcc
);
317 ar
& make_nvp("Subject", p
.Subject
);
318 ar
& make_nvp("Body", p
.Body
);
319 ar
& make_nvp("MessageRecordId", p
.MessageRecordId
);
320 ar
& make_nvp("MessageReplyTo", p
.MessageReplyTo
);
321 ar
& make_nvp("MessageDateSent", p
.MessageDateSent
);
322 ar
& make_nvp("MessageDateReceived", p
.MessageDateReceived
);
324 ar
& make_nvp("MessageTruncated", p
.MessageTruncated
);
325 ar
& make_nvp("MessageRead", p
.MessageRead
);
326 ar
& make_nvp("MessageReply", p
.MessageReply
);
327 ar
& make_nvp("MessageSaved", p
.MessageSaved
);
328 ar
& make_nvp("MessageSavedDeleted", p
.MessageSavedDeleted
);
330 ar
& make_nvp("MessagePriority", p
.Priority
);
331 ar
& make_nvp("MessageSensitivity", p
.Sensitivity
);
333 if(ver
< BARRY_POD_MAP_VERSION
) {
334 ar
& make_nvp("Unknowns", p
.Unknowns
);
338 template <class ArchiveT
>
339 void serialize(ArchiveT
&ar
, Barry::SavedMessage
&m
, const unsigned int ver
)
341 ar
& make_nvp("RecType", m
.RecType
);
342 ar
& make_nvp("RecordId", m
.RecordId
);
344 ar
& make_nvp("From", m
.From
);
345 ar
& make_nvp("To", m
.To
);
346 ar
& make_nvp("Cc", m
.Cc
);
347 ar
& make_nvp("Bcc", m
.Bcc
);
348 ar
& make_nvp("Sender", m
.Sender
);
349 ar
& make_nvp("ReplyTo", m
.ReplyTo
);
350 ar
& make_nvp("Subject", m
.Subject
);
351 ar
& make_nvp("Body", m
.Body
);
352 ar
& make_nvp("Attachment", m
.Attachment
);
353 ar
& make_nvp("MessageRecordId", m
.MessageRecordId
);
354 ar
& make_nvp("MessageReplyTo", m
.MessageReplyTo
);
355 ar
& make_nvp("MessageDateSent", m
.MessageDateSent
);
356 ar
& make_nvp("MessageDateReceived", m
.MessageDateReceived
);
358 ar
& make_nvp("MessageTruncated", m
.MessageTruncated
);
359 ar
& make_nvp("MessageRead", m
.MessageRead
);
360 ar
& make_nvp("MessageReply", m
.MessageReply
);
361 ar
& make_nvp("MessageSaved", m
.MessageSaved
);
362 ar
& make_nvp("MessageSavedDeleted", m
.MessageSavedDeleted
);
364 ar
& make_nvp("MessagePriority", m
.Priority
);
365 ar
& make_nvp("MessageSensitivity", m
.Sensitivity
);
367 if( ver
< BARRY_POD_MAP_VERSION
) {
368 ar
& make_nvp("Unknowns", m
.Unknowns
);
372 template <class ArchiveT
>
373 void serialize(ArchiveT
&ar
, Barry::Sms
&m
, const unsigned int ver
)
375 ar
& make_nvp("RecType", m
.RecType
);
376 ar
& make_nvp("RecordId", m
.RecordId
);
378 ar
& make_nvp("MessageStatus", m
.MessageStatus
);
379 ar
& make_nvp("DeliveryStatus", m
.DeliveryStatus
);
381 ar
& make_nvp("IsNew", m
.IsNew
);
382 ar
& make_nvp("NewConversation", m
.NewConversation
);
383 ar
& make_nvp("Saved", m
.Saved
);
384 ar
& make_nvp("Deleted", m
.Deleted
);
385 ar
& make_nvp("Opened", m
.Opened
);
387 ar
& make_nvp("Timestamp", m
.Timestamp
);
388 ar
& make_nvp("ServiceCenterTimestamp", m
.ServiceCenterTimestamp
);
390 ar
& make_nvp("DataCodingScheme", m
.DataCodingScheme
);
391 ar
& make_nvp("ErrorId", m
.ErrorId
);
393 ar
& make_nvp("Addresses", m
.Addresses
);
394 ar
& make_nvp("Body", m
.Body
);
396 if( ver
< BARRY_POD_MAP_VERSION
) {
397 ar
& make_nvp("Unknowns", m
.Unknowns
);
401 template <class ArchiveT
>
402 void serialize(ArchiveT
&ar
, Barry::Folder
&f
, const unsigned int ver
)
404 ar
& make_nvp("RecType", f
.RecType
);
405 ar
& make_nvp("RecordId", f
.RecordId
);
407 ar
& make_nvp("FolderName", f
.Name
);
408 ar
& make_nvp("FolderNumber", f
.Number
);
409 ar
& make_nvp("FolderLevel", f
.Level
);
410 ar
& make_nvp("FolderType", f
.Type
);
412 if( ver
< BARRY_POD_MAP_VERSION
) {
413 ar
& make_nvp( "Unknowns", f
.Unknowns
);
417 template <class ArchiveT
>
418 void serialize(ArchiveT
&ar
, Barry::Timezone
&t
, const unsigned int ver
)
420 ar
& make_nvp("RecType", t
.RecType
);
421 ar
& make_nvp("RecordId", t
.RecordId
);
423 ar
& make_nvp("TZType", t
.TZType
);
424 ar
& make_nvp("DSTOffset", t
.DSTOffset
);
425 ar
& make_nvp("Index", t
.Index
);
426 ar
& make_nvp("Offset", t
.Offset
);
427 ar
& make_nvp("OffsetFraction", t
.OffsetFraction
);
428 ar
& make_nvp("StartMonth", t
.StartMonth
);
429 ar
& make_nvp("EndMonth", t
.EndMonth
);
430 ar
& make_nvp("Left", t
.Left
);
431 ar
& make_nvp("UseDST", t
.UseDST
);
433 ar
& make_nvp("TimeZoneName", t
.TimeZoneName
);
435 if( ver
< BARRY_POD_MAP_VERSION
) {
436 ar
& make_nvp("Unknowns", t
.Unknowns
);
440 }} // namespace boost::serialization