Boost logo

Boost Users :

Subject: Re: [Boost-users] XML Serialization
From: Lasse Laursen (gazoo_at_[hidden])
Date: 2013-11-04 21:27:01


Hey Ice,

Thanks for engaging me in conversation. I'm still pretty much at a loss,
as to why I cannot get my program to compile. Am I perhaps missing a
header or something?

The empty struct that I mentioned uses the following two headers:

#include "boost\serialization\nvp.hpp"
#include "boost\serialization\string.hpp"

and is - at this point - literally empty (after removing the comments):

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 )
        {
        }

};

I'm using the object as a container in another object which uses the
following headers:

#include "boost/archive/xml_iarchive.hpp"
#include "boost/archive/xml_oarchive.hpp"

and loads the object as follows:

void AudioEngineMaster::loadSettings( std::string settingsPath )
{
        std::ifstream ifs( settingsPath );
        boost::archive::xml_iarchive ia( ifs );

        ia >> mAESettings;
}

And still I get the aforementioned error. I saw another post regarding
the latest release candidate of boost 1.55 which apparently sports some
errors regarding serialization. Is it just not working in boost?

Regards,
Gazoo

On 04-11-2013 18:45, Christophe hugon wrote:
> Hi Gazoo
>
> On 03/11/2013 10:22, Lasse Laursen wrote:
>> 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.
> Yes, it provide a flag name for the xml structure
>
>> 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:
>
> I do prefer to use the form
> ar & boost::serialization::make_nvp
> ("DoubleProperties",fDoubleProperties);
> I don't think that the friend is not superfluous if it is fully public,
> but let's wait confirmation.
>>
>> 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 mailing list
>> Boost-users_at_[hidden]
>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
> Ice


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