Chapter 14. Serializing binary data

Objects of the following types are stored as blobs in the database:

These types are automatically handled by the library and can be serialized using non-split serialization when they are used as a member of a class.

You can also serialize other binary data by using a split load() / save() serialization technique: on saving, you create a ccs::serialization::raw_blob_for_saving object containing the size and address of the data to store, and on loading, you obtain the size and address of the data from the database by using a ccs::serialization::raw_blob_for_loading object and you then allocate your own buffer and copy the data from the library's buffer into your buffer. You need to copy the data because the library's buffer is deallocated after the load() call returns to the library. For an example of this technique, see the cxx_test_split_ni class in the serialization_unit_tests.cpp file.

Although inconvenient, the split serialization technique is more flexible because it allows clients to, for example, compress the blob data before saving and then decompress it while loading.