Boost logo

Boost Users :

From: Jeshua Bratman (bratman_at_[hidden])
Date: 2007-08-09 15:11:57


Oliver Kania-3 wrote:
>
> int main(int argc, char* argv[])
> {
> //string filename("SerializeTest");
> CUBE_INFO* c = new CUBE_INFO();
> std::ofstream ofs("filename");
> //std::ofstream ofs("filename" );
> // save data to archive
> {
> boost::archive::text_oarchive oa( ofs );
> // write class instance to archive
> oa << ( c );
> // archive and stream closed when destructors are called
> }
> return 0;
> }
>

Hello,

I've been playing with this all day and I was confused about this very same
problem. Try serializing a const pointer. This sort of thing worked for me:

int main(int argc, char* argv[])
{
    //string filename("SerializeTest");
    CUBE_INFO* c = new CUBE_INFO();
    std::ofstream ofs("filename");
    //std::ofstream ofs("filename" );
    // save data to archive
    {
        boost::archive::text_oarchive oa( ofs );
        // write class instance to archive
        const CUBE_INFO* to_serialize = c;
        oa << ( *to_serialize );
        // archive and stream closed when destructors are called
    }
    return 0;
}

I'm not sure why yet, I'm looking into it right now. Hopefully that will
help though!

Jeshua Bratman

-- 
View this message in context: http://www.nabble.com/Subject%3A--Serialization--Why-is-it-not-possible-to-serialize-this-structure-through-a-pointer--tf4232218.html#a12061490
Sent from the Boost - Users mailing list archive at Nabble.com.

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