xml_archives check that that data looks like <tag ...> ... </tag>.  This traps errors where the loading is not compatible with the saving.  These programming errors are otherwise difficult to track.  It doesn't check  that the value of the tag specified in the program matches the one in the file.  Maybe it should.  If you consider that this would be a useful feature, makeup a trak item.
 
Robert Ramey
"Dan Eaton" <daniel.eaton@acceleware.com> wrote in message news:AD3E5D661CED404A842D89A45C87D5661654313ED2@axe-post.Acceleware.local...

Robert,


Could you please clarify what you mean by that? Do you mean the first and last tags of the archive are checked? I can't reproduce that behaviour either.

 

int foo = 1;

unsigned int bar =1;

 

// create stream & output xml archive

  oarchive << BOOST_SERIALIZATION_NVP(foo);

// create input xml archive from stream

  iarchive >> BOOST_SERIALIZATION_NVP(bar);

This deserializes happily.

 

Thanks,
Danny

 

 

From: Dan Eaton
Sent: Monday, May 25, 2009 1:30 PM
To: 'boost-users@lists.boost.org'
Subject: [Serialization] Guard against attempting to deserialize the wrong type

 

Hello,

I'm just wondering if NVP/XML archives check the name during deserialization?

 

I just had a problem whereby I tried deserializing an object to one type, but the archive actually contained a different (larger ) object type. The first serialized element of the object just so happened to be an unsigned int, and I was trying to deserialize an enum, so the output actually seemed sensible, and didn't cause any problems until I later deserialized the full object from the same archive, which caused a segmentation fault in the boost::serialize source (trying to get ETI from a null pointer).

 

I was using a polymorphic text archive, and as I mentioned above, am wondering if I switched to an XML archive if this sort of user-error would be detected.

 

Thanks,

 

Dan Eaton
Software Developer
Acceleware Corp. (TSX-V:AXE) www.acceleware.com

 

Phone: +1.403.249.9099 Ext.295
Fax: +1.403.249.9881
Email: daniel.eaton@acceleware.com

 

 

Get superpowered!
Acceleware gets your products to market faster, better and stronger!                   

 

 

This e-mail may contain information that is privileged and confidential and subject to legal restrictions and penalties regarding its unauthorized disclosure or use. You are prohibited from copying, distributing or otherwise using this information if you are not the intended recipient. If you have received this e-mail in error, please notify us immediately by return e-mail and delete this e-mail and its attachments from your system. Thank you.
2008 Acceleware, Inc. All Rights Reserved

 

 

 

 

 

 


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users