Boost Serialization Difference in Archive Versions
Hope everyone is doing well. I'm having an issue with boost serialization. I have serialized a file on my ODroid U2 using Boost v1.53. I'm trying to deserialize the file on a computer which only has Boost v1.46; however, line 7 below causes the following error: CMyClass Exception thrown: unsupported version Code: 1 void CMyClass::enableDeserialize(std::string file, bool binary) { 2 filename = file ; 3 isBinary = binary ; 4 ifs = new std::ifstream(file.c_str()) ; 5 try { 6 if (isBinary) { 7 CMyClass::ib = new boost::archive::binary_iarchive(*ifs) ; 8 } else { 9 CMyClass::ia = new boost::archive::text_iarchive(*ifs) ; 10 } 11 } catch (boost::archive::archive_exception e) { 12 std::cout << "CMyClass Exception thrown: " << e.what() << std::endl ; 13 } 14 } The boost archive version for v1.53 (version I serialized with) is 10 and the boost archive version for v1.46 (the version I'm trying to deserialize with) is 9. Boost documentation hasn't helped me determine the differences between the 2 archive versions. I've only been able to find answers for how to deserialize an older archive. Please note, I don't do anything with BOOST_CLASS_VERSION. CMyClass hasn't changed at all. I can't imagine boost can handle the deserialization of a newer archive so I don't feel like I'm missing that answer. What I need to know if if there is a way I can serialize in v1.53 based on boost archive version 9 instead of 10. I'm hoping the new version of boost will still allow me to serialize at an older version. Then, I should be able to deserialize the archive just fine. Any advice you could provide is much appreciated! -- Lynn Coddington Gilbert Partner, Robotic Paradigm Systems www.roboticparadigmsystems.com www.facebook.com/RoboticParadigmSystems lynn@roboticparadigmsystems.com 678-428-0935
On Thu, Mar 06, 2014 at 10:47:46AM -0500, Lynn Gilbert wrote:
Hope everyone is doing well. 4 ifs = new std::ifstream(file.c_str()) ;
Hi, Just picking some tangential nits, not actually answering your original question. You probably want to open your file in std::ios::binary mode to avoid newline translation and premature EOF. -- Lars Viklund | zao@acc.umu.se
Good advice. Thank you! Lynn Coddington Gilbert Partner, Robotic Paradigm Systems www.roboticparadigmsystems.com www.facebook.com/RoboticParadigmSystems lynn@roboticparadigmsystems.com 678-428-0935 On 03/06/2014 01:02 PM, Lars Viklund wrote:
On Thu, Mar 06, 2014 at 10:47:46AM -0500, Lynn Gilbert wrote:
Hope everyone is doing well. 4 ifs = new std::ifstream(file.c_str()) ; Hi, Just picking some tangential nits, not actually answering your original question.
You probably want to open your file in std::ios::binary mode to avoid newline translation and premature EOF.
What I need to know if if there is a way I can serialize in v1.53
Lynn Gilbert
instead of 10. I'm hoping the new version of boost will still allow me to serialize at an older version.
Unfortunately that's not yet possible: http://www.boost.org/doc/libs/1_55_0/ libs/serialization/doc/ todo.html#backversioning You can only deserialize data from newer versions.
participants (3)
-
Lars Viklund
-
Lynn Gilbert
-
Marcel Raad