linuxx
linuxx

Reputation: 1527

boost c++ serialize/deserialize

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 way to do it?

Upvotes: 1

Views: 703

Answers (2)

Nim
Nim

Reputation: 33655

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></...>";
}

Upvotes: 0

Joel Falcou
Joel Falcou

Reputation: 6357

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

Upvotes: 1

Related Questions