boost][serialization] Adding State to Archives

Martin Ecker wrote:
One way of achieving all this would, of course, be to derive from one of the existing archive classes and add the required functionality. However, we don't want to lose the flexibility of being able to write out data to a binary, text, XML, or any other archive with some other kind of representation. So basically we're looking for a good way of inserting an additional layer in between the archives and the actual serialize functions that can store state variables.
Have you consider making a template which takes the base class as a parameter? Example template <class BaseArchive> class stately_iarchive : public BaseArchive { ... // your overloads here ... // you extra control functions here }; To be used thusly: // can't use typedef because it typedef does like self-reference class stately_binary_archive : public stately_archive<binary_iarchive_impl<stately_binary_archive> { stately_binary_archive(istream &is, flags = 0) : stately_archive<binary_iarchive_impl<stately_binary_archive>(is, flags); }; Now just use stately_binary_archive anywhere you used binary_archive before. Robert Ramey

Hello, Robert Ramey wrote:
Martin Ecker wrote:
One way of achieving all this would, of course, be to derive from one of the existing archive classes and add the required functionality. However, we don't want to lose the flexibility of being able to write out data to a binary, text, XML, or any other archive with some other kind of representation. So basically we're looking for a good way of inserting an additional layer in between the archives and the actual serialize functions that can store state variables.
Have you consider making a template which takes the base class as a parameter? Example
Ah, that's a nifty idea. I'll investigate this some further, but I believe this is just what we need. Thanks, Martin TAB Austria Industrie- und Unterhaltungselektronik GmbH & CoKG http://www.tab.at
participants (2)
-
martin.ecker@tab.at
-
Robert Ramey