-
March 25th, 2006, 05:39 PM
#1
boost::serialization with boost::any
Hi there.
Has any of you found a generic method of making boost::any serializable? The net doesn't provide anything more than a couple of unfinished ideas, as far as I have searched.
Exampla code:
Code:
#include <boost/any.hpp>
#include <boost/config.hpp>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp>
int main()
{
boost::any a;
a = ...[insert some value here];
std::ofstream ofs("C:\\fiel.xml");
boost::archive::xml_oarchive oa(ofs);
oa << BOOST_SERIALIZATION_NVP(a);
return 0;
}
Of course, one could modify boost::any. That's not my first option, to be honest.
Any ideas, thoughts?
-
March 26th, 2006, 04:27 AM
#2
Re: boost::serialization with boost::any
Boost serialisation does provide means of serialising objects which were not not desigened to be compatible with that library. You may have a look at implementation of that functionality for std::vector or boost::shared_ptr (files are in boost serialisation folder).
This mechanism is described in boost serialisation documentation as well.
-
March 26th, 2006, 08:09 AM
#3
Re: boost::serialization with boost::any
Originally Posted by DragForce
Boost serialisation does provide means of serialising objects which were not not desigened to be compatible with that library. You may have a look at implementation of that functionality for std::vector or boost::shared_ptr (files are in boost serialisation folder).
This mechanism is described in boost serialisation documentation as well.
Hi.
Am am of course aware that boost::serialization offers non-intrusive serialization for a large number of well known constructs, like std::vector or boost::shared_ptr.
However, there is no (official) method for serializing boost::any. I was hopping that someone here has found a (more or less) generical method for that, as I didn't want to begin ym own attempt.
The issue has been discussed on the boost mailing list, but, as I said, to no more than some ideas. One can hope that a future release of boost will cover the issue.
In the meanwhile, I see three options:
- write an own implementation, that covers strictly the needs of my project (i.e. non-generic)
- drop boost::any and use something else, like boost::variant or an own construct
- attempt an own gnerical implementation and upload it to the boost vault, hoping that it gets accepted
I dislike the first option because of aesthetical reasons The third option is rather time consuming, and would mean a digression in my project. The second option is probably the most pragmatical one...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|