Boost logo

Boost :

From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2004-09-10 09:25:01


Robert,

The following demonstrates a problem with serialization of strings
conataining '<' and/or '>'. This is on VC7.1 using serialization20 with
boost_1_13_0. I'm not in a position to check this on the CVS version at this
time. Is this still an issue?

Thanks, Jeff

/////////////////////////////////////////

#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>

#include <string>
#include <fstream>

int main(int argc, char* argv[])
{
   std::string lStringOut("<empty>");

   {
      std::ofstream lOut( "C:/xmltest.xml"
                        , std::ios_base::out | std::ios_base::trunc );

      if( lOut.good() )
      {
         boost::archive::xml_oarchive oa( lOut );

         oa << boost::serialization::make_nvp( "MyString", lStringOut );
      }
   }

   std::string lStringIn;

   {
    std::ifstream lIn( "C:/xmltest.xml" );

    if( lIn.good() )
    {
         boost::archive::xml_iarchive ia( lIn );

         ia >> boost::serialization::make_nvp( "MyString", lStringIn );
      }
   }

   assert( lStringOut == lStringIn );

 return 0;
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk