|
Boost Users : |
Subject: Re: [Boost-users] Serialization of a complex data structure
From: Marco Meoni - Sbaush (sbaush_at_[hidden])
Date: 2010-04-30 04:38:43
Yes.
I did an example like this to learn how to serialize in the "classical"
way.
My problem is that i can't define a serialize method inside Container, but i
would serialize it anyway. How can i serialize the Example strut entirely?
Do you understand my problem?
On Fri, Apr 30, 2010 at 3:49 AM, Robert Ramey <ramey_at_[hidden]> wrote:
> Marco Meoni - Sbaush wrote:
> > Can someone help me?
> > Robert, where can I find what you're talking about?
>
> I don't know what you're trying to do so I'll take a guess.
>
> Does this look like what you want to do?
>
> struct Container {
> int m_container_member;
> ... // more members
> template<class Archive>
> void serialize(Archive & ar, const unsigned int version){
> ar & m_container_member;
> ... // more members
> }
> };
>
> struct Example {
> friend class boost::serialization::access; // not really necessary as
> all "struct" members are public
> template<class Archive>
> void serialize(Archive & ar, const unsigned int version){
> ar & m_container;
> }
> };
>
> int main(int argc, char * argv[]){
> const Container c = ...
> std::fostream os("filename");
> boost::serialization::archive ar(os);
> ar & c;
> }
>
> Does that help any?
>
> Robert Ramey
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
-- Marco Meoni - Sbaush www.marcomeoni.net
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net