Boost Users :
Subject: [Boost-users] Serialization: how to inject context into save/load free functions?
From: Michael Schuerig (michael.lists_at_[hidden])
Date: 2011-06-15 09:34:28
I have a POD struct that I de/serialize through appropriately overloaded
save and load free functions[*].
In my case, de/serialization involves translating between different
representations (uid <-> username, gid <-> groupname). This translation
is encapsulated in a class Etc and currently I just have a local
variable of class Etc in both methods. I'd prefer a way to inject the
Etc instance into save and load.
The ideal solution would meet these criteria:
* The Etc instance is created externally to save/load.
* No global or quasi-global (static or singleton) variables.
* No changes to the serialized struct (i.e. not an additional pointer to
an Etc instance).
* Usable with existing archive classes without extension.
As far as I can tell, so far, I can't get all of these. I'm hoping that
there is a way that I have overlooked.
-- Michael Schuerig mailto:michael_at_[hidden] http://www.schuerig.de/michael/
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