今天找了很长时间如何序列化和反序列化自己类,但是找了很多帖子都没有序列化自己指针类的例子。最后我发现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; }
</