开发者

boost c++ serialize/deserialize

开发者 https://www.devze.com 2023-03-05 07:17 出处:网络
Can someone give me an example of serialization/deseralization using the Boost library? I am working in c++/ubuntu 9.1

Can someone give me an example of serialization/deseralization using the Boost library? I am working in c++/ubuntu 9.1

I have the class

class x
{
public:
    x();

    std::string name;
    std::string surname;
};

How can I create XML <1.0...> id: <name>..<surname> using boost serialization? Or is there another开发者_Python百科 way to do it?


boost serialization will build its own XML schema which is not modifiable. Serialization is for serialization not reading/writing random XML.


boost is overkill for such a trivial example... I mean, all you need is

friend std::ostream& (std::ostream& str, x const & cData)
{
  return str << "<...><name>" << cData.name << "</name><surname>" << cData.surname << "</surname></...>";
}
0

精彩评论

暂无评论...
验证码 换一张
取 消