[Serialization] load_binary/save_binary purpose

Hi, I'm fairly new to boost so please excuse if my question may sound stupid :) I was wondering what the actual purpose of the load_binary/save_binary methods of the Archive concept classes is. In the documentation section "Archive Concepts", it is noted, that save_binary( u, count ) "Appends to the archive size_t(count) bytes found at u" and load_binary( u, count ) "Retrieves from la size_t(count) bytes and stores them in memory starting at u". Is this meant to a) enable appending random data after some object was serialized to the archive or is this really b) a lowlevel interface through which all data is read/written to the archive, as one could think (or at least, I did :)) by reading the "Archive Class Reference" also found in the documentation? And if case b) applies, couldn't that become a problem, when someone likes to implement an archive where it isn't quite possible to write raw binary data to as additional information is needed (databases/column names come to mind)? Thanks and bye, Peter

This function does exactly what it says. It appends/retrieves raw data to/from the archive. This can be used for various purpose. Here are some examples. a) binary_archive implements the serialization of primitive types through this interface. b) suppose you retrieved some binary data from source - like an image in a format you don't care about - and wanted to store it in archive to be retrieved later. You could load/save binary to do this. Robert Ramey

ok, in this case, I have some additional questions: I'm trying to write (well, I haven't even started yet to be honest because I feel like I have to understand the library first) an archive that writes to a (sql) database backend... Now you can't just append some binary data to a database table, so the save/load_binary methods would not work very well here. Is it safe to just define them to do nothing?
This function does exactly what it says. It appends/retrieves raw data to/from the archive.
This can be used for various purpose. Here are some examples.
a) binary_archive implements the serialization of primitive types through this interface. b) suppose you retrieved some binary data from source - like an image in a format you don't care about - and wanted to store it in archive to be retrieved later. You could load/save binary to do this.
Robert Ramey
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Common databases support Blog type, so you should be able to archive in a binary format.
-----Messaggio originale----- Da: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] Per conto di Peter S. Inviato: domenica 31 agosto 2008 19.30 A: boost-users@lists.boost.org Oggetto: Re: [Boost-users] [Serialization] load_binary/save_binary purpose
ok, in this case, I have some additional questions:
I'm trying to write (well, I haven't even started yet to be honest because I feel like I have to understand the library first) an archive that writes to a (sql) database backend... Now you can't just append some binary data to a database table, so the save/load_binary methods would not work very well here. Is it safe to just define them to do nothing?

You could, or you could just not call these functions and maybe include an "assert" in case you do it by accident. Robert Ramey Peter S. wrote:
ok, in this case, I have some additional questions:
I'm trying to write (well, I haven't even started yet to be honest because I feel like I have to understand the library first) an archive that writes to a (sql) database backend... Now you can't just append some binary data to a database table, so the save/load_binary methods would not work very well here. Is it safe to just define them to do nothing?
This function does exactly what it says. It appends/retrieves raw data to/from the archive.
This can be used for various purpose. Here are some examples.
a) binary_archive implements the serialization of primitive types through this interface. b) suppose you retrieved some binary data from source - like an image in a format you don't care about - and wanted to store it in archive to be retrieved later. You could load/save binary to do this.
Robert Ramey
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Andrea Denzler
-
Peter S.
-
Robert Ramey