Boost logo

Boost Users :

Subject: Re: [Boost-users] stream error thrown in boost serialization
From: Robert Ramey (ramey_at_[hidden])
Date: 2009-01-13 11:32:46


without seeing anymore code, I can only guess.

My quess is that you're closing the stream before the archive destructor is called. Try the following:

main(){
    ofstream of("filename);
    {
        text_archve oa(of):
        oa << stuff;
    } // text_archive destructor called here - this finishes off the archive
} // ofstream destructor called here - this closes the stream

Robert Ramey
  "Lee MacDonald" <lee.macdonald_at_[hidden]> wrote in message news:F85AC698E27B0547A7AA4ACE8C18917C03D68153_at_[hidden]

        Guys,

        I'm having a bit of trouble with boost serialisation using boost 1.35

        I am writing out my objects to a text file fine. I see the text_oarchive destructor get called and I get the required new line added to the end of the file. However when I read the objects back in, they get created fine, but as the archive reaches the end of file, it throws a stream error. I have tested the example code and that works fine, so I'm stuck at the mo. Unfortunately i can't try writing/reading the objects as binary easily.

        I presume the archive is trying to read past the end of the stream, but I don't know why as the newline exists?

        I've tried the following to make sure the stream is good, but archive still throws.

        while(stream.good())
        {
            archive >> object;
        }

        Any help would be appreciated.

        Thanks.

        Lee MacDonald

       

        Schneider Trading
        4th Floor,
        25 Copthall Avenue
        London EC2R 7BP

------------------------------------------------------------------------

        Message from: lee.macdonald_at_[hidden]
        Message to: boost-users_at_[hidden]
        Attached files: 0

        This e-mail and any files transmitted with it are confidential, may be legally privileged, and are for the sole use of the intended recipient. Copyright in this e-mail and any accompanying document created by us is owned by us. If you are not the intended recipient of this e-mail or any part of it please telephone our IT Department at the number shown above or by e-mail at info_at_schneidertrading.com.

        You should not use or disclose to any other person the contents of this e-mail or its attachments (if any), nor take copies. This e-mail is not a representation or warranty and is not intended nor should it be taken to create any legal relations, contractual or otherwise.

        Schneider Trading Associates Ltd (Registration No. 3692131) is incorporated in England and Wales and the registered office is at 25 Copthall Avenue, London EC2R 7BP. The company is authorised and regulated by the Financial Services Authority

       

------------------------------------------------------------------------------

  _______________________________________________
  Boost-users mailing list
  Boost-users_at_[hidden]
  http://lists.boost.org/mailman/listinfo.cgi/boost-users



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