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 {
    // Write support for earlier versions allows for upgrade compatibility testing
    // See load comments for version information
    if (version == 0) {
        save_td<int32_t>(ar, td);
    } else {
        save_td<int64_t>(ar, td);
    }
  }
}
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 {
    typename posix_time::time_duration::hour_type h = td.hours();
    typename posix_time::time_duration::min_type m = td.minutes();
    typename posix_time::time_duration::sec_type s = td.seconds();
    typename 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);
  }
}
Example #3
0
 /*!
  * Creates a rotation time interval of the specified duration
  *
  * \param interval The interval of the rotation, should be no less than 1 second
  */
 explicit rotation_at_time_interval(posix_time::time_duration const& interval) :
     m_Interval(interval)
 {
     BOOST_ASSERT(!interval.is_special());
     BOOST_ASSERT(interval.total_seconds() > 0);
 }