|
Boost : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2004-10-21 10:40:06
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.
Robert Ramey
"Russell Hind" <rh_gmane_at_[hidden]> wrote in message
news:cl7tra$jqe$1_at_sea.gmane.org...
> Robert Ramey wrote:
> >
> > It certainly should - send me a code snippet. The package includes
tests of
> >
>
> If I change this to use text_i/o archive then it works fine, but with
> XML, m_Version is set to zero when writing, but set to 3 when reading
> (this is with latest trunk from just before branch for release yesterday
> morning). Also, if I provide a version number for the class of anything
> but 0 then it works find (e.g. 1) but 0 or no version lead to the
> ambiguity (running under borland bcc32 5.6.4)
>
> #include <fstream>
> #include <iostream>
> #include <boost/archive/xml_iarchive.hpp>
> #include <boost/archive/xml_oarchive.hpp>
>
> class Test_c
> {
> public:
> Test_c(void) : m_Version(99999999)
> {
> }
>
> template <typename ArchiveT>
> void serialize(ArchiveT& ar, const unsigned int version)
> {
> m_Version = version;
> }
>
> unsigned int m_Version;
> };
>
> int main(int argc, char** argv)
> {
> Test_c Test;
>
> {
> std::ofstream ofs("C:\\test.xml");
> boost::archive::xml_oarchive toa(ofs);
> toa & BOOST_SERIALIZATION_NVP(Test);
> std::cout << "Test version = " << Test.m_Version << std::endl;
> }
>
> {
> std::ifstream ifs("C:\\test.xml");
> boost::archive::xml_iarchive tia(ifs);
> tia & BOOST_SERIALIZATION_NVP(Test);
> std::cout << "Test version = " << Test.m_Version << std::endl;
> }
>
> return 0;
> }
>
> >
> > serialization traits determine whether or not a class is versioned.
Default
> > is for non primititve types to be versioned and the default version
number
> > is 0. The usage of version number when not necessary could be a
performance
> > issue so there is the option of setting serialization traits for any
type so
> > that versioning isn't done. For example, this is not done for STL
> > collections. Review the section of the documentation "serialization
traits"
> >
>
> Thanks, I will do.
>
> Cheers
>
> Russell
>
> _______________________________________________
> 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