- added item to gui's todo list
[barry.git] / src / s11n-boost.h
blob26c4060316b113ab79db691a25e2ea5680a141ef
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 Archive>
49 void serialize(Archive &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 Archive>
56 void serialize(Archive &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 Archive>
63 void serialize(Archive &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("FirstName", c.FirstName);
76 ar & make_nvp("LastName", c.LastName);
77 ar & make_nvp("Company", c.Company);
78 ar & make_nvp("DefaultCommunicationsMethod", c.DefaultCommunicationsMethod);
79 ar & make_nvp("Address1", c.Address1);
80 ar & make_nvp("Address2", c.Address2);
81 ar & make_nvp("Address3", c.Address3);
82 ar & make_nvp("City", c.City);
83 ar & make_nvp("Province", c.Province);
84 ar & make_nvp("PostalCode", c.PostalCode);
85 ar & make_nvp("Country", c.Country);
86 ar & make_nvp("Title", c.Title);
87 ar & make_nvp("PublicKey", c.PublicKey);
88 ar & make_nvp("Notes", c.Notes);
90 if( ver < BARRY_POD_MAP_VERSION ) {
91 ar & make_nvp("GroupLinks", c.GroupLinks);
92 ar & make_nvp("Unknowns", c.Unknowns);
96 template <class Archive>
97 void serialize(Archive &ar, Barry::Message::Address &a, const unsigned int ver)
99 ar & make_nvp("Name", a.Name);
100 ar & make_nvp("Email", a.Email);
103 template <class Archive>
104 void serialize(Archive &ar, Barry::Message &m, const unsigned int ver)
106 ar & make_nvp("From", m.From);
107 ar & make_nvp("To", m.To);
108 ar & make_nvp("Cc", m.Cc);
109 ar & make_nvp("Subject", m.Subject);
110 ar & make_nvp("Body", m.Body);
112 if( ver < BARRY_POD_MAP_VERSION ) {
113 ar & make_nvp("Unknowns", m.Unknowns);
117 template <class Archive>
118 void serialize(Archive &ar, Barry::Calendar &c, const unsigned int ver)
120 ar & make_nvp("RecordId", c.RecordId);
122 ar & make_nvp("Recurring", c.Recurring);
123 ar & make_nvp("AllDayEvent", c.AllDayEvent);
125 ar & make_nvp("Subject", c.Subject);
126 ar & make_nvp("Notes", c.Notes);
127 ar & make_nvp("Location", c.Location);
129 ar & make_nvp("NotificationTime", c.NotificationTime);
130 ar & make_nvp("StartTime", c.StartTime);
131 ar & make_nvp("EndTime", c.EndTime);
133 if( ver < BARRY_POD_MAP_VERSION ) {
134 ar & make_nvp("Unknowns", c.Unknowns);
138 template <class Archive>
139 void serialize(Archive &ar, Barry::ServiceBook &c, const unsigned int ver)
141 ar & make_nvp("RecordId", c.RecordId);
143 if( ver < BARRY_POD_MAP_VERSION ) {
144 ar & make_nvp("Unknowns", c.Unknowns);
148 }} // namespace boost::serialization
150 #endif