void TypedData< TimePeriod >::save( SaveContext *context ) const { Data::save( context ); IndexedIOPtr container = context->container( staticTypeName(), 0 ); container->write( g_beginEntry, boost::posix_time::to_iso_string( readable().begin() ) ); container->write( g_endEntry, boost::posix_time::to_iso_string( readable().end() ) ); }
void TypedData< TimePeriod >::load( LoadContextPtr context ) { Data::load( context ); unsigned int v = 0; ConstIndexedIOPtr container = context->container( staticTypeName(), v ); std::string beginStr; container->read( g_beginEntry, beginStr ); boost::posix_time::ptime begin; try { begin = boost::posix_time::from_iso_string( beginStr ); } catch ( boost::bad_lexical_cast ) { /// Do these checks here instead of first as they're likely to be the least-used cases. if ( beginStr == "not-a-date-time" ) { begin = boost::posix_time::not_a_date_time; } else if ( beginStr == "+infinity" ) { begin = boost::posix_time::pos_infin; } else if ( beginStr == "-infinity" ) { begin = boost::posix_time::neg_infin; } else { throw; } } std::string endStr; container->read( g_endEntry, endStr ); boost::posix_time::ptime end; try { end = boost::posix_time::from_iso_string( endStr ); } catch ( boost::bad_lexical_cast ) { /// Do these checks here instead of first as they're likely to be the least-used cases. if ( endStr == "not-a-date-time" ) { end = boost::posix_time::not_a_date_time; } else if ( endStr == "+infinity" ) { end = boost::posix_time::pos_infin; } else if ( endStr == "-infinity" ) { end = boost::posix_time::neg_infin; } else { throw; } } writable() = boost::posix_time::time_period( begin, end ); }
const char* Haste::getTypeName()const { return staticTypeName(); }
QString IqPostmanVideoContentType::typeName() const { return staticTypeName(); }