- fixed Category handling in the Contact record class, to
[barry.git] / src / s11n-boost.h
blob3b831f2f08d473845ba569b31599e62569994650
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-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__
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);
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.WorkAddress.Address1);
84 ar & make_nvp("Address2", c.WorkAddress.Address2);
85 ar & make_nvp("Address3", c.WorkAddress.Address3);
86 ar & make_nvp("City", c.WorkAddress.City);
87 ar & make_nvp("Province", c.WorkAddress.Province);
88 ar & make_nvp("PostalCode", c.WorkAddress.PostalCode);
89 ar & make_nvp("Country", c.WorkAddress.Country);
90 ar & make_nvp("JobTitle", c.JobTitle);
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("Categories", c.Categories);
95 ar & make_nvp("HomeAddress1", c.HomeAddress.Address1);
96 ar & make_nvp("HomeAddress2", c.HomeAddress.Address2);
97 ar & make_nvp("HomeAddress3", c.HomeAddress.Address3);
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.HomeAddress.City);
104 ar & make_nvp("HomeProvince", c.HomeAddress.Province);
105 ar & make_nvp("HomePostalCode", c.HomeAddress.PostalCode);
106 ar & make_nvp("HomeCountry", c.HomeAddress.Country);
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::EmailAddress &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("Sender", m.Sender);
129 ar & make_nvp("ReplyTo", m.ReplyTo);
130 ar & make_nvp("Subject", m.Subject);
131 ar & make_nvp("Body", m.Body);
132 ar & make_nvp("Attachment", m.Attachment);
134 if( ver < BARRY_POD_MAP_VERSION ) {
135 ar & make_nvp("Unknowns", m.Unknowns);
139 template <class ArchiveT>
140 void serialize(ArchiveT &ar, Barry::Calendar &c, const unsigned int ver)
142 ar & make_nvp("RecordId", c.RecordId);
144 ar & make_nvp("Recurring", c.Recurring);
145 ar & make_nvp("AllDayEvent", c.AllDayEvent);
147 ar & make_nvp("Subject", c.Subject);
148 ar & make_nvp("Notes", c.Notes);
149 ar & make_nvp("Location", c.Location);
151 ar & make_nvp("NotificationTime", c.NotificationTime);
152 ar & make_nvp("StartTime", c.StartTime);
153 ar & make_nvp("EndTime", c.EndTime);
155 ar & make_nvp("FreeBusyFlag", c.FreeBusyFlag);
156 ar & make_nvp("ClassFlag", c.ClassFlag);
158 ar & make_nvp("Recurring", c.Recurring);
159 ar & make_nvp("RecurringType", c.RecurringType);
160 ar & make_nvp("Interval", c.Interval);
161 ar & make_nvp("RecurringEndTime", c.RecurringEndTime);
162 ar & make_nvp("Perpetual", c.Perpetual);
163 ar & make_nvp("TimeZoneCode", c.TimeZoneCode);
165 if( ver < BARRY_POD_MAP_VERSION ) {
166 ar & make_nvp("Unknowns", c.Unknowns);
170 template <class ArchiveT>
171 void serialize(ArchiveT &ar, Barry::ServiceBook &c, const unsigned int ver)
173 ar & make_nvp("RecordId", c.RecordId);
175 if( ver < BARRY_POD_MAP_VERSION ) {
176 ar & make_nvp("Unknowns", c.Unknowns);
180 template <class ArchiveT>
181 void serialize(ArchiveT &ar, Barry::Memo &m, const unsigned int ver)
183 ar & make_nvp("RecordId", m.RecordId);
185 ar & make_nvp("Title", m.Title);
186 ar & make_nvp("Body", m.Body);
187 ar & make_nvp("Category", m.Category);
189 if( ver < BARRY_POD_MAP_VERSION ) {
190 ar & make_nvp( "Unknowns", m.Unknowns);
194 template <class ArchiveT>
195 void serialize(ArchiveT &ar, Barry::Task &t, const unsigned int ver)
197 ar & make_nvp("RecordId", t.RecordId);
199 ar & make_nvp("Summary", t.Summary);
200 ar & make_nvp("Notes", t.Notes);
201 ar & make_nvp("Categories", t.Categories);
203 ar & make_nvp("StartTime", t.StartTime);
204 ar & make_nvp("AlarmTime", t.AlarmTime);
205 ar & make_nvp("DueTime", t.DueTime);
207 ar & make_nvp("TimeZoneCode", t.TimeZoneCode);
208 ar & make_nvp("AlarmType", t.AlarmType);
209 ar & make_nvp("Interval", t.Interval);
210 ar & make_nvp("RecurringType", t.RecurringType);
211 ar & make_nvp("RecurringEndTime", t.RecurringEndTime);
212 ar & make_nvp("ClassType", t.ClassType);
213 ar & make_nvp("PriorityFlag", t.PriorityFlag);
214 ar & make_nvp("StatusFlag", t.StatusFlag);
215 ar & make_nvp("Recurring", t.Recurring);
217 if( ver < BARRY_POD_MAP_VERSION ) {
218 ar & make_nvp( "Unknowns", t.Unknowns);
222 template<class ArchiveT>
223 void serialize(ArchiveT &ar, Barry::PINMessage &p, const unsigned int ver)
225 ar & make_nvp("From", p.From);
226 ar & make_nvp("To", p.To);
227 ar & make_nvp("Cc", p.Cc);
228 ar & make_nvp("Bcc", p.Bcc);
229 ar & make_nvp("Subject", p.Subject);
230 ar & make_nvp("Body", p.Body);
232 if(ver < BARRY_POD_MAP_VERSION) {
233 ar & make_nvp("Unknowns", p.Unknowns);
237 template <class ArchiveT>
238 void serialize(ArchiveT &ar, Barry::SavedMessage &m, const unsigned int ver)
240 ar & make_nvp("From", m.From);
241 ar & make_nvp("To", m.To);
242 ar & make_nvp("Cc", m.Cc);
243 ar & make_nvp("Bcc", m.Bcc);
244 ar & make_nvp("Sender", m.Sender);
245 ar & make_nvp("ReplyTo", m.ReplyTo);
246 ar & make_nvp("Subject", m.Subject);
247 ar & make_nvp("Body", m.Body);
248 ar & make_nvp("Attachment", m.Attachment);
250 if( ver < BARRY_POD_MAP_VERSION ) {
251 ar & make_nvp("Unknowns", m.Unknowns);
255 template <class ArchiveT>
256 void serialize(ArchiveT &ar, Barry::Folder &f, const unsigned int ver)
258 ar & make_nvp("FolderName", f.FolderName);
259 if( ver < BARRY_POD_MAP_VERSION ) {
260 ar & make_nvp( "Unknowns", f.Unknowns);
264 }} // namespace boost::serialization
266 #endif