summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2013-09-07 14:28:58 (GMT)
committerKevin Smith <git@kismith.co.uk>2013-09-07 14:30:01 (GMT)
commitc485baf2315b67fc545621b0b041cd9cee3b9d3e (patch)
tree2f5a511d95b887b3f4ee281590f1ce6652e97eae /3rdParty/Boost/src/boost
parent6f6df1064446bc3a0a71925c68488b03b6888176 (diff)
downloadswift-c485baf2315b67fc545621b0b041cd9cee3b9d3e.zip
swift-c485baf2315b67fc545621b0b041cd9cee3b9d3e.tar.bz2
Add boost::serialization for posix_time.
Change-Id: Ie6acca254457933d891654cd0d29459e4c733270
Diffstat (limited to '3rdParty/Boost/src/boost')
-rw-r--r--3rdParty/Boost/src/boost/date_time/gregorian/greg_serialize.hpp517
-rw-r--r--3rdParty/Boost/src/boost/date_time/posix_time/time_serialize.hpp201
2 files changed, 718 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/boost/date_time/gregorian/greg_serialize.hpp b/3rdParty/Boost/src/boost/date_time/gregorian/greg_serialize.hpp
new file mode 100644
index 0000000..2cfad93
--- /dev/null
+++ b/3rdParty/Boost/src/boost/date_time/gregorian/greg_serialize.hpp
@@ -0,0 +1,517 @@
+#ifndef GREGORIAN_SERIALIZE_HPP___
+#define GREGORIAN_SERIALIZE_HPP___
+
+/* Copyright (c) 2004-2005 CrystalClear Software, Inc.
+ * Use, modification and distribution is subject to the
+ * Boost Software License, Version 1.0. (See accompanying
+ * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2012-09-30 16:25:22 -0700 (Sun, 30 Sep 2012) $
+ */
+
+#include "boost/date_time/gregorian/gregorian_types.hpp"
+#include "boost/date_time/gregorian/parsers.hpp"
+#include "boost/serialization/split_free.hpp"
+#include "boost/serialization/nvp.hpp"
+
+
+// macros to split serialize functions into save & load functions
+// An expanded version is below for gregorian::date
+// NOTE: these macros define template functions in the boost::serialization namespace.
+// They must be expanded *outside* of any namespace
+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)
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::partial_date)
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::nth_kday_of_month)
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::first_kday_of_month)
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::last_kday_of_month)
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::first_kday_before)
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::first_kday_after)
+
+namespace boost {
+namespace serialization {
+
+/*! Method that does serialization for gregorian::date -- splits to load/save
+ */
+template<class Archive>
+inline void serialize(Archive & ar,
+ ::boost::gregorian::date & d,
+ const unsigned int file_version)
+{
+ split_free(ar, d, file_version);
+}
+
+//! Function to save gregorian::date objects using serialization lib
+/*! Dates are serialized into a string for transport and storage.
+ * While it would be more efficient to store the internal
+ * integer used to manipulate the dates, it is an unstable solution.
+ */
+template<class Archive>
+void save(Archive & ar,
+ const ::boost::gregorian::date & d,
+ unsigned int /* version */)
+{
+ std::string ds = to_iso_string(d);
+ ar & make_nvp("date", ds);
+}
+
+//! Function to load gregorian::date objects using serialization lib
+/*! Dates are serialized into a string for transport and storage.
+ * While it would be more efficient to store the internal
+ * integer used to manipulate the dates, it is an unstable solution.
+ */
+template<class Archive>
+void load(Archive & ar,
+ ::boost::gregorian::date & d,
+ unsigned int /*version*/)
+{
+ std::string ds;
+ ar & make_nvp("date", ds);
+ try{
+ d = ::boost::gregorian::from_undelimited_string(ds);
+ }catch(bad_lexical_cast&) {
+ gregorian::special_values sv = gregorian::special_value_from_string(ds);
+ if(sv == gregorian::not_special) {
+ throw; // no match found, rethrow original exception
+ }
+ else {
+ d = gregorian::date(sv);
+ }
+ }
+}
+
+
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & /*ar*/,
+ ::boost::gregorian::date* dp,
+ const unsigned int /*file_version*/)
+{
+ // retrieve data from archive required to construct new
+ // invoke inplace constructor to initialize instance of date
+ ::new(dp) ::boost::gregorian::date(::boost::gregorian::not_a_date_time);
+}
+
+/**** date_duration ****/
+
+//! Function to save gregorian::date_duration objects using serialization lib
+template<class Archive>
+void save(Archive & ar, const gregorian::date_duration & dd,
+ unsigned int /*version*/)
+{
+ typename gregorian::date_duration::duration_rep dr = dd.get_rep();
+ ar & make_nvp("date_duration", dr);
+}
+//! Function to load gregorian::date_duration objects using serialization lib
+template<class Archive>
+void load(Archive & ar, gregorian::date_duration & dd, unsigned int /*version*/)
+{
+ typename gregorian::date_duration::duration_rep dr(0);
+ ar & make_nvp("date_duration", dr);
+ dd = gregorian::date_duration(dr);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & /*ar*/, gregorian::date_duration* dd,
+ const unsigned int /*file_version*/)
+{
+ ::new(dd) gregorian::date_duration(gregorian::not_a_date_time);
+}
+
+/**** date_duration::duration_rep (most likely int_adapter) ****/
+
+//! helper unction to save date_duration objects using serialization lib
+template<class Archive>
+void save(Archive & ar, const gregorian::date_duration::duration_rep & dr,
+ unsigned int /*version*/)
+{
+ typename gregorian::date_duration::duration_rep::int_type it = dr.as_number();
+ ar & make_nvp("date_duration_duration_rep", it);
+}
+//! helper function to load date_duration objects using serialization lib
+template<class Archive>
+void load(Archive & ar, gregorian::date_duration::duration_rep & dr, unsigned int /*version*/)
+{
+ typename gregorian::date_duration::duration_rep::int_type it(0);
+ ar & make_nvp("date_duration_duration_rep", it);
+ dr = gregorian::date_duration::duration_rep::int_type(it);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & /*ar*/, gregorian::date_duration::duration_rep* dr,
+ const unsigned int /*file_version*/)
+{
+ ::new(dr) gregorian::date_duration::duration_rep(0);
+}
+
+/**** date_period ****/
+
+//! Function to save gregorian::date_period objects using serialization lib
+/*! date_period objects are broken down into 2 parts for serialization:
+ * the begining date object and the end date object
+ */
+template<class Archive>
+void save(Archive & ar, const gregorian::date_period& dp,
+ unsigned int /*version*/)
+{
+ gregorian::date d1 = dp.begin();
+ gregorian::date d2 = dp.end();
+ ar & make_nvp("date_period_begin_date", d1);
+ ar & make_nvp("date_period_end_date", d2);
+}
+//! Function to load gregorian::date_period objects using serialization lib
+/*! date_period objects are broken down into 2 parts for serialization:
+ * the begining date object and the end date object
+ */
+template<class Archive>
+void load(Archive & ar, gregorian::date_period& dp, unsigned int /*version*/)
+{
+ gregorian::date d1(gregorian::not_a_date_time);
+ gregorian::date d2(gregorian::not_a_date_time);
+ ar & make_nvp("date_period_begin_date", d1);
+ ar & make_nvp("date_period_end_date", d2);
+ dp = gregorian::date_period(d1,d2);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & /*ar*/, gregorian::date_period* dp,
+ const unsigned int /*file_version*/)
+{
+ gregorian::date d(gregorian::not_a_date_time);
+ gregorian::date_duration dd(1);
+ ::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
+template<class Archive>
+void save(Archive & ar, const gregorian::greg_month& gm,
+ unsigned int /*version*/)
+{
+ unsigned short us = gm.as_number();
+ ar & make_nvp("greg_month", us);
+}
+//! Function to load gregorian::greg_month objects using serialization lib
+template<class Archive>
+void load(Archive & ar, gregorian::greg_month& gm, unsigned int /*version*/)
+{
+ unsigned short us;
+ ar & make_nvp("greg_month", us);
+ gm = gregorian::greg_month(us);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & /*ar*/, gregorian::greg_month* gm,
+ const unsigned int /*file_version*/)
+{
+ ::new(gm) gregorian::greg_month(1);
+}
+
+/**** greg_day ****/
+
+//! Function to save gregorian::greg_day objects using serialization lib
+template<class Archive>
+void save(Archive & ar, const gregorian::greg_day& gd,
+ unsigned int /*version*/)
+{
+ unsigned short us = gd.as_number();
+ ar & make_nvp("greg_day", us);
+}
+//! Function to load gregorian::greg_day objects using serialization lib
+template<class Archive>
+void load(Archive & ar, gregorian::greg_day& gd, unsigned int /*version*/)
+{
+ unsigned short us;
+ ar & make_nvp("greg_day", us);
+ gd = gregorian::greg_day(us);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & /*ar*/, gregorian::greg_day* gd,
+ const unsigned int /*file_version*/)
+{
+ ::new(gd) gregorian::greg_day(1);
+}
+
+/**** greg_weekday ****/
+
+//! Function to save gregorian::greg_weekday objects using serialization lib
+template<class Archive>
+void save(Archive & ar, const gregorian::greg_weekday& gd,
+ unsigned int /*version*/)
+{
+ unsigned short us = gd.as_number();
+ ar & make_nvp("greg_weekday", us);
+}
+//! Function to load gregorian::greg_weekday objects using serialization lib
+template<class Archive>
+void load(Archive & ar, gregorian::greg_weekday& gd, unsigned int /*version*/)
+{
+ unsigned short us;
+ ar & make_nvp("greg_weekday", us);
+ gd = gregorian::greg_weekday(us);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & /*ar*/, gregorian::greg_weekday* gd,
+ const unsigned int /*file_version*/)
+{
+ ::new(gd) gregorian::greg_weekday(1);
+}
+
+/**** date_generators ****/
+
+/**** partial_date ****/
+
+//! Function to save gregorian::partial_date objects using serialization lib
+/*! partial_date objects are broken down into 2 parts for serialization:
+ * the day (typically greg_day) and month (typically greg_month) objects
+ */
+template<class Archive>
+void save(Archive & ar, const gregorian::partial_date& pd,
+ unsigned int /*version*/)
+{
+ gregorian::greg_day gd(pd.day());
+ gregorian::greg_month gm(pd.month().as_number());
+ ar & make_nvp("partial_date_day", gd);
+ ar & make_nvp("partial_date_month", gm);
+}
+//! Function to load gregorian::partial_date objects using serialization lib
+/*! partial_date objects are broken down into 2 parts for serialization:
+ * the day (greg_day) and month (greg_month) objects
+ */
+template<class Archive>
+void load(Archive & ar, gregorian::partial_date& pd, unsigned int /*version*/)
+{
+ gregorian::greg_day gd(1);
+ gregorian::greg_month gm(1);
+ ar & make_nvp("partial_date_day", gd);
+ ar & make_nvp("partial_date_month", gm);
+ pd = gregorian::partial_date(gd,gm);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & /*ar*/, gregorian::partial_date* pd,
+ const unsigned int /*file_version*/)
+{
+ gregorian::greg_month gm(1);
+ gregorian::greg_day gd(1);
+ ::new(pd) gregorian::partial_date(gd,gm);
+}
+
+/**** nth_kday_of_month ****/
+
+//! Function to save nth_day_of_the_week_in_month objects using serialization lib
+/*! nth_day_of_the_week_in_month objects are broken down into 3 parts for
+ * serialization: the week number, the day of the week, and the month
+ */
+template<class Archive>
+void save(Archive & ar, const gregorian::nth_kday_of_month& nkd,
+ unsigned int /*version*/)
+{
+ typename gregorian::nth_kday_of_month::week_num wn(nkd.nth_week());
+ typename gregorian::nth_kday_of_month::day_of_week_type d(nkd.day_of_week().as_number());
+ typename gregorian::nth_kday_of_month::month_type m(nkd.month().as_number());
+ ar & make_nvp("nth_kday_of_month_week_num", wn);
+ ar & make_nvp("nth_kday_of_month_day_of_week", d);
+ ar & make_nvp("nth_kday_of_month_month", m);
+}
+//! Function to load nth_day_of_the_week_in_month objects using serialization lib
+/*! nth_day_of_the_week_in_month objects are broken down into 3 parts for
+ * serialization: the week number, the day of the week, and the month
+ */
+template<class Archive>
+void load(Archive & ar, gregorian::nth_kday_of_month& nkd, unsigned int /*version*/)
+{
+ typename gregorian::nth_kday_of_month::week_num wn(gregorian::nth_kday_of_month::first);
+ typename gregorian::nth_kday_of_month::day_of_week_type d(gregorian::Monday);
+ typename gregorian::nth_kday_of_month::month_type m(gregorian::Jan);
+ ar & make_nvp("nth_kday_of_month_week_num", wn);
+ ar & make_nvp("nth_kday_of_month_day_of_week", d);
+ ar & make_nvp("nth_kday_of_month_month", m);
+
+ nkd = gregorian::nth_kday_of_month(wn,d,m);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & /*ar*/,
+ gregorian::nth_kday_of_month* nkd,
+ const unsigned int /*file_version*/)
+{
+ // values used are not significant
+ ::new(nkd) gregorian::nth_kday_of_month(gregorian::nth_kday_of_month::first,
+ gregorian::Monday,gregorian::Jan);
+}
+
+/**** first_kday_of_month ****/
+
+//! Function to save first_day_of_the_week_in_month objects using serialization lib
+/*! first_day_of_the_week_in_month objects are broken down into 2 parts for
+ * serialization: the day of the week, and the month
+ */
+template<class Archive>
+void save(Archive & ar, const gregorian::first_kday_of_month& fkd,
+ unsigned int /*version*/)
+{
+ typename gregorian::first_kday_of_month::day_of_week_type d(fkd.day_of_week().as_number());
+ typename gregorian::first_kday_of_month::month_type m(fkd.month().as_number());
+ ar & make_nvp("first_kday_of_month_day_of_week", d);
+ ar & make_nvp("first_kday_of_month_month", m);
+}
+//! Function to load first_day_of_the_week_in_month objects using serialization lib
+/*! first_day_of_the_week_in_month objects are broken down into 2 parts for
+ * serialization: the day of the week, and the month
+ */
+template<class Archive>
+void load(Archive & ar, gregorian::first_kday_of_month& fkd, unsigned int /*version*/)
+{
+ typename gregorian::first_kday_of_month::day_of_week_type d(gregorian::Monday);
+ typename gregorian::first_kday_of_month::month_type m(gregorian::Jan);
+ ar & make_nvp("first_kday_of_month_day_of_week", d);
+ ar & make_nvp("first_kday_of_month_month", m);
+
+ fkd = gregorian::first_kday_of_month(d,m);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & /*ar*/,
+ gregorian::first_kday_of_month* fkd,
+ const unsigned int /*file_version*/)
+{
+ // values used are not significant
+ ::new(fkd) gregorian::first_kday_of_month(gregorian::Monday,gregorian::Jan);
+}
+
+/**** last_kday_of_month ****/
+
+//! Function to save last_day_of_the_week_in_month objects using serialization lib
+/*! last_day_of_the_week_in_month objects are broken down into 2 parts for
+ * serialization: the day of the week, and the month
+ */
+template<class Archive>
+void save(Archive & ar, const gregorian::last_kday_of_month& lkd,
+ unsigned int /*version*/)
+{
+ typename gregorian::last_kday_of_month::day_of_week_type d(lkd.day_of_week().as_number());
+ typename gregorian::last_kday_of_month::month_type m(lkd.month().as_number());
+ ar & make_nvp("last_kday_of_month_day_of_week", d);
+ ar & make_nvp("last_kday_of_month_month", m);
+}
+//! Function to load last_day_of_the_week_in_month objects using serialization lib
+/*! last_day_of_the_week_in_month objects are broken down into 2 parts for
+ * serialization: the day of the week, and the month
+ */
+template<class Archive>
+void load(Archive & ar, gregorian::last_kday_of_month& lkd, unsigned int /*version*/)
+{
+ typename gregorian::last_kday_of_month::day_of_week_type d(gregorian::Monday);
+ typename gregorian::last_kday_of_month::month_type m(gregorian::Jan);
+ ar & make_nvp("last_kday_of_month_day_of_week", d);
+ ar & make_nvp("last_kday_of_month_month", m);
+
+ lkd = gregorian::last_kday_of_month(d,m);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & /*ar*/,
+ gregorian::last_kday_of_month* lkd,
+ const unsigned int /*file_version*/)
+{
+ // values used are not significant
+ ::new(lkd) gregorian::last_kday_of_month(gregorian::Monday,gregorian::Jan);
+}
+
+/**** first_kday_before ****/
+
+//! Function to save first_day_of_the_week_before objects using serialization lib
+template<class Archive>
+void save(Archive & ar, const gregorian::first_kday_before& fkdb,
+ unsigned int /*version*/)
+{
+ typename gregorian::first_kday_before::day_of_week_type d(fkdb.day_of_week().as_number());
+ ar & make_nvp("first_kday_before_day_of_week", d);
+}
+//! Function to load first_day_of_the_week_before objects using serialization lib
+template<class Archive>
+void load(Archive & ar, gregorian::first_kday_before& fkdb, unsigned int /*version*/)
+{
+ typename gregorian::first_kday_before::day_of_week_type d(gregorian::Monday);
+ ar & make_nvp("first_kday_before_day_of_week", d);
+
+ fkdb = gregorian::first_kday_before(d);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & /*ar*/,
+ gregorian::first_kday_before* fkdb,
+ const unsigned int /*file_version*/)
+{
+ // values used are not significant
+ ::new(fkdb) gregorian::first_kday_before(gregorian::Monday);
+}
+
+/**** first_kday_after ****/
+
+//! Function to save first_day_of_the_week_after objects using serialization lib
+template<class Archive>
+void save(Archive & ar, const gregorian::first_kday_after& fkda,
+ unsigned int /*version*/)
+{
+ typename gregorian::first_kday_after::day_of_week_type d(fkda.day_of_week().as_number());
+ ar & make_nvp("first_kday_after_day_of_week", d);
+}
+//! Function to load first_day_of_the_week_after objects using serialization lib
+template<class Archive>
+void load(Archive & ar, gregorian::first_kday_after& fkda, unsigned int /*version*/)
+{
+ typename gregorian::first_kday_after::day_of_week_type d(gregorian::Monday);
+ ar & make_nvp("first_kday_after_day_of_week", d);
+
+ fkda = gregorian::first_kday_after(d);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & /*ar*/,
+ gregorian::first_kday_after* fkda,
+ const unsigned int /*file_version*/)
+{
+ // values used are not significant
+ ::new(fkda) gregorian::first_kday_after(gregorian::Monday);
+}
+
+} // namespace serialization
+} // namespace boost
+
+#endif
diff --git a/3rdParty/Boost/src/boost/date_time/posix_time/time_serialize.hpp b/3rdParty/Boost/src/boost/date_time/posix_time/time_serialize.hpp
new file mode 100644
index 0000000..c9038f1
--- /dev/null
+++ b/3rdParty/Boost/src/boost/date_time/posix_time/time_serialize.hpp
@@ -0,0 +1,201 @@
+#ifndef POSIX_TIME_SERIALIZE_HPP___
+#define POSIX_TIME_SERIALIZE_HPP___
+
+/* Copyright (c) 2004-2005 CrystalClear Software, Inc.
+ * Use, modification and distribution is subject to the
+ * Boost Software License, Version 1.0. (See accompanying
+ * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2012-09-30 16:25:22 -0700 (Sun, 30 Sep 2012) $
+ */
+
+#include "boost/date_time/posix_time/posix_time.hpp"
+#include "boost/date_time/gregorian/greg_serialize.hpp"
+#include "boost/serialization/split_free.hpp"
+#include "boost/serialization/nvp.hpp"
+
+
+// macros to split serialize functions into save & load functions
+// NOTE: these macros define template functions in the boost::serialization namespace.
+// They must be expanded *outside* of any namespace
+BOOST_SERIALIZATION_SPLIT_FREE(boost::posix_time::ptime)
+BOOST_SERIALIZATION_SPLIT_FREE(boost::posix_time::time_duration)
+BOOST_SERIALIZATION_SPLIT_FREE(boost::posix_time::time_period)
+
+namespace boost {
+namespace serialization {
+
+
+/*** time_duration ***/
+
+//! Function to save posix_time::time_duration objects using serialization lib
+/*! time_duration objects are broken down into 4 parts for serialization:
+ * types are hour_type, min_type, sec_type, and fractional_seconds_type
+ * as defined in the time_duration class
+ */
+template<class Archive>
+void save(Archive & ar,
+ const posix_time::time_duration& td,
+ unsigned int /*version*/)
+{
+ // serialize a bool so we know how to read this back in later
+ bool is_special = td.is_special();
+ ar & make_nvp("is_special", is_special);
+ if(is_special) {
+ std::string s = to_simple_string(td);
+ ar & make_nvp("sv_time_duration", s);
+ }
+ else {
+ posix_time::time_duration::hour_type h = td.hours();
+ posix_time::time_duration::min_type m = td.minutes();
+ posix_time::time_duration::sec_type s = td.seconds();
+ posix_time::time_duration::fractional_seconds_type fs = td.fractional_seconds();
+ ar & make_nvp("time_duration_hours", h);
+ ar & make_nvp("time_duration_minutes", m);
+ ar & make_nvp("time_duration_seconds", s);
+ ar & make_nvp("time_duration_fractional_seconds", fs);
+ }
+}
+
+//! Function to load posix_time::time_duration objects using serialization lib
+/*! time_duration objects are broken down into 4 parts for serialization:
+ * types are hour_type, min_type, sec_type, and fractional_seconds_type
+ * as defined in the time_duration class
+ */
+template<class Archive>
+void load(Archive & ar,
+ posix_time::time_duration & td,
+ unsigned int /*version*/)
+{
+ bool is_special = false;
+ ar & make_nvp("is_special", is_special);
+ if(is_special) {
+ std::string s;
+ ar & make_nvp("sv_time_duration", s);
+ posix_time::special_values sv = gregorian::special_value_from_string(s);
+ td = posix_time::time_duration(sv);
+ }
+ else {
+ posix_time::time_duration::hour_type h(0);
+ posix_time::time_duration::min_type m(0);
+ posix_time::time_duration::sec_type s(0);
+ posix_time::time_duration::fractional_seconds_type fs(0);
+ ar & make_nvp("time_duration_hours", h);
+ ar & make_nvp("time_duration_minutes", m);
+ ar & make_nvp("time_duration_seconds", s);
+ ar & make_nvp("time_duration_fractional_seconds", fs);
+ td = posix_time::time_duration(h,m,s,fs);
+ }
+}
+
+// no load_construct_data function provided as time_duration provides a
+// default constructor
+
+/*** ptime ***/
+
+//! Function to save posix_time::ptime objects using serialization lib
+/*! ptime objects are broken down into 2 parts for serialization:
+ * a date object and a time_duration onject
+ */
+template<class Archive>
+void save(Archive & ar,
+ const posix_time::ptime& pt,
+ unsigned int /*version*/)
+{
+ // from_iso_string does not include fractional seconds
+ // therefore date and time_duration are used
+ posix_time::ptime::date_type d = pt.date();
+ ar & make_nvp("ptime_date", d);
+ if(!pt.is_special()) {
+ posix_time::ptime::time_duration_type td = pt.time_of_day();
+ ar & make_nvp("ptime_time_duration", td);
+ }
+}
+
+//! Function to load posix_time::ptime objects using serialization lib
+/*! ptime objects are broken down into 2 parts for serialization:
+ * a date object and a time_duration onject
+ */
+template<class Archive>
+void load(Archive & ar,
+ posix_time::ptime & pt,
+ unsigned int /*version*/)
+{
+ // from_iso_string does not include fractional seconds
+ // therefore date and time_duration are used
+ posix_time::ptime::date_type d(posix_time::not_a_date_time);
+ posix_time::ptime::time_duration_type td;
+ ar & make_nvp("ptime_date", d);
+ if(!d.is_special()) {
+ ar & make_nvp("ptime_time_duration", td);
+ pt = boost::posix_time::ptime(d,td);
+ }
+ else {
+ pt = boost::posix_time::ptime(d.as_special());
+ }
+
+}
+
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & /*ar*/,
+ posix_time::ptime* pt,
+ const unsigned int /*file_version*/)
+{
+ // retrieve data from archive required to construct new
+ // invoke inplace constructor to initialize instance of date
+ new(pt) boost::posix_time::ptime(boost::posix_time::not_a_date_time);
+}
+
+/*** time_period ***/
+
+//! Function to save posix_time::time_period objects using serialization lib
+/*! time_period objects are broken down into 2 parts for serialization:
+ * a begining ptime object and an ending ptime object
+ */
+template<class Archive>
+void save(Archive & ar,
+ const posix_time::time_period& tp,
+ unsigned int /*version*/)
+{
+ posix_time::ptime beg(tp.begin().date(), tp.begin().time_of_day());
+ posix_time::ptime end(tp.end().date(), tp.end().time_of_day());
+ ar & make_nvp("time_period_begin", beg);
+ ar & make_nvp("time_period_end", end);
+}
+
+//! Function to load posix_time::time_period objects using serialization lib
+/*! time_period objects are broken down into 2 parts for serialization:
+ * a begining ptime object and an ending ptime object
+ */
+template<class Archive>
+void load(Archive & ar,
+ boost::posix_time::time_period & tp,
+ unsigned int /*version*/)
+{
+ posix_time::time_duration td(1,0,0);
+ gregorian::date d(gregorian::not_a_date_time);
+ posix_time::ptime beg(d,td);
+ posix_time::ptime end(d,td);
+ ar & make_nvp("time_period_begin", beg);
+ ar & make_nvp("time_period_end", end);
+ tp = boost::posix_time::time_period(beg, end);
+}
+
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & /*ar*/,
+ boost::posix_time::time_period* tp,
+ const unsigned int /*file_version*/)
+{
+ posix_time::time_duration td(1,0,0);
+ gregorian::date d(gregorian::not_a_date_time);
+ posix_time::ptime beg(d,td);
+ posix_time::ptime end(d,td);
+ new(tp) boost::posix_time::time_period(beg,end);
+}
+
+} // namespace serialization
+} // namespace boost
+
+#endif