-
Notifications
You must be signed in to change notification settings - Fork 557
/
Datetime_serialization.h
40 lines (32 loc) · 954 Bytes
/
Datetime_serialization.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* Datetime_Serialization.h
*
* Created on: 2013-4-29
* Author: fasiondog
*/
#pragma once
#ifndef DATETIME_SERIALIZATION_H_
#define DATETIME_SERIALIZATION_H_
#include "../datetime/Datetime.h"
#include "../config.h"
#if HKU_SUPPORT_SERIALIZATION
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/split_free.hpp>
namespace boost {
namespace serialization {
template <class Archive>
void save(Archive& ar, const hku::Datetime& date, unsigned int version) {
std::string datetime = date.str();
ar& BOOST_SERIALIZATION_NVP(datetime);
}
template <class Archive>
void load(Archive& ar, hku::Datetime& date, unsigned int version) {
std::string datetime;
ar& BOOST_SERIALIZATION_NVP(datetime);
date = hku::Datetime(datetime);
}
} // namespace serialization
} // namespace boost
BOOST_SERIALIZATION_SPLIT_FREE(hku::Datetime)
#endif /* HKU_SUPPORT_SERIALIZATION */
#endif /* DATETIME_SERIALIZATION_H_ */