| 73 | /// Here we specialise the TypedData::load() method to correctly load the data produced by save(). |
| 74 | template<> |
| 75 | void DateTimeData::load( LoadContextPtr context ) |
| 76 | { |
| 77 | Data::load( context ); |
| 78 | const IndexedIO *container = context->rawContainer(); |
| 79 | |
| 80 | std::string t; |
| 81 | container->read( g_valueEntry, t ); |
| 82 | |
| 83 | try |
| 84 | { |
| 85 | writable() = boost::posix_time::from_iso_string( t ); |
| 86 | } |
| 87 | catch( const boost::bad_lexical_cast & ) |
| 88 | { |
| 89 | /// Do these checks here instead of first as they're likely to be the least-used cases. |
| 90 | if ( t == "not-a-date-time" ) |
| 91 | { |
| 92 | writable() = boost::posix_time::not_a_date_time; |
| 93 | } |
| 94 | else if ( t == "+infinity" ) |
| 95 | { |
| 96 | writable() = boost::posix_time::pos_infin; |
| 97 | } |
| 98 | else if ( t == "-infinity" ) |
| 99 | { |
| 100 | writable() = boost::posix_time::neg_infin; |
| 101 | } |
| 102 | else |
| 103 | { |
| 104 | throw; |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | template class TypedData< boost::posix_time::ptime >; |
| 110 |
nothing calls this directly
no test coverage detected