Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2004-10-24 20:25:49


OK, I have found an error and checked in a change that I believe will fix
this. Thanks for finding this.

Robert Ramey

"Russell Hind" <rh_gmane_at_[hidden]> wrote in message
news:cld60j$fmc$1_at_sea.gmane.org...
> Robert,
>
> test_class_info_load and test_class_info_save both passed for
> xml_archive but I have created a test (attached) which fails for version
> 0 xml archives. Can you try this please?
>
> It creates an object with version 0, writes it to an xml archive
> (currently hard-coded to drive c so I could check the output file
> easily), and then reads it back in.
>
> As mentioned before: when reading in the object, the version is passed
> in to serialize as 3, not 0 as it should be.
>
> For XML files: there is no version attribute for the object when the
> version is 0, so maybe this is the problem.
>
> Thanks
>
> Russell
>
> Robert Ramey wrote:
> > I rebuilt and reran the the tests "test_class_info_load" and
> > "test_class_info_save" which are explicitly designed to test this
> > functionality. I ran these test with XML archives. Do these tests pass
for
> > you? How is this situation different than yours? I updated the test
> > sliightly so that the class version jumps from 2 to 4 - skipping over 3
so
> > that a confusion between serialization library version and class version
> > wouldn't be overlooked.
> >
> > Robert Ramey
> >
> >
> >
> > "Russell Hind" <rh_gmane_at_[hidden]> wrote in message
> > news:clacr8$u01$1_at_sea.gmane.org...
> >
> >>Robert Ramey wrote:
> >>
> >>>There is a confusion here. Check the manual section titled "Class
> >>>Versioning"
> >>>
> >>>There should be something like:
> >>>
> >>>BOOST_CLASS_VERSION(Test_c, 99)
> >>>
> >>>in your code. I don't remember what the maximum class version might be
> >
> > but
> >
> >>>it could be small like 255 for binary archives.
> >>>
> >>
> >>I did ask about this in the previous e-mail. I thought non-primitive
> >>types were, by default, versioned, i.e. if no BOOST_CLASS_VERSION is
> >>specified, they have a version of 0. Is this not the case?
> >>
> >>Anyway, the code I posted still gives odd results if I set
> >>BOOST_CLASS_VERSION(Test_c, 0). Anything but 0 works, but zero gives
> >>the effects described previously, a 3 on the way back in, which is your
> >>archive version, not the class version.
> >>
> >>Again, specifying no version works for text archives (haven't checked
> >>binary) but not for XML.
> >>
> >>Thanks
> >>
> >>Russell
> >>
> >>_______________________________________________
> >>Unsubscribe & other changes:
> >
> > http://lists.boost.org/mailman/listinfo.cgi/boost
> >
> >
> >
> >
> > _______________________________________________
> > Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
> >
>

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

----
>
/////////1/////////2/////////3/////////4/////////5/////////6/////////7//////
///8
> // test_class_info_load.cpp: test implementation level trait
>
> // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
> // Use, modification and distribution is subject to the Boost Software
> // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
> // http://www.boost.org/LICENSE_1_0.txt)
>
> // test implementation level "object_class_info"
> // should pass compilation and execution
>
> #include <cstdio>
> #include <string>
> #include <fstream>
>
>
> #include <boost/static_assert.hpp>
> #include <boost/serialization/level.hpp>
> #include <boost/serialization/tracking.hpp>
> #include <boost/serialization/version.hpp>
> #include <boost/serialization/nvp.hpp>
>
> #include <boost/archive/tmpdir.hpp>
> #include <boost/preprocessor/stringize.hpp>
>
> #include <boost/archive/xml_iarchive.hpp>
> #include <boost/archive/xml_oarchive.hpp>
> #include "test_tools.hpp"
>
> class A
> {
> public:
> template <typename ArchiveT>
> void serialize(ArchiveT& ar, const unsigned int version)
> {
> if (ArchiveT::is_loading::value)
> {
> BOOST_CHECK(version == 0);
> }
> }
> };
>
> BOOST_CLASS_VERSION(A, 0)
>
> void in(const char *testfile, A& a)
> {
> {
> std::ofstream ofs(testfile);
> boost::archive::xml_oarchive xoa(ofs);
> xoa & BOOST_SERIALIZATION_NVP(a);
> }
>
> {
> std::ifstream ifs(testfile);
> boost::archive::xml_iarchive xia(ifs);
> xia & BOOST_SERIALIZATION_NVP(a);
> }
> }
>
> int
> test_main( int /* argc */, char* /* argv */[] )
> {
>     A a;
>     std::string filename;
>     filename += boost::archive::tmpdir();
>     filename += '/';
>     filename += BOOST_PP_STRINGIZE(testfile_);
>     filename += BOOST_PP_STRINGIZE(BOOST_ARCHIVE_TEST);
> //    in(filename.c_str(), a, b);
> in("c:\\test.xml", a);
>     return boost::exit_success;
> }
>
> // EOF
>
----------------------------------------------------------------------------
----
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk