Jump to content
  • Advertisement
Sign in to follow this  
impulsionaudio

boost serialization to xml has problems

This topic is 3562 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In a test Win32 console app, the following code throws a boost exception when run:
#include "stdafx.h"
#include <boost/archive/xml_oarchive.hpp>
#include <boost/serialization/nvp.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 & boost::serialization::make_nvp("Foo", m_foo);
		archive & boost::serialization::make_nvp("Bar", m_bar);
	}

	int m_foo;
	float m_bar;
};

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

	return 0;
}
If I do not use make_nvp, the code doesn't even compile. Switching from xml_oarchive to text_oarchive works without problem. Can someone tell me what I am doing wrong? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!