Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #5847

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

From Michael Schuerig <michael@schuerig.de>
Newsgroups comp.lang.c++
Subject Boost serialization: how to inject a context into free load/save funcs?
Date 2011-05-30 21:53 +0200
Organization news.netcologne.de
Message-ID <is0sja$id5$1@newsreader5.netcologne.de> (permalink)

Show all headers | View raw


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
mailto:michael@schuerig.de
http://www.schuerig.de/michael/

Back to comp.lang.c++ | Previous | NextNext in thread | Find similar


Thread

Boost serialization: how to inject a context into free load/save funcs? Michael Schuerig <michael@schuerig.de> - 2011-05-30 21:53 +0200
  Re: Boost serialization: how to inject a context into free load/save funcs? Jeff Flinn <TriumphSprint2000@hotmail.com> - 2011-05-31 08:44 -0400

csiph-web