[serialization] Transactional persistence ?

I'm looking for an STL-like library that would let me do something
like the following:
tp::database data;
tp::map

Buster wrote:
The approach I use is to use Berkeley DB for transactional persistence of each element/object in the database, and boost::serialization for converting C++ objects to and from the array of bytes that is required by Berkeley DB. That is, I serialize at the granularity of individuals objects in the database, rather than serializing the whole database contents in one go.
I serialize an object to an in-memory byte vector first before saving to the database, so that (along with Berkeley DB) guarantees all-or-nothing (i.e. atomic) changes to the database.

On 15/12/05, Buster
http://www.cuj.com/documents/s=8000/cujcexp1812alexandr/alexandr.htm The scopeguard trick will work in any case where you have a rollback function that is nofail -- such as erase in a map or pop_back in a list. For more complex tasks you'll need a more complex solution, but ScopeGuard is quite simple and elegant for many. I wrote an implementation you're free to use or imitate or whatever: http://www.uploadthis.co.uk/uploads/me22/guard.hpp - Scott McMurray
participants (4)
-
Buster
-
me22
-
Mick Hollins
-
Robert Ramey