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-2007, 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
);
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("RecordId", c
.RecordId
);
67 ar
& make_nvp("Email", c
.Email
);
68 ar
& make_nvp("Phone", c
.Phone
);
69 ar
& make_nvp("Fax", c
.Fax
);
70 ar
& make_nvp("WorkPhone", c
.WorkPhone
);
71 ar
& make_nvp("HomePhone", c
.HomePhone
);
72 ar
& make_nvp("MobilePhone", c
.MobilePhone
);
73 ar
& make_nvp("Pager", c
.Pager
);
74 ar
& make_nvp("PIN", c
.PIN
);
75 ar
& make_nvp("Radio", c
.Radio
);
76 ar
& make_nvp("WorkPhone2", c
.WorkPhone2
);
77 ar
& make_nvp("HomePhone2", c
.HomePhone2
);
78 ar
& make_nvp("OtherPhone", c
.OtherPhone
);
79 ar
& make_nvp("FirstName", c
.FirstName
);
80 ar
& make_nvp("LastName", c
.LastName
);
81 ar
& make_nvp("Company", c
.Company
);
82 ar
& make_nvp("DefaultCommunicationsMethod", c
.DefaultCommunicationsMethod
);
83 ar
& make_nvp("Address1", c
.Address1
);
84 ar
& make_nvp("Address2", c
.Address2
);
85 ar
& make_nvp("Address3", c
.Address3
);
86 ar
& make_nvp("City", c
.City
);
87 ar
& make_nvp("Province", c
.Province
);
88 ar
& make_nvp("PostalCode", c
.PostalCode
);
89 ar
& make_nvp("Country", c
.Country
);
90 ar
& make_nvp("Title", c
.Title
);
91 ar
& make_nvp("PublicKey", c
.PublicKey
);
92 ar
& make_nvp("URL", c
.URL
);
93 ar
& make_nvp("Prefix", c
.Prefix
);
94 ar
& make_nvp("Category", c
.Category
);
95 ar
& make_nvp("HomeAddress1", c
.HomeAddress1
);
96 ar
& make_nvp("HomeAddress2", c
.HomeAddress2
);
97 ar
& make_nvp("HomeAddress3", c
.HomeAddress3
);
98 ar
& make_nvp("Notes", c
.Notes
);
99 ar
& make_nvp("UserDefined1", c
.UserDefined1
);
100 ar
& make_nvp("UserDefined2", c
.UserDefined2
);
101 ar
& make_nvp("UserDefined3", c
.UserDefined3
);
102 ar
& make_nvp("UserDefined4", c
.UserDefined4
);
103 ar
& make_nvp("HomeCity", c
.HomeCity
);
104 ar
& make_nvp("HomeProvince", c
.HomeProvince
);
105 ar
& make_nvp("HomePostalCode", c
.HomePostalCode
);
106 ar
& make_nvp("HomeCountry", c
.HomeCountry
);
107 ar
& make_nvp("Image", c
.Image
);
109 if( ver
< BARRY_POD_MAP_VERSION
) {
110 ar
& make_nvp("GroupLinks", c
.GroupLinks
);
111 ar
& make_nvp("Unknowns", c
.Unknowns
);
115 template <class ArchiveT
>
116 void serialize(ArchiveT
&ar
, Barry::Message::Address
&a
, const unsigned int ver
)
118 ar
& make_nvp("Name", a
.Name
);
119 ar
& make_nvp("Email", a
.Email
);
122 template <class ArchiveT
>
123 void serialize(ArchiveT
&ar
, Barry::Message
&m
, const unsigned int ver
)
125 ar
& make_nvp("From", m
.From
);
126 ar
& make_nvp("To", m
.To
);
127 ar
& make_nvp("Cc", m
.Cc
);
128 ar
& make_nvp("Subject", m
.Subject
);
129 ar
& make_nvp("Body", m
.Body
);
131 if( ver
< BARRY_POD_MAP_VERSION
) {
132 ar
& make_nvp("Unknowns", m
.Unknowns
);
136 template <class ArchiveT
>
137 void serialize(ArchiveT
&ar
, Barry::Calendar
&c
, const unsigned int ver
)
139 ar
& make_nvp("RecordId", c
.RecordId
);
141 ar
& make_nvp("Recurring", c
.Recurring
);
142 ar
& make_nvp("AllDayEvent", c
.AllDayEvent
);
144 ar
& make_nvp("Subject", c
.Subject
);
145 ar
& make_nvp("Notes", c
.Notes
);
146 ar
& make_nvp("Location", c
.Location
);
148 ar
& make_nvp("NotificationTime", c
.NotificationTime
);
149 ar
& make_nvp("StartTime", c
.StartTime
);
150 ar
& make_nvp("EndTime", c
.EndTime
);
152 ar
& make_nvp("FreeBusyFlag", c
.FreeBusyFlag
);
153 ar
& make_nvp("ClassFlag", c
.ClassFlag
);
155 ar
& make_nvp("Recurring", c
.Recurring
);
156 ar
& make_nvp("RecurringType", c
.RecurringType
);
157 ar
& make_nvp("Interval", c
.Interval
);
158 ar
& make_nvp("RecurringEndTime", c
.RecurringEndTime
);
159 ar
& make_nvp("Perpetual", c
.Perpetual
);
160 ar
& make_nvp("TimeZoneCode", c
.TimeZoneCode
);
162 if( ver
< BARRY_POD_MAP_VERSION
) {
163 ar
& make_nvp("Unknowns", c
.Unknowns
);
167 template <class ArchiveT
>
168 void serialize(ArchiveT
&ar
, Barry::ServiceBook
&c
, const unsigned int ver
)
170 ar
& make_nvp("RecordId", c
.RecordId
);
172 if( ver
< BARRY_POD_MAP_VERSION
) {
173 ar
& make_nvp("Unknowns", c
.Unknowns
);
177 template <class ArchiveT
>
178 void serialize(ArchiveT
&ar
, Barry::Memo
&m
, const unsigned int ver
)
180 ar
& make_nvp("RecordId", m
.RecordId
);
182 ar
& make_nvp("Title", m
.Title
);
183 ar
& make_nvp("Body", m
.Body
);
184 ar
& make_nvp("Category", m
.Category
);
186 if( ver
< BARRY_POD_MAP_VERSION
) {
187 ar
& make_nvp( "Unknowns", m
.Unknowns
);
191 template <class ArchiveT
>
192 void serialize(ArchiveT
&ar
, Barry::Task
&t
, const unsigned int ver
)
194 ar
& make_nvp("RecordId", t
.RecordId
);
196 ar
& make_nvp("Summary", t
.Summary
);
197 ar
& make_nvp("Notes", t
.Notes
);
198 ar
& make_nvp("Categories", t
.Categories
);
200 ar
& make_nvp("StartTime", t
.StartTime
);
201 ar
& make_nvp("AlarmTime", t
.AlarmTime
);
202 ar
& make_nvp("DueTime", t
.DueTime
);
204 ar
& make_nvp("TimeZoneCode", t
.TimeZoneCode
);
205 ar
& make_nvp("AlarmType", t
.AlarmType
);
206 ar
& make_nvp("Interval", t
.Interval
);
207 ar
& make_nvp("RecurringType", t
.RecurringType
);
208 ar
& make_nvp("RecurringEndTime", t
.RecurringEndTime
);
209 ar
& make_nvp("ClassType", t
.ClassType
);
210 ar
& make_nvp("PriorityFlag", t
.PriorityFlag
);
211 ar
& make_nvp("StatusFlag", t
.StatusFlag
);
212 ar
& make_nvp("Recurring", t
.Recurring
);
214 if( ver
< BARRY_POD_MAP_VERSION
) {
215 ar
& make_nvp( "Unknowns", t
.Unknowns
);
219 }} // namespace boost::serialization