Chris@16
|
1 #ifndef GREGORIAN_SERIALIZE_HPP___
|
Chris@16
|
2 #define GREGORIAN_SERIALIZE_HPP___
|
Chris@16
|
3
|
Chris@16
|
4 /* Copyright (c) 2004-2005 CrystalClear Software, Inc.
|
Chris@16
|
5 * Use, modification and distribution is subject to the
|
Chris@16
|
6 * Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
7 * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8 * Author: Jeff Garland, Bart Garst
|
Chris@101
|
9 * $Date$
|
Chris@16
|
10 */
|
Chris@16
|
11
|
Chris@16
|
12 #include "boost/date_time/gregorian/gregorian_types.hpp"
|
Chris@16
|
13 #include "boost/date_time/gregorian/parsers.hpp"
|
Chris@16
|
14 #include "boost/serialization/split_free.hpp"
|
Chris@16
|
15 #include "boost/serialization/nvp.hpp"
|
Chris@16
|
16
|
Chris@16
|
17
|
Chris@16
|
18 // macros to split serialize functions into save & load functions
|
Chris@16
|
19 // An expanded version is below for gregorian::date
|
Chris@16
|
20 // NOTE: these macros define template functions in the boost::serialization namespace.
|
Chris@16
|
21 // They must be expanded *outside* of any namespace
|
Chris@16
|
22 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::date_duration)
|
Chris@16
|
23 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::date_duration::duration_rep)
|
Chris@16
|
24 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::date_period)
|
Chris@16
|
25 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::greg_year)
|
Chris@16
|
26 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::greg_month)
|
Chris@16
|
27 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::greg_day)
|
Chris@16
|
28 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::greg_weekday)
|
Chris@16
|
29 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::partial_date)
|
Chris@16
|
30 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::nth_kday_of_month)
|
Chris@16
|
31 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::first_kday_of_month)
|
Chris@16
|
32 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::last_kday_of_month)
|
Chris@16
|
33 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::first_kday_before)
|
Chris@16
|
34 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::first_kday_after)
|
Chris@16
|
35
|
Chris@16
|
36 namespace boost {
|
Chris@16
|
37 namespace serialization {
|
Chris@16
|
38
|
Chris@16
|
39 /*! Method that does serialization for gregorian::date -- splits to load/save
|
Chris@16
|
40 */
|
Chris@16
|
41 template<class Archive>
|
Chris@16
|
42 inline void serialize(Archive & ar,
|
Chris@16
|
43 ::boost::gregorian::date & d,
|
Chris@16
|
44 const unsigned int file_version)
|
Chris@16
|
45 {
|
Chris@16
|
46 split_free(ar, d, file_version);
|
Chris@16
|
47 }
|
Chris@16
|
48
|
Chris@16
|
49 //! Function to save gregorian::date objects using serialization lib
|
Chris@16
|
50 /*! Dates are serialized into a string for transport and storage.
|
Chris@16
|
51 * While it would be more efficient to store the internal
|
Chris@16
|
52 * integer used to manipulate the dates, it is an unstable solution.
|
Chris@16
|
53 */
|
Chris@16
|
54 template<class Archive>
|
Chris@16
|
55 void save(Archive & ar,
|
Chris@16
|
56 const ::boost::gregorian::date & d,
|
Chris@16
|
57 unsigned int /* version */)
|
Chris@16
|
58 {
|
Chris@16
|
59 std::string ds = to_iso_string(d);
|
Chris@16
|
60 ar & make_nvp("date", ds);
|
Chris@16
|
61 }
|
Chris@16
|
62
|
Chris@16
|
63 //! Function to load gregorian::date objects using serialization lib
|
Chris@16
|
64 /*! Dates are serialized into a string for transport and storage.
|
Chris@16
|
65 * While it would be more efficient to store the internal
|
Chris@16
|
66 * integer used to manipulate the dates, it is an unstable solution.
|
Chris@16
|
67 */
|
Chris@16
|
68 template<class Archive>
|
Chris@16
|
69 void load(Archive & ar,
|
Chris@16
|
70 ::boost::gregorian::date & d,
|
Chris@16
|
71 unsigned int /*version*/)
|
Chris@16
|
72 {
|
Chris@16
|
73 std::string ds;
|
Chris@16
|
74 ar & make_nvp("date", ds);
|
Chris@16
|
75 try{
|
Chris@16
|
76 d = ::boost::gregorian::from_undelimited_string(ds);
|
Chris@16
|
77 }catch(bad_lexical_cast&) {
|
Chris@16
|
78 gregorian::special_values sv = gregorian::special_value_from_string(ds);
|
Chris@16
|
79 if(sv == gregorian::not_special) {
|
Chris@16
|
80 throw; // no match found, rethrow original exception
|
Chris@16
|
81 }
|
Chris@16
|
82 else {
|
Chris@16
|
83 d = gregorian::date(sv);
|
Chris@16
|
84 }
|
Chris@16
|
85 }
|
Chris@16
|
86 }
|
Chris@16
|
87
|
Chris@16
|
88
|
Chris@16
|
89 //!override needed b/c no default constructor
|
Chris@16
|
90 template<class Archive>
|
Chris@16
|
91 inline void load_construct_data(Archive & /*ar*/,
|
Chris@16
|
92 ::boost::gregorian::date* dp,
|
Chris@16
|
93 const unsigned int /*file_version*/)
|
Chris@16
|
94 {
|
Chris@16
|
95 // retrieve data from archive required to construct new
|
Chris@16
|
96 // invoke inplace constructor to initialize instance of date
|
Chris@16
|
97 ::new(dp) ::boost::gregorian::date(::boost::gregorian::not_a_date_time);
|
Chris@16
|
98 }
|
Chris@16
|
99
|
Chris@16
|
100 /**** date_duration ****/
|
Chris@16
|
101
|
Chris@16
|
102 //! Function to save gregorian::date_duration objects using serialization lib
|
Chris@16
|
103 template<class Archive>
|
Chris@16
|
104 void save(Archive & ar, const gregorian::date_duration & dd,
|
Chris@16
|
105 unsigned int /*version*/)
|
Chris@16
|
106 {
|
Chris@16
|
107 typename gregorian::date_duration::duration_rep dr = dd.get_rep();
|
Chris@16
|
108 ar & make_nvp("date_duration", dr);
|
Chris@16
|
109 }
|
Chris@16
|
110 //! Function to load gregorian::date_duration objects using serialization lib
|
Chris@16
|
111 template<class Archive>
|
Chris@16
|
112 void load(Archive & ar, gregorian::date_duration & dd, unsigned int /*version*/)
|
Chris@16
|
113 {
|
Chris@16
|
114 typename gregorian::date_duration::duration_rep dr(0);
|
Chris@16
|
115 ar & make_nvp("date_duration", dr);
|
Chris@16
|
116 dd = gregorian::date_duration(dr);
|
Chris@16
|
117 }
|
Chris@16
|
118 //!override needed b/c no default constructor
|
Chris@16
|
119 template<class Archive>
|
Chris@16
|
120 inline void load_construct_data(Archive & /*ar*/, gregorian::date_duration* dd,
|
Chris@16
|
121 const unsigned int /*file_version*/)
|
Chris@16
|
122 {
|
Chris@16
|
123 ::new(dd) gregorian::date_duration(gregorian::not_a_date_time);
|
Chris@16
|
124 }
|
Chris@16
|
125
|
Chris@16
|
126 /**** date_duration::duration_rep (most likely int_adapter) ****/
|
Chris@16
|
127
|
Chris@16
|
128 //! helper unction to save date_duration objects using serialization lib
|
Chris@16
|
129 template<class Archive>
|
Chris@16
|
130 void save(Archive & ar, const gregorian::date_duration::duration_rep & dr,
|
Chris@16
|
131 unsigned int /*version*/)
|
Chris@16
|
132 {
|
Chris@16
|
133 typename gregorian::date_duration::duration_rep::int_type it = dr.as_number();
|
Chris@16
|
134 ar & make_nvp("date_duration_duration_rep", it);
|
Chris@16
|
135 }
|
Chris@16
|
136 //! helper function to load date_duration objects using serialization lib
|
Chris@16
|
137 template<class Archive>
|
Chris@16
|
138 void load(Archive & ar, gregorian::date_duration::duration_rep & dr, unsigned int /*version*/)
|
Chris@16
|
139 {
|
Chris@16
|
140 typename gregorian::date_duration::duration_rep::int_type it(0);
|
Chris@16
|
141 ar & make_nvp("date_duration_duration_rep", it);
|
Chris@16
|
142 dr = gregorian::date_duration::duration_rep::int_type(it);
|
Chris@16
|
143 }
|
Chris@16
|
144 //!override needed b/c no default constructor
|
Chris@16
|
145 template<class Archive>
|
Chris@16
|
146 inline void load_construct_data(Archive & /*ar*/, gregorian::date_duration::duration_rep* dr,
|
Chris@16
|
147 const unsigned int /*file_version*/)
|
Chris@16
|
148 {
|
Chris@16
|
149 ::new(dr) gregorian::date_duration::duration_rep(0);
|
Chris@16
|
150 }
|
Chris@16
|
151
|
Chris@16
|
152 /**** date_period ****/
|
Chris@16
|
153
|
Chris@16
|
154 //! Function to save gregorian::date_period objects using serialization lib
|
Chris@16
|
155 /*! date_period objects are broken down into 2 parts for serialization:
|
Chris@16
|
156 * the begining date object and the end date object
|
Chris@16
|
157 */
|
Chris@16
|
158 template<class Archive>
|
Chris@16
|
159 void save(Archive & ar, const gregorian::date_period& dp,
|
Chris@16
|
160 unsigned int /*version*/)
|
Chris@16
|
161 {
|
Chris@16
|
162 gregorian::date d1 = dp.begin();
|
Chris@16
|
163 gregorian::date d2 = dp.end();
|
Chris@16
|
164 ar & make_nvp("date_period_begin_date", d1);
|
Chris@16
|
165 ar & make_nvp("date_period_end_date", d2);
|
Chris@16
|
166 }
|
Chris@16
|
167 //! Function to load gregorian::date_period objects using serialization lib
|
Chris@16
|
168 /*! date_period objects are broken down into 2 parts for serialization:
|
Chris@16
|
169 * the begining date object and the end date object
|
Chris@16
|
170 */
|
Chris@16
|
171 template<class Archive>
|
Chris@16
|
172 void load(Archive & ar, gregorian::date_period& dp, unsigned int /*version*/)
|
Chris@16
|
173 {
|
Chris@16
|
174 gregorian::date d1(gregorian::not_a_date_time);
|
Chris@16
|
175 gregorian::date d2(gregorian::not_a_date_time);
|
Chris@16
|
176 ar & make_nvp("date_period_begin_date", d1);
|
Chris@16
|
177 ar & make_nvp("date_period_end_date", d2);
|
Chris@16
|
178 dp = gregorian::date_period(d1,d2);
|
Chris@16
|
179 }
|
Chris@16
|
180 //!override needed b/c no default constructor
|
Chris@16
|
181 template<class Archive>
|
Chris@16
|
182 inline void load_construct_data(Archive & /*ar*/, gregorian::date_period* dp,
|
Chris@16
|
183 const unsigned int /*file_version*/)
|
Chris@16
|
184 {
|
Chris@16
|
185 gregorian::date d(gregorian::not_a_date_time);
|
Chris@16
|
186 gregorian::date_duration dd(1);
|
Chris@16
|
187 ::new(dp) gregorian::date_period(d,dd);
|
Chris@16
|
188 }
|
Chris@16
|
189
|
Chris@16
|
190 /**** greg_year ****/
|
Chris@16
|
191
|
Chris@16
|
192 //! Function to save gregorian::greg_year objects using serialization lib
|
Chris@16
|
193 template<class Archive>
|
Chris@16
|
194 void save(Archive & ar, const gregorian::greg_year& gy,
|
Chris@16
|
195 unsigned int /*version*/)
|
Chris@16
|
196 {
|
Chris@16
|
197 unsigned short us = gy;
|
Chris@16
|
198 ar & make_nvp("greg_year", us);
|
Chris@16
|
199 }
|
Chris@16
|
200 //! Function to load gregorian::greg_year objects using serialization lib
|
Chris@16
|
201 template<class Archive>
|
Chris@16
|
202 void load(Archive & ar, gregorian::greg_year& gy, unsigned int /*version*/)
|
Chris@16
|
203 {
|
Chris@16
|
204 unsigned short us;
|
Chris@16
|
205 ar & make_nvp("greg_year", us);
|
Chris@16
|
206 gy = gregorian::greg_year(us);
|
Chris@16
|
207 }
|
Chris@16
|
208 //!override needed b/c no default constructor
|
Chris@16
|
209 template<class Archive>
|
Chris@16
|
210 inline void load_construct_data(Archive & /*ar*/, gregorian::greg_year* gy,
|
Chris@16
|
211 const unsigned int /*file_version*/)
|
Chris@16
|
212 {
|
Chris@16
|
213 ::new(gy) gregorian::greg_year(1900);
|
Chris@16
|
214 }
|
Chris@16
|
215
|
Chris@16
|
216 /**** greg_month ****/
|
Chris@16
|
217
|
Chris@16
|
218 //! Function to save gregorian::greg_month objects using serialization lib
|
Chris@16
|
219 template<class Archive>
|
Chris@16
|
220 void save(Archive & ar, const gregorian::greg_month& gm,
|
Chris@16
|
221 unsigned int /*version*/)
|
Chris@16
|
222 {
|
Chris@16
|
223 unsigned short us = gm.as_number();
|
Chris@16
|
224 ar & make_nvp("greg_month", us);
|
Chris@16
|
225 }
|
Chris@16
|
226 //! Function to load gregorian::greg_month objects using serialization lib
|
Chris@16
|
227 template<class Archive>
|
Chris@16
|
228 void load(Archive & ar, gregorian::greg_month& gm, unsigned int /*version*/)
|
Chris@16
|
229 {
|
Chris@16
|
230 unsigned short us;
|
Chris@16
|
231 ar & make_nvp("greg_month", us);
|
Chris@16
|
232 gm = gregorian::greg_month(us);
|
Chris@16
|
233 }
|
Chris@16
|
234 //!override needed b/c no default constructor
|
Chris@16
|
235 template<class Archive>
|
Chris@16
|
236 inline void load_construct_data(Archive & /*ar*/, gregorian::greg_month* gm,
|
Chris@16
|
237 const unsigned int /*file_version*/)
|
Chris@16
|
238 {
|
Chris@16
|
239 ::new(gm) gregorian::greg_month(1);
|
Chris@16
|
240 }
|
Chris@16
|
241
|
Chris@16
|
242 /**** greg_day ****/
|
Chris@16
|
243
|
Chris@16
|
244 //! Function to save gregorian::greg_day objects using serialization lib
|
Chris@16
|
245 template<class Archive>
|
Chris@16
|
246 void save(Archive & ar, const gregorian::greg_day& gd,
|
Chris@16
|
247 unsigned int /*version*/)
|
Chris@16
|
248 {
|
Chris@16
|
249 unsigned short us = gd.as_number();
|
Chris@16
|
250 ar & make_nvp("greg_day", us);
|
Chris@16
|
251 }
|
Chris@16
|
252 //! Function to load gregorian::greg_day objects using serialization lib
|
Chris@16
|
253 template<class Archive>
|
Chris@16
|
254 void load(Archive & ar, gregorian::greg_day& gd, unsigned int /*version*/)
|
Chris@16
|
255 {
|
Chris@16
|
256 unsigned short us;
|
Chris@16
|
257 ar & make_nvp("greg_day", us);
|
Chris@16
|
258 gd = gregorian::greg_day(us);
|
Chris@16
|
259 }
|
Chris@16
|
260 //!override needed b/c no default constructor
|
Chris@16
|
261 template<class Archive>
|
Chris@16
|
262 inline void load_construct_data(Archive & /*ar*/, gregorian::greg_day* gd,
|
Chris@16
|
263 const unsigned int /*file_version*/)
|
Chris@16
|
264 {
|
Chris@16
|
265 ::new(gd) gregorian::greg_day(1);
|
Chris@16
|
266 }
|
Chris@16
|
267
|
Chris@16
|
268 /**** greg_weekday ****/
|
Chris@16
|
269
|
Chris@16
|
270 //! Function to save gregorian::greg_weekday objects using serialization lib
|
Chris@16
|
271 template<class Archive>
|
Chris@16
|
272 void save(Archive & ar, const gregorian::greg_weekday& gd,
|
Chris@16
|
273 unsigned int /*version*/)
|
Chris@16
|
274 {
|
Chris@16
|
275 unsigned short us = gd.as_number();
|
Chris@16
|
276 ar & make_nvp("greg_weekday", us);
|
Chris@16
|
277 }
|
Chris@16
|
278 //! Function to load gregorian::greg_weekday objects using serialization lib
|
Chris@16
|
279 template<class Archive>
|
Chris@16
|
280 void load(Archive & ar, gregorian::greg_weekday& gd, unsigned int /*version*/)
|
Chris@16
|
281 {
|
Chris@16
|
282 unsigned short us;
|
Chris@16
|
283 ar & make_nvp("greg_weekday", us);
|
Chris@16
|
284 gd = gregorian::greg_weekday(us);
|
Chris@16
|
285 }
|
Chris@16
|
286 //!override needed b/c no default constructor
|
Chris@16
|
287 template<class Archive>
|
Chris@16
|
288 inline void load_construct_data(Archive & /*ar*/, gregorian::greg_weekday* gd,
|
Chris@16
|
289 const unsigned int /*file_version*/)
|
Chris@16
|
290 {
|
Chris@16
|
291 ::new(gd) gregorian::greg_weekday(1);
|
Chris@16
|
292 }
|
Chris@16
|
293
|
Chris@16
|
294 /**** date_generators ****/
|
Chris@16
|
295
|
Chris@16
|
296 /**** partial_date ****/
|
Chris@16
|
297
|
Chris@16
|
298 //! Function to save gregorian::partial_date objects using serialization lib
|
Chris@16
|
299 /*! partial_date objects are broken down into 2 parts for serialization:
|
Chris@16
|
300 * the day (typically greg_day) and month (typically greg_month) objects
|
Chris@16
|
301 */
|
Chris@16
|
302 template<class Archive>
|
Chris@16
|
303 void save(Archive & ar, const gregorian::partial_date& pd,
|
Chris@16
|
304 unsigned int /*version*/)
|
Chris@16
|
305 {
|
Chris@16
|
306 gregorian::greg_day gd(pd.day());
|
Chris@16
|
307 gregorian::greg_month gm(pd.month().as_number());
|
Chris@16
|
308 ar & make_nvp("partial_date_day", gd);
|
Chris@16
|
309 ar & make_nvp("partial_date_month", gm);
|
Chris@16
|
310 }
|
Chris@16
|
311 //! Function to load gregorian::partial_date objects using serialization lib
|
Chris@16
|
312 /*! partial_date objects are broken down into 2 parts for serialization:
|
Chris@16
|
313 * the day (greg_day) and month (greg_month) objects
|
Chris@16
|
314 */
|
Chris@16
|
315 template<class Archive>
|
Chris@16
|
316 void load(Archive & ar, gregorian::partial_date& pd, unsigned int /*version*/)
|
Chris@16
|
317 {
|
Chris@16
|
318 gregorian::greg_day gd(1);
|
Chris@16
|
319 gregorian::greg_month gm(1);
|
Chris@16
|
320 ar & make_nvp("partial_date_day", gd);
|
Chris@16
|
321 ar & make_nvp("partial_date_month", gm);
|
Chris@16
|
322 pd = gregorian::partial_date(gd,gm);
|
Chris@16
|
323 }
|
Chris@16
|
324 //!override needed b/c no default constructor
|
Chris@16
|
325 template<class Archive>
|
Chris@16
|
326 inline void load_construct_data(Archive & /*ar*/, gregorian::partial_date* pd,
|
Chris@16
|
327 const unsigned int /*file_version*/)
|
Chris@16
|
328 {
|
Chris@16
|
329 gregorian::greg_month gm(1);
|
Chris@16
|
330 gregorian::greg_day gd(1);
|
Chris@16
|
331 ::new(pd) gregorian::partial_date(gd,gm);
|
Chris@16
|
332 }
|
Chris@16
|
333
|
Chris@16
|
334 /**** nth_kday_of_month ****/
|
Chris@16
|
335
|
Chris@16
|
336 //! Function to save nth_day_of_the_week_in_month objects using serialization lib
|
Chris@16
|
337 /*! nth_day_of_the_week_in_month objects are broken down into 3 parts for
|
Chris@16
|
338 * serialization: the week number, the day of the week, and the month
|
Chris@16
|
339 */
|
Chris@16
|
340 template<class Archive>
|
Chris@16
|
341 void save(Archive & ar, const gregorian::nth_kday_of_month& nkd,
|
Chris@16
|
342 unsigned int /*version*/)
|
Chris@16
|
343 {
|
Chris@16
|
344 typename gregorian::nth_kday_of_month::week_num wn(nkd.nth_week());
|
Chris@16
|
345 typename gregorian::nth_kday_of_month::day_of_week_type d(nkd.day_of_week().as_number());
|
Chris@16
|
346 typename gregorian::nth_kday_of_month::month_type m(nkd.month().as_number());
|
Chris@16
|
347 ar & make_nvp("nth_kday_of_month_week_num", wn);
|
Chris@16
|
348 ar & make_nvp("nth_kday_of_month_day_of_week", d);
|
Chris@16
|
349 ar & make_nvp("nth_kday_of_month_month", m);
|
Chris@16
|
350 }
|
Chris@16
|
351 //! Function to load nth_day_of_the_week_in_month objects using serialization lib
|
Chris@16
|
352 /*! nth_day_of_the_week_in_month objects are broken down into 3 parts for
|
Chris@16
|
353 * serialization: the week number, the day of the week, and the month
|
Chris@16
|
354 */
|
Chris@16
|
355 template<class Archive>
|
Chris@16
|
356 void load(Archive & ar, gregorian::nth_kday_of_month& nkd, unsigned int /*version*/)
|
Chris@16
|
357 {
|
Chris@16
|
358 typename gregorian::nth_kday_of_month::week_num wn(gregorian::nth_kday_of_month::first);
|
Chris@16
|
359 typename gregorian::nth_kday_of_month::day_of_week_type d(gregorian::Monday);
|
Chris@16
|
360 typename gregorian::nth_kday_of_month::month_type m(gregorian::Jan);
|
Chris@16
|
361 ar & make_nvp("nth_kday_of_month_week_num", wn);
|
Chris@16
|
362 ar & make_nvp("nth_kday_of_month_day_of_week", d);
|
Chris@16
|
363 ar & make_nvp("nth_kday_of_month_month", m);
|
Chris@16
|
364
|
Chris@16
|
365 nkd = gregorian::nth_kday_of_month(wn,d,m);
|
Chris@16
|
366 }
|
Chris@16
|
367 //!override needed b/c no default constructor
|
Chris@16
|
368 template<class Archive>
|
Chris@16
|
369 inline void load_construct_data(Archive & /*ar*/,
|
Chris@16
|
370 gregorian::nth_kday_of_month* nkd,
|
Chris@16
|
371 const unsigned int /*file_version*/)
|
Chris@16
|
372 {
|
Chris@16
|
373 // values used are not significant
|
Chris@16
|
374 ::new(nkd) gregorian::nth_kday_of_month(gregorian::nth_kday_of_month::first,
|
Chris@16
|
375 gregorian::Monday,gregorian::Jan);
|
Chris@16
|
376 }
|
Chris@16
|
377
|
Chris@16
|
378 /**** first_kday_of_month ****/
|
Chris@16
|
379
|
Chris@16
|
380 //! Function to save first_day_of_the_week_in_month objects using serialization lib
|
Chris@16
|
381 /*! first_day_of_the_week_in_month objects are broken down into 2 parts for
|
Chris@16
|
382 * serialization: the day of the week, and the month
|
Chris@16
|
383 */
|
Chris@16
|
384 template<class Archive>
|
Chris@16
|
385 void save(Archive & ar, const gregorian::first_kday_of_month& fkd,
|
Chris@16
|
386 unsigned int /*version*/)
|
Chris@16
|
387 {
|
Chris@16
|
388 typename gregorian::first_kday_of_month::day_of_week_type d(fkd.day_of_week().as_number());
|
Chris@16
|
389 typename gregorian::first_kday_of_month::month_type m(fkd.month().as_number());
|
Chris@16
|
390 ar & make_nvp("first_kday_of_month_day_of_week", d);
|
Chris@16
|
391 ar & make_nvp("first_kday_of_month_month", m);
|
Chris@16
|
392 }
|
Chris@16
|
393 //! Function to load first_day_of_the_week_in_month objects using serialization lib
|
Chris@16
|
394 /*! first_day_of_the_week_in_month objects are broken down into 2 parts for
|
Chris@16
|
395 * serialization: the day of the week, and the month
|
Chris@16
|
396 */
|
Chris@16
|
397 template<class Archive>
|
Chris@16
|
398 void load(Archive & ar, gregorian::first_kday_of_month& fkd, unsigned int /*version*/)
|
Chris@16
|
399 {
|
Chris@16
|
400 typename gregorian::first_kday_of_month::day_of_week_type d(gregorian::Monday);
|
Chris@16
|
401 typename gregorian::first_kday_of_month::month_type m(gregorian::Jan);
|
Chris@16
|
402 ar & make_nvp("first_kday_of_month_day_of_week", d);
|
Chris@16
|
403 ar & make_nvp("first_kday_of_month_month", m);
|
Chris@16
|
404
|
Chris@16
|
405 fkd = gregorian::first_kday_of_month(d,m);
|
Chris@16
|
406 }
|
Chris@16
|
407 //!override needed b/c no default constructor
|
Chris@16
|
408 template<class Archive>
|
Chris@16
|
409 inline void load_construct_data(Archive & /*ar*/,
|
Chris@16
|
410 gregorian::first_kday_of_month* fkd,
|
Chris@16
|
411 const unsigned int /*file_version*/)
|
Chris@16
|
412 {
|
Chris@16
|
413 // values used are not significant
|
Chris@16
|
414 ::new(fkd) gregorian::first_kday_of_month(gregorian::Monday,gregorian::Jan);
|
Chris@16
|
415 }
|
Chris@16
|
416
|
Chris@16
|
417 /**** last_kday_of_month ****/
|
Chris@16
|
418
|
Chris@16
|
419 //! Function to save last_day_of_the_week_in_month objects using serialization lib
|
Chris@16
|
420 /*! last_day_of_the_week_in_month objects are broken down into 2 parts for
|
Chris@16
|
421 * serialization: the day of the week, and the month
|
Chris@16
|
422 */
|
Chris@16
|
423 template<class Archive>
|
Chris@16
|
424 void save(Archive & ar, const gregorian::last_kday_of_month& lkd,
|
Chris@16
|
425 unsigned int /*version*/)
|
Chris@16
|
426 {
|
Chris@16
|
427 typename gregorian::last_kday_of_month::day_of_week_type d(lkd.day_of_week().as_number());
|
Chris@16
|
428 typename gregorian::last_kday_of_month::month_type m(lkd.month().as_number());
|
Chris@16
|
429 ar & make_nvp("last_kday_of_month_day_of_week", d);
|
Chris@16
|
430 ar & make_nvp("last_kday_of_month_month", m);
|
Chris@16
|
431 }
|
Chris@16
|
432 //! Function to load last_day_of_the_week_in_month objects using serialization lib
|
Chris@16
|
433 /*! last_day_of_the_week_in_month objects are broken down into 2 parts for
|
Chris@16
|
434 * serialization: the day of the week, and the month
|
Chris@16
|
435 */
|
Chris@16
|
436 template<class Archive>
|
Chris@16
|
437 void load(Archive & ar, gregorian::last_kday_of_month& lkd, unsigned int /*version*/)
|
Chris@16
|
438 {
|
Chris@16
|
439 typename gregorian::last_kday_of_month::day_of_week_type d(gregorian::Monday);
|
Chris@16
|
440 typename gregorian::last_kday_of_month::month_type m(gregorian::Jan);
|
Chris@16
|
441 ar & make_nvp("last_kday_of_month_day_of_week", d);
|
Chris@16
|
442 ar & make_nvp("last_kday_of_month_month", m);
|
Chris@16
|
443
|
Chris@16
|
444 lkd = gregorian::last_kday_of_month(d,m);
|
Chris@16
|
445 }
|
Chris@16
|
446 //!override needed b/c no default constructor
|
Chris@16
|
447 template<class Archive>
|
Chris@16
|
448 inline void load_construct_data(Archive & /*ar*/,
|
Chris@16
|
449 gregorian::last_kday_of_month* lkd,
|
Chris@16
|
450 const unsigned int /*file_version*/)
|
Chris@16
|
451 {
|
Chris@16
|
452 // values used are not significant
|
Chris@16
|
453 ::new(lkd) gregorian::last_kday_of_month(gregorian::Monday,gregorian::Jan);
|
Chris@16
|
454 }
|
Chris@16
|
455
|
Chris@16
|
456 /**** first_kday_before ****/
|
Chris@16
|
457
|
Chris@16
|
458 //! Function to save first_day_of_the_week_before objects using serialization lib
|
Chris@16
|
459 template<class Archive>
|
Chris@16
|
460 void save(Archive & ar, const gregorian::first_kday_before& fkdb,
|
Chris@16
|
461 unsigned int /*version*/)
|
Chris@16
|
462 {
|
Chris@16
|
463 typename gregorian::first_kday_before::day_of_week_type d(fkdb.day_of_week().as_number());
|
Chris@16
|
464 ar & make_nvp("first_kday_before_day_of_week", d);
|
Chris@16
|
465 }
|
Chris@16
|
466 //! Function to load first_day_of_the_week_before objects using serialization lib
|
Chris@16
|
467 template<class Archive>
|
Chris@16
|
468 void load(Archive & ar, gregorian::first_kday_before& fkdb, unsigned int /*version*/)
|
Chris@16
|
469 {
|
Chris@16
|
470 typename gregorian::first_kday_before::day_of_week_type d(gregorian::Monday);
|
Chris@16
|
471 ar & make_nvp("first_kday_before_day_of_week", d);
|
Chris@16
|
472
|
Chris@16
|
473 fkdb = gregorian::first_kday_before(d);
|
Chris@16
|
474 }
|
Chris@16
|
475 //!override needed b/c no default constructor
|
Chris@16
|
476 template<class Archive>
|
Chris@16
|
477 inline void load_construct_data(Archive & /*ar*/,
|
Chris@16
|
478 gregorian::first_kday_before* fkdb,
|
Chris@16
|
479 const unsigned int /*file_version*/)
|
Chris@16
|
480 {
|
Chris@16
|
481 // values used are not significant
|
Chris@16
|
482 ::new(fkdb) gregorian::first_kday_before(gregorian::Monday);
|
Chris@16
|
483 }
|
Chris@16
|
484
|
Chris@16
|
485 /**** first_kday_after ****/
|
Chris@16
|
486
|
Chris@16
|
487 //! Function to save first_day_of_the_week_after objects using serialization lib
|
Chris@16
|
488 template<class Archive>
|
Chris@16
|
489 void save(Archive & ar, const gregorian::first_kday_after& fkda,
|
Chris@16
|
490 unsigned int /*version*/)
|
Chris@16
|
491 {
|
Chris@16
|
492 typename gregorian::first_kday_after::day_of_week_type d(fkda.day_of_week().as_number());
|
Chris@16
|
493 ar & make_nvp("first_kday_after_day_of_week", d);
|
Chris@16
|
494 }
|
Chris@16
|
495 //! Function to load first_day_of_the_week_after objects using serialization lib
|
Chris@16
|
496 template<class Archive>
|
Chris@16
|
497 void load(Archive & ar, gregorian::first_kday_after& fkda, unsigned int /*version*/)
|
Chris@16
|
498 {
|
Chris@16
|
499 typename gregorian::first_kday_after::day_of_week_type d(gregorian::Monday);
|
Chris@16
|
500 ar & make_nvp("first_kday_after_day_of_week", d);
|
Chris@16
|
501
|
Chris@16
|
502 fkda = gregorian::first_kday_after(d);
|
Chris@16
|
503 }
|
Chris@16
|
504 //!override needed b/c no default constructor
|
Chris@16
|
505 template<class Archive>
|
Chris@16
|
506 inline void load_construct_data(Archive & /*ar*/,
|
Chris@16
|
507 gregorian::first_kday_after* fkda,
|
Chris@16
|
508 const unsigned int /*file_version*/)
|
Chris@16
|
509 {
|
Chris@16
|
510 // values used are not significant
|
Chris@16
|
511 ::new(fkda) gregorian::first_kday_after(gregorian::Monday);
|
Chris@16
|
512 }
|
Chris@16
|
513
|
Chris@16
|
514 } // namespace serialization
|
Chris@16
|
515 } // namespace boost
|
Chris@16
|
516
|
Chris@16
|
517 #endif
|