boost如何序列化 和反序列化 指针类(本身类也可以)

今天找了很长时间如何序列化和反序列化自己类,但是找了很多帖子都没有序列化自己指针类的例子。最后我发现boost对于指针的序列化和反序列化处理不好。于是我自己想办法解决如何序列化指针类。序列化指针类的真正原理都是直接序列化数据本身。把指针转换成数值。不多说了 直接上代码,希望能帮助其他朋友

class FPDF_BOOKMARKNODE {
public:


FPDF_BOOKMARKNODE() :firstChild(nullptr), nextSibling(nullptr)  {}
FPDF_BOOKMARKNODE(const std::wstring &title, const int &ipage) :wtitle(title), page(ipage),
firstChild(nullptr), nextSibling(nullptr) {}




FPDF_BOOKMARKNODE(FPDF_BOOKMARKNODE &&other) : wtitle(other.wtitle), page(other.page), firstChild(std::move(other.firstChild)),
nextSibling(std::move(other.nextSibling)) {
}


FPDF_BOOKMARKNODE &operator=(FPDF_BOOKMARKNODE*rhs) {
if (this != rhs) {
wtitle = rhs->wtitle;
page = rhs->page;
firstChild = std::move(rhs->firstChild);
nextSibling = std::move(rhs->nextSibling);
rhs->firstChild = rhs->nextSibling = nullptr;
}
return *this;
}


~FPDF_BOOKMARKNODE() {}


inline bool isHaveChile()  { return firstChild == nullptr; }
inline bool isHaveNext()  { return nextSibling == nullptr; }
inline FPDF_BOOKMARKNODE *Child()   { return firstChild; }
inline FPDF_BOOKMARKNODE *Sibling()  { return nextSibling; }

</
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值