简体   繁体   中英

How to save c++ object into a xml file and restore back?

如何将c ++对象保存到xml文件中并还原?

Boost.Serialization and libs11n can both do this. The libs11n manual (available here ) has an extensive comparison of the two.

As Tobias said, the C++ FAQ has good background information.

Boost的序列化库可能正在实现您正在寻找的许多功能。

Serialization is a complex topic which is probably too much for a simple answer on SO. Unfortunately with C++, you don't get it for free as in other languages.

See the C++ faq lite or boost for a start.

I don't know if any direct way of achieving this. You can write separate methods to serialize and de-seriealize methods in which individual data members of the object need to be written and extracted from the file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM