Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::serialization does not compile when archivingto xml
From: Robert Ramey (ramey_at_[hidden])
Date: 2008-12-21 21:14:22


You need to use a NameValuePair wrapper to assign a name for the xml data item.

Checkout demo_xml and the documentation.

Robert Ramey

  "Daniel Roberts" <impulsionaudio_at_[hidden]> wrote in message news:14125aaf0812211436q6fb00657saba425a7d6cbaec9_at_mail.gmail.com...
  Building a Win32 console app, the following code compiles just fine:

  #include "stdafx.h"
  #include <boost/archive/text_oarchive.hpp>
  #include <fstream>

  class SomeClass
  {
  public:
      SomeClass() : m_foo(666), m_bar(777.f) {}

  private:
      friend class boost::serialization::access;
      template<class Archive>
      void serialize(Archive& archive, const unsigned int version)
      {
          archive & m_foo;
          archive & m_bar;
      }

      int m_foo;
      float m_bar;
  };

  int _tmain(int argc, _TCHAR* argv[])
  {
      SomeClass someClass;
      std::ofstream fileStream("TestFile.object");
      boost::archive::text_oarchive oa(fileStream);
      oa << someClass;

      return 0;
  }

  but if I include xml_oarchive.hpp and create an xml_oarchive object, just changing the include statement and the type of oa, I get the following error:

>c:\program files (x86)\boost\boost_1_36_0\boost\archive\basic_xml_oarchive.hpp(88) : error C2664: 'boost::mpl::assertion_failed' : cannot convert parameter 1 from 'boost::mpl::failed ************boost::serialization::is_wrapper<T>::* ***********' to 'boost::mpl::assert<false>::type'
  1> with
  1> [
  1> T=SomeClass
  1> ]
  1> No constructor could take the source type, or constructor overload resolution was ambiguous
  1> c:\program files (x86)\boost\boost_1_36_0\boost\archive\detail\interface_oarchive.hpp(64) : see reference to function template instantiation 'void boost::archive::basic_xml_oarchive<Archive>::save_override<T>(T &,int)' being compiled
  1> with
  1> [
  1> Archive=boost::archive::xml_oarchive,
  1> T=SomeClass
  1> ]
  1> c:\users\daniel\documents\visual studio 2008\projects\testdata\testdata.cpp(31) : see reference to function template instantiation 'Archive &boost::archive::detail::interface_oarchive<Archive>::operator <<<SomeClass>(T &)' being compiled
  1> with
  1> [
  1> Archive=boost::archive::xml_oarchive,
  1> T=SomeClass
  1> ]

  Basically, I can't archive into XML. Can someone please explain what I am doing wrong? I am using Windows Vista, Visual Studio 2008 and boost v36,

  Thanks

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

  _______________________________________________
  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