Hikyuu
StockWeight_serialization.h
浏览该文件的文档.
1 /*
2  * StockWeight.h
3  *
4  * Created on: 2013-5-1
5  * Author: fasiondog
6  */
7 
8 #ifndef STOCKWEIGHT_SERIALIZATION_H_
9 #define STOCKWEIGHT_SERIALIZATION_H_
10 
11 #include "../config.h"
12 #include "../StockWeight.h"
13 
14 #if HKU_SUPPORT_SERIALIZATION
15 #include <boost/serialization/nvp.hpp>
16 #include <boost/serialization/split_free.hpp>
17 #include <boost/serialization/vector.hpp>
18 
19 namespace boost {
20 namespace serialization {
21 template<class Archive>
22 void save(Archive & ar, const hku::StockWeight& record, unsigned int version) {
23  hku::hku_uint64 datetime = record.datetime().number();
24  hku::price_t countAsGift = record.countAsGift();
25  hku::price_t countForSell = record.countForSell();
26  hku::price_t priceForSell = record.priceForSell();
27  hku::price_t bonus = record.bonus();
28  hku::price_t increasement = record.increasement();
29  hku::price_t totalCount = record.totalCount();
30  hku::price_t freeCount = record.freeCount();
31  ar & BOOST_SERIALIZATION_NVP(datetime);
32  ar & BOOST_SERIALIZATION_NVP(countAsGift);
33  ar & BOOST_SERIALIZATION_NVP(countForSell);
34  ar & BOOST_SERIALIZATION_NVP(priceForSell);
35  ar & BOOST_SERIALIZATION_NVP(bonus);
36  ar & BOOST_SERIALIZATION_NVP(increasement);
37  ar & BOOST_SERIALIZATION_NVP(totalCount);
38  ar & BOOST_SERIALIZATION_NVP(freeCount);
39 }
40 
41 template<class Archive>
42 void load(Archive & ar, hku::StockWeight& record, unsigned int version) {
43  hku::hku_uint64 datetime;
44  hku::price_t countAsGift, countForSell, priceForSell, bonus;
45  hku::price_t increasement, totalCount, freeCount;
46  ar & BOOST_SERIALIZATION_NVP(datetime);
47  ar & BOOST_SERIALIZATION_NVP(countAsGift);
48  ar & BOOST_SERIALIZATION_NVP(countForSell);
49  ar & BOOST_SERIALIZATION_NVP(priceForSell);
50  ar & BOOST_SERIALIZATION_NVP(bonus);
51  ar & BOOST_SERIALIZATION_NVP(increasement);
52  ar & BOOST_SERIALIZATION_NVP(totalCount);
53  ar & BOOST_SERIALIZATION_NVP(freeCount);
54  record = hku::StockWeight(hku::Datetime(datetime), countAsGift,
55  countForSell, priceForSell, bonus, increasement,
56  totalCount, freeCount);
57 }
58 }} /* namespace boost::serailization */
59 
60 BOOST_SERIALIZATION_SPLIT_FREE(hku::StockWeight)
61 
62 #endif /* HKU_SUPPORT_SERIALIZATION */
63 
64 #endif /* STOCKWEIGHT_SERIALIZATION_H_ */
unsigned long long number() const
返回如YYYYMMDDhhmmss格式的数字,方便比较操作, Null<Datetime>()对应的 number 为 Null<unsigned long lo...
Definition: Datetime.cpp:71
price_t totalCount() const
总股本(万股)
Definition: StockWeight.h:50
Definition: Block_serialization.h:17
日期类型
Definition: Datetime.h:33
void load(Archive &ar, hku::Block &blk, unsigned int version)
Definition: Block_serialization.h:34
price_t countForSell() const
每10股配X股
Definition: StockWeight.h:38
price_t bonus() const
每10股红利
Definition: StockWeight.h:44
void save(Archive &ar, const hku::Block &blk, unsigned int version)
Definition: Block_serialization.h:20
double price_t
Definition: DataType.h:53
price_t increasement() const
每10股转增X股
Definition: StockWeight.h:47
price_t countAsGift() const
每10股送X股
Definition: StockWeight.h:35
权息数据结构
Definition: StockWeight.h:19
price_t freeCount() const
流通股(万股)
Definition: StockWeight.h:53
price_t priceForSell() const
配股价
Definition: StockWeight.h:41
unsigned long long hku_uint64
Definition: DataType.h:46
Datetime datetime() const
权息日期
Definition: StockWeight.h:32