|
Boost : |
From: Jeff Garland (jeff_at_[hidden])
Date: 2003-09-14 09:24:53
On Wed, 3 Sep 2003 10:18:08 -0700, Robert Ramey wrote
> I have just uploaded a draft version of the serialization library to
> the files section under the file name serialization10.zip.
Robert -
I have looked over the latest implementation and I have to say thanks for the
incredible effort and work on this. This new version looks like it does
everything from the mundane to the complicated right out of the box. I was
able to update the little test program I wrote during the review and it worked
great with g++3.2 on Linux. Very nice work!
Of course there are many great new features that I had to try out and that ran
me into a couple issues with the xml output. The first is that I can't seem
to output a std::string name value pair:
$ g++ -I/home/jeff/devTools/boost_serialize test_string.cpp -L.
-lboost_serialization
/tmp/ccBqF41H.o(.gnu.linkonce.t._ZN5boost7archive18basic_xml_oarchiveISoE4saveISsEEvRKT_+0x2a):
In function `void boost::archive::basic_xml_oarchive<std::basic_ostream<char,
std::char_traits<char> > >::save<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)':
: undefined reference to `void
boost::archive::xml_oprimitive::save<std::basic_ostream<char,
std::char_traits<char> > >(std::basic_ostream<char, std::char_traits<char> >&,
std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&,
int)'
collect2: ld returned 1 exit status
Here is the relevant code:
std::string foo = "bar";
const int anInt = 100;
std::ofstream ofx("test_string.xml");
boost::archive::xml_oarchive oax(ofx);
oax << boost::serialization::make_nvp("int_again", anInt);
oax << boost::serialization::make_nvp("foostring", foo);
If I remove the last line it compiles fine. Looking thru the implemenation, I
was unable to find a matching implementation for
//basic_xml_oarchive.hpp
// complex types that need special treatment
template<class OStream>
void save(OStream & os, const std::string & s, int);
The other thing I noticed by accident is that it is possible to write an
archive that requires name value pairs without creating one. That is,
const int anInt = 100;
std::ofstream ofx("test_string.xml");
boost::archive::xml_oarchive oax(ofx);
oax << anInt;
oax << boost::serialization::make_nvp("int_again", anInt);
compile and executes resulting in:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE boost_serialization>
<boost_serialization signature="serialization::archive" version="2">
100<int_again>100</int_again>
</boost_serialization>
I notice that trying this with strings results in a compilation error. I
assume the intent is to make all types fail to compile with archives that take
name value pairs?
Jeff
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk