|
Boost Users : |
From: Rich Peters (rpeters_at_[hidden])
Date: 2007-10-18 12:16:13
I have been having some issues trying to get this relatively simple binary
memory based serialization to work.
If I use a byte type below, I get errors with not finding a matching ctor:
If I use a char, it compiles and thows an exception in
binary_iarchive_impl.hpp at line 52:
this->basic_binary_iarchive<Archive>::init();
which appears to be related to char string processing.
can anyone help me sort this out?
thanks
Rich
======================
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/iostreams/device/array.hpp>
#include <boost/iostreams/stream_buffer.hpp>
#include <boost/iostreams/stream.hpp>
....
std::vector<byte> store(1000, 0x00) ;
// std::vector<char> store(1000, 0x00) ; // other test
boost::iostreams::stream <boost::iostreams::array > theStream(&store[0],
&store[0]+store.size()) ;
// save data to archive
{
boost::archive::binary_oarchive oa(theStream);
oa & theInfo;
// archive closed when destructors are called
}
c:\Program Files\boost\boost_1_34_1\boost\iostreams\stream.hpp(112) : error
C2665: 'boost::iostreams::basic_array<Ch>::__ctor' : none of the 5 overloads
can convert parameter 1 from type 'unsigned char *__w64 const '
with
[
Ch=char
]
and
[
Ch=char
]
c:\Program
Files\boost\boost_1_34_1\boost\iostreams\device\array.hpp(90): could be
'boost::iostreams::basic_array<Ch>::basic_array(boost::iostreams::basic_array<Ch>::char_type
*,boost::iostreams::basic_array<Ch>::char_type *)'
with
[
Ch=char
]
c:\Program
Files\boost\boost_1_34_1\boost\iostreams\device\array.hpp(90): or
'boost::iostreams::basic_array<Ch>::basic_array(boost::iostreams::basic_array<Ch>::char_type
*,size_t)'
with
[
Ch=char
]
c:\Program
Files\boost\boost_1_34_1\boost\iostreams\device\array.hpp(90): or
'boost::iostreams::basic_array<Ch>::basic_array(const
boost::iostreams::basic_array<Ch>::char_type *,const
boost::iostreams::basic_array<Ch>::char_type *)'
with
[
Ch=char
]
c:\Program
Files\boost\boost_1_34_1\boost\iostreams\device\array.hpp(90): or
'boost::iostreams::basic_array<Ch>::basic_array(const
boost::iostreams::basic_array<Ch>::char_type *,size_t)'
with
[
Ch=char
]
while trying to match the argument list '(unsigned char *__w64 const
, unsigned char *__w64 const )'
c:\Dev\Shared-ADL
Integration\UnitTest\BoostSerialization\BoostSerialization\Serialize.h(194)
: see reference to function template instantiation
'boost::iostreams::stream<Device>::stream<std::allocator<_Ty>::value_type*__w64
,std::allocator<_Ty>::value_type*__w64 >(const U0 & ,const U1 & )' being
compiled
with
[
Device=boost::iostreams::array,
_Ty=unsigned char,
U0=std::allocator<unsigned char>::value_type *__w64 ,
U1=std::allocator<unsigned char>::value_type *__w64
]
thanks
Rich
Matthias Troyer wrote:
You can use the Boost IOstreams library to create an iostream using a
memory buffer and use that with the binary archives
Matthias
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net