Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79539 - in branches/release: boost/date_time/gregorian libs/date_time/test/gregorian
From: marshall_at_[hidden]
Date: 2012-07-15 12:49:32


Author: marshall
Date: 2012-07-15 12:49:32 EDT (Sun, 15 Jul 2012)
New Revision: 79539
URL: http://svn.boost.org/trac/boost/changeset/79539

Log:
Merge greg_year serialization changes to release; fixes #3633
Properties modified:
   branches/release/boost/date_time/gregorian/greg_serialize.hpp (contents, props changed)
   branches/release/libs/date_time/test/gregorian/testgreg_serialize.cpp (contents, props changed)
Text files modified:
   branches/release/boost/date_time/gregorian/greg_serialize.hpp | 27 +++++++++++++++++++++++++++
   branches/release/libs/date_time/test/gregorian/testgreg_serialize.cpp | 7 +++++++
   2 files changed, 34 insertions(+), 0 deletions(-)

Modified: branches/release/boost/date_time/gregorian/greg_serialize.hpp
==============================================================================
--- branches/release/boost/date_time/gregorian/greg_serialize.hpp (original)
+++ branches/release/boost/date_time/gregorian/greg_serialize.hpp 2012-07-15 12:49:32 EDT (Sun, 15 Jul 2012)
@@ -22,6 +22,7 @@
 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::date_duration)
 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::date_duration::duration_rep)
 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::date_period)
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::greg_year)
 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::greg_month)
 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::greg_day)
 BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::greg_weekday)
@@ -186,6 +187,32 @@
   ::new(dp) gregorian::date_period(d,dd);
 }
 
+/**** greg_year ****/
+
+//! Function to save gregorian::greg_year objects using serialization lib
+template<class Archive>
+void save(Archive & ar, const gregorian::greg_year& gy,
+ unsigned int /*version*/)
+{
+ unsigned short us = gy;
+ ar & make_nvp("greg_year", us);
+}
+//! Function to load gregorian::greg_year objects using serialization lib
+template<class Archive>
+void load(Archive & ar, gregorian::greg_year& gy, unsigned int /*version*/)
+{
+ unsigned short us;
+ ar & make_nvp("greg_year", us);
+ gy = gregorian::greg_year(us);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & ar, gregorian::greg_year* gy,
+ const unsigned int /*file_version*/)
+{
+ ::new(gy) gregorian::greg_year(1900);
+}
+
 /**** greg_month ****/
 
 //! Function to save gregorian::greg_month objects using serialization lib

Modified: branches/release/libs/date_time/test/gregorian/testgreg_serialize.cpp
==============================================================================
--- branches/release/libs/date_time/test/gregorian/testgreg_serialize.cpp (original)
+++ branches/release/libs/date_time/test/gregorian/testgreg_serialize.cpp 2012-07-15 12:49:32 EDT (Sun, 15 Jul 2012)
@@ -43,6 +43,7 @@
   date_duration dd(11);
   date_duration sv_dd(neg_infin);
   date_period dp(d,dd);
+ greg_year gy(1959);
   greg_month gm(Feb);
   greg_day gd(14);
   greg_weekday gwd(Friday);
@@ -62,6 +63,7 @@
     save_to(oa, BOOST_SERIALIZATION_NVP(dd));
     save_to(oa, BOOST_SERIALIZATION_NVP(sv_dd));
     save_to(oa, BOOST_SERIALIZATION_NVP(dp));
+ save_to(oa, BOOST_SERIALIZATION_NVP(gy));
     save_to(oa, BOOST_SERIALIZATION_NVP(gm));
     save_to(oa, BOOST_SERIALIZATION_NVP(gd));
     save_to(oa, BOOST_SERIALIZATION_NVP(gwd));
@@ -78,6 +80,7 @@
     save_to(oa, dd);
     save_to(oa, sv_dd);
     save_to(oa, dp);
+ save_to(oa, gy);
     save_to(oa, gm);
     save_to(oa, gd);
     save_to(oa, gwd);
@@ -108,6 +111,7 @@
   date_duration dd2(not_a_date_time);
   date_duration sv_dd2(0);
   date_period dp2(date(2000,Jan,1),date_duration(1));
+ greg_year gy2(1960);
   greg_month gm2(Jan);
   greg_day gd2(1);
   greg_weekday gwd2(Monday);
@@ -126,6 +130,7 @@
     ia >> BOOST_SERIALIZATION_NVP(dd2);
     ia >> BOOST_SERIALIZATION_NVP(sv_dd2);
     ia >> BOOST_SERIALIZATION_NVP(dp2);
+ ia >> BOOST_SERIALIZATION_NVP(gy2);
     ia >> BOOST_SERIALIZATION_NVP(gm2);
     ia >> BOOST_SERIALIZATION_NVP(gd2);
     ia >> BOOST_SERIALIZATION_NVP(gwd2);
@@ -142,6 +147,7 @@
     ia >> dd2;
     ia >> sv_dd2;
     ia >> dp2;
+ ia >> gy2;
     ia >> gm2;
     ia >> gd2;
     ia >> gwd2;
@@ -164,6 +170,7 @@
   check("date_duration", dd == dd2);
   check("special_value date_duration (neg_infin)", sv_dd == sv_dd2);
   check("date_period", dp == dp2);
+ check("greg_year", gy == gy2);
   check("greg_month", gm == gm2);
   check("greg_day", gd == gd2);
   check("greg_weekday", gwd == gwd2);


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk