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

后端 未结 4 744
臣服心动
臣服心动 2020-12-19 12:50

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

相关标签:
4条回答
  • 2020-12-19 13:30

    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.

    0 讨论(0)
  • 2020-12-19 13:35

    Boost's serialization library might be implementing a lot of the functionality you are looking for.

    0 讨论(0)
  • 2020-12-19 13:38

    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.

    0 讨论(0)
  • 2020-12-19 13:40

    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.

    0 讨论(0)
提交回复
热议问题