Boost logo

Boost Users :

Subject: [Boost-users] XML Serialization
From: Lasse Laursen (gazoo_at_[hidden])
Date: 2013-11-03 04:22:04


Hey People,

I'm having some issues using BOOST's serialization capabilities in
version 1.53. To be honest, the capability provided by boost seem to
involve a lot of macro usage here and there, and despite the fact that
I've read a number of tutorials, I still don't feel like I've got a
solid grasp on how it all works.

Probably because I keep running into compilation problems that I can't
seem to figure out how to fix logically, I usually just end up trying a
number of different macro's that other people recommend until it just works.

Not ideal, I know, but... All my logical deduction usually leads me to
solutions that don't work as I keep expecting.

Case in point, I want to serialize some data as XML. Essentially it's
just a struct with a few strings in it that is used as 'settings' data.

I get the following error message during compilation in VS2012:

Error 47 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'
d:\sdks\cinder\boost\boost\archive\basic_xml_iarchive.hpp 70

I found out, it had to do with any XML serilization requiring an
additional 'name' to be added, pertaining to how XML works via the
'BOOST_SERIALIZATION_NVP' macro. I added that to all my strings - still
nothing. Then I proceeded to comment out everything, so my struct is now
just an empty shell:

struct AEMSettings {
        // Superfluous since structs are fully public?
        friend class boost::serialization::access;

        AEMSettings() {
        }

        /***
        * Serialize handles both input/output as the & operator doubles as both
<< and >>
        */
        template<class Archive>
        void serialize( Archive &ar, const unsigned version )
        {
                //ar & BOOST_SERIALIZATION_NVP( mSpeakersDeviceName );
                //ar & BOOST_SERIALIZATION_NVP( mSpeakersDeviceDriverName );

                //ar & BOOST_SERIALIZATION_NVP( mHeadphonesDeviceName );
                //ar & BOOST_SERIALIZATION_NVP( mHeadphonesDeviceDriverName );

                //ar & BOOST_SERIALIZATION_NVP( mMicrophoneDeviceName );
                //ar & BOOST_SERIALIZATION_NVP( mMicrophoneDeviceDriverName );
        }

        //std::string mSpeakersDeviceName;
        //std::string mSpeakersDeviceDriverName;

        //std::string mHeadphonesDeviceName;
        //std::string mHeadphonesDeviceDriverName;

        //std::string mMicrophoneDeviceName;
        //std::string mMicrophoneDeviceDriverName;

};

Can anyone tell me what I am missing here?

Regards,
Gazoo


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