boost::serialization problem with own defined primitive type
Hi all, I've tried to define operator >> & << in order to make a juce::String serializable in the same manner as a std::wstring. Here is the question thread on StackOverflow: http://stackoverflow.com/questions/6126133/boost-deserialization-problem-of-... Any ideas what might be wrong ? Thing is (as I say in the thread above), that it _has_ worked and I obviously have made a change but 2 hours of checking SVN repo diffsets I cannot find it. TIA /Rob
Robert Bielik skrev 2011-05-25 18:52:
I've tried to define operator >> & << in order to make a juce::String serializable in the same manner as a std::wstring. Here is the question thread on StackOverflow:
http://stackoverflow.com/questions/6126133/boost-deserialization-problem-of-...
Any ideas what might be wrong ? Thing is (as I say in the thread above), that it _has_ worked and I obviously have made a change but 2 hours of checking SVN repo diffsets I cannot find it.
Really? No one? /Rob
On Fri, May 27, 2011 at 9:53 AM, Robert Bielik
Robert Bielik skrev 2011-05-25 18:52:
I've tried to define operator >> & << in order to make a juce::String serializable in the same manner as a std::wstring. Here is the question thread on StackOverflow:
http://stackoverflow.com/questions/6126133/boost-deserialization-problem-of-...
Any ideas what might be wrong ? Thing is (as I say in the thread above), that it _has_ worked and I obviously have made a change but 2 hours of checking SVN repo diffsets I cannot find it.
Really? No one?
/Rob _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Posted an answer, but not sure if it is even a possible solution for your problem - http://stackoverflow.com/questions/6126133/boost-deserialization-problem-of-... . Hope it helps Ganesh -- Ganeshram Iyer Open Source and CAD: http://ossandcad.blogspot.com ganeshramiyer@yahoo.com
Robert Bielik wrote:
Robert Bielik skrev 2011-05-25 18:52:
I've tried to define operator >> & << in order to make a juce::String serializable in the same manner as a std::wstring. Here is the question thread on StackOverflow: http://stackoverflow.com/questions/6126133/boost-deserialization-problem-of-...
Any ideas what might be wrong ? Thing is (as I say in the thread above), that it _has_ worked and I obviously have made a change but 2 hours of checking SVN repo diffsets I cannot find it.
Really? No one?
/Rob
If you look at how serialization of string is implemented inside the library (text_primitive), you'll see the it is something like <string length> <string characters> It has to be something like this to avoid "running over". I would think that your implemenation would have to have something similar. And there's another problem. Your saving as one type (pointer to a wide char and loading a different type - a std::wstring. Not guarenteed to work though some times you could get lucky. Also this will break the machinery used to restore pointers. if you can't do just ar << wstring and ar >> wstring You'll have to digg for the cause. I believe this is explictly tested in one of the tests for the library. Look through the tests and verify that it is in fact implemented. Robert Ramey
Hi Robert, Robert Ramey skrev 2011-05-28 07:45:
If you look at how serialization of string is implemented inside the library (text_primitive), you'll see the it is something like
<string length> <string characters> It has to be something like this to avoid "running over". I would think that your implemenation would have to have something similar.
With the text archive there is no problem. The problem occurs only when using the XML archive.
I've checked the xml_iarchive_impl::load impl for std::wstring and there it uses an xml_grammar
to parse out the string, which obviously is why that works. So I would need to do something like that.
Unfortunately there is no way to specialize xml_iarchive_impl::load for my string type, nor is there a way to
call xml_oarchive::save and xml_iarchive_impl::load explicitly (for std::wstring) from load/save implementations (when splitting
serialize into load/save) since they're protected.
For now I split serialize of juce::String into load/save and load/save a std::wstring (with the necessary additional tag)
<myString>
Robert Bielik skrev 2011-05-30 08:20:
My end goal is to be able to save my string as:
<myString>StringValue</myString>
Any tips towards that end would be greatly appreciated :)
I solved it currently for the XML archive by using basic_xml_grammar to parse the string in the >> stream operator. Regards /Rob
On Monday, May 30, 2011, Robert Bielik
I solved it currently for the XML archive by using basic_xml_grammar to parse the string in the >> stream operator.
Regards /Rob
Hello Rob Any chance you can post the whole solution somewhere (perhaps on the stackoverflow q) for reference? I am personally interested in it myself ( I was one of he responders to ur stackiverflow q and I only realized the error of sorts in my code based in your comment) Thanks Ganesh -- Ganeshram Iyer Open Source and CAD: http://ossandcad.blogspot.com ganeshramiyer@yahoo.com
On Monday, May 30, 2011, Robert Bielik
I solved it currently for the XML archive by using basic_xml_grammar to parse the string in the >> stream operator.
Regards /Rob
Hello Rob Any chance you can post the whole solution somewhere (perhaps on the stackoverflow q) for reference? I am personally interested in it myself ( I was one of he responders to ur stackiverflow q and I only realized the error of sorts in my code based in your comment) Thanks Ganesh -- Ganeshram Iyer Open Source and CAD: http://ossandcad.blogspot.com ganeshramiyer@yahoo.com
On Monday, May 30, 2011, Robert Bielik
I solved it currently for the XML archive by using basic_xml_grammar to parse the string in the >> stream operator.
Regards /Rob
Hello Rob Any chance you can post the whole solution somewhere (perhaps on the stackoverflow q) for reference? I am personally interested in it myself ( I was one of he responders to ur stackiverflow q and I only realized the error of sorts in my code based in your comment) Thanks Ganesh -- Ganeshram Iyer Open Source and CAD: http://ossandcad.blogspot.com ganeshramiyer@yahoo.com
participants (3)
-
Ganeshram Iyer
-
Robert Bielik
-
Robert Ramey