Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-09-27 11:56:20


Here are the changes I made. This makes it save but more changes would have to be made in order to load.

Robert Ramey
  "Pyush Agrawal" <pyush.agrawal_at_[hidden]> wrote in message news:f7a7f9d105092708436724b870_at_mail.gmail.com...
  Two Problems:

  Firstly---> I made the changes you had suggested and it did not work for me. The compilation fails with
  "C:\ai\src\external\boost133\boost\archive\basic_xml_oarchive.hpp(86): error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'". Do I have to define a name-value pair??

  If you're using an XML archive, you have to use nvp to assign a name tag to every datum.

  (Refer to my previous boost users mailing list posting).
  Is it possible for you to attach the cpp code that you compiled and tested (I just want to make sure that I am not doing something stupid).

  Secondly----> The output that you had attached just serializes the 'base' object and does not serialize the 'derived' object. I thought the result should have been serialized 'derived' object. Is my understanding wrong?

  Pyush

  "Robert Ramey" <ramey_at_[hidden]> wrote in message news:dhalo7$p1u$1_at_sea.gmane.org...
>I just changed
>
> template<class Archive, class T>
> inline void save(Archive& ar, derived<T>& obj, const unsigned int version)
> {
>
> to
> template<class Archive, class T>
> inline void save(Archive& ar, const nderived<T>& obj, const unsigned int
> version)
> {
>
> at line # 91,
>
> and I removed the l // from line #85
>
> compiled and ran with VC 7.1 Seemed to work find. the output was:
>
> ------ Build started: Project: test_zexp, Configuration: Debug
> runtime-dynamic text_archive Win32 ------
> Linking...
> Creating library
> c:\BoostMainCVS\libs\serialization\vc7ide\../../../bin/boost/libs/serialization/test/test_zexp_text_archive.test/vc-7_1/debug/threading-multi//test_zexp.lib
> and object
> c:\BoostMainCVS\libs\serialization\vc7ide\../../../bin/boost/libs/serialization/test/test_zexp_text_archive.test/vc-7_1/debug/threading-multi//test_zexp.exp
> run test_zexp with Debug runtime-dynamic text_archive
> base: Save
> derived<T>::Serialize
> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
> <!DOCTYPE boost_serialization>
> <boost_serialization signature="serialization::archive" version="3">
> <originalObject class_id="0" tracking_level="0" version="0">
> <temp>100</temp>
> </originalObject>
>
> which looks correct to me.
>
> Robert Ramey
>

  On 9/26/05, Pyush Agrawal <pyush.agrawal_at_[hidden]> wrote:
    I had tried putting 'const' in the save function header. The code compilation fails with "boost::STATIC_ASSERTION_FAILURE<x>" at the "save_override" function in "basic_xml_oarchive.hpp".

    I tried "BOOST_SERIALIZATION_BASE_OBJECT_NVP(obj)" and "boost::serialization::base_object< <base<T> >(obj)" and I am not able to compile the source code. Base object serialization macros are not able to deduce the template argument list.

    Pyush

    On 9/26/05, Pyush Agrawal <pyush.agrawal_at_[hidden] > wrote:
      Hi,
        I am relatively a new to Boost serialization classes. I am trying to serialize a derived template class.

      template<class T> class base {};
      tempate<class T> class derived : public base<T> {};

      I am trying to serialize 'derived' and have tried many different things. I am unable to serialize the inherited template classes.
      For some reason the code calls
      (1) 'derived::Serialize'
      (2) 'base::Save'
      and never executes 'derived:: Save' and doesnot serialize the 'derived' object properly.

      I am attaching the source code (SerializeTemplates.cpp) and the output(output.txt) of the program.
      I am using MSVC7.1, debug mode, Boost 1.33, Spirit 1.8
      It will be great, if somebody could point out what I am doing wrong.
      Thanks,
      Pyush

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

  _______________________________________________
  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