0
我需要序列化我自己的方法std :: wstring。 如何強制推動使用我的序列化方法,而不是默認方法? 謝謝。boost.serialization並替換現有的序列化方法std :: wstring
我需要序列化我自己的方法std :: wstring。 如何強制推動使用我的序列化方法,而不是默認方法? 謝謝。boost.serialization並替換現有的序列化方法std :: wstring
未經檢驗的,但你要專門的boost ::系列化::歸檔爲您的數據類型:
namespace boost { namespace serialization { template<class Archive> void serialize(Archive & ar, std::wstring& s, const unsigned int version) { for (std::wstring::iterator it = s.begin(); it != s.end(); ++it) ar >> *it } } // namespace serialization } // namespace boost
此代碼應的基本工作原理爲,是,你只是想改變的內容序列化功能(但不簽名。)的
爲什麼你要以其他任何方式序列化的wstring不僅僅是打印它(即只用正常輸入輸出流),我不知道。
有什麼想法? 測試代碼在這裏:http://liveworkspace.org/code/5f8a62c02c8cf96a909666ad8b40a6e5 – niXman 2010-12-26 10:04:16