Maybe we refer to two distinct case...this is the example of boost::serialization

// Serialize the data first so we know how large it is.
std::ostringstream archive_stream;
boost::archive::text_oarchive archive(archive_stream);
archive << t;
outbound_data_ = archive_stream.str();

// Format the header.
std::ostringstream header_stream;
header_stream << std::setw(header_length)
<< std::hex << outbound_data_.size();
if (!header_stream || header_stream.str().size() != header_length)
{
// Something went wrong, inform the caller.
boost::system::error_code error(boost::asio::error::invalid_argument);
socket_.io_service().post(boost::bind(handler, error));
return;
}
outbound_header_ = header_stream.str();

// Write the serialized data to the socket. We use "gather-write" to send
// both the header and the data in a single write operation.
std::vector<boost::asio::const_buffer> buffers;
buffers.push_back(boost::asio::buffer(outbound_header_));
buffers.push_back(boost::asio::buffer(outbound_data_));
boost::asio::async_write(socket_, buffers, handler);
}
I don't understand if is mandatory to attach this header, or if I can delete it.


Da: "Pfligersdorffer, Christian" <Christian.Pfligersdorffer@eos.info>
A: boost-users@lists.boost.org
Inviato: Ven 18 marzo 2011, 16:57:09
Oggetto: Re: [Boost-users] serialization example

Marco Piacentini wrote:
> In the example of the serialization, before serialize, an header is linked to the data.
> It will be handle both in write and read operations.
> Is this header essential for the serialization process, or it can be omitted and I can serialize only the data?
> thank you...

Try the boost::archive::no_header flag when constructing your archive.
Then you will serialize only data, if that is what you wanted.

Good luck,

--
Christian Pfligersdorffer
Software Engineering
www.eos.info
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users