Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Boost serialization: how to inject a context into free load/save funcs?

Reply
Thread Tools

Boost serialization: how to inject a context into free load/save funcs?

 
 
Michael Schuerig
Guest
Posts: n/a
 
      05-30-2011

I haven't been using C++ for years and I've never used Boost before, so
I might well be missing something obvious.

I'm using Boost serialization on a class holding a vector of plain
structs. In order to keep anything related to serialization out of the
interface, I have defined free functions for load and save. This works
as expected.

However, for the external representation of the data I need to do a
little bit of mapping from user and group IDs to respective names. I
have another class, Etc, for this task and currently the load and save
functions just have a local Etc variable. This, unfortunately, ties the
code to a specific implementation of the functionality and precludes
caching of mappings in a single Etc instance.

So, what I'm looking for is a way to inject "context" into the load and
save functions that would allow me to keep one Etc instance and pass it
along to where it is needed.

If anyone is interested in the actual code, it can be found here:
https://github.com/mschuerig/preserfs/tree/master/src

Michael

--
Michael Schuerig
(E-Mail Removed)
http://www.schuerig.de/michael/
 
Reply With Quote
 
 
 
 
Jeff Flinn
Guest
Posts: n/a
 
      05-31-2011
Michael Schuerig wrote:
> I haven't been using C++ for years and I've never used Boost before, so
> I might well be missing something obvious.
>
> I'm using Boost serialization on a class holding a vector of plain
> structs. In order to keep anything related to serialization out of the
> interface, I have defined free functions for load and save. This works
> as expected.
>
> However, for the external representation of the data I need to do a
> little bit of mapping from user and group IDs to respective names. I
> have another class, Etc, for this task and currently the load and save
> functions just have a local Etc variable. This, unfortunately, ties the
> code to a specific implementation of the functionality and precludes
> caching of mappings in a single Etc instance.
>
> So, what I'm looking for is a way to inject "context" into the load and
> save functions that would allow me to keep one Etc instance and pass it
> along to where it is needed.
>
> If anyone is interested in the actual code, it can be found here:
> https://github.com/mschuerig/preserfs/tree/master/src


Well the Archive is the 'context'. IIUC, you would create your own
archive class. There are docs and examples on doing this. The boost
mailing list would provide support for your endeavor.

Jeff
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Inject my code into someone else's JNLP app? Chris Kelly Java 6 02-07-2008 02:51 AM
Is there a "grease gun" to inject silicone grease into waterproof housing slots? self Digital Photography 5 11-29-2007 11:43 PM
inject extra code into all controls on a page sklett ASP .Net 1 09-17-2006 01:51 PM
inject does not inject last value Peņa, Botp Ruby 4 08-07-2006 09:26 AM



Advertisments