X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fstlplus%2Fpersistence%2Fpersistent_multimap.tpp;fp=src%2Fstlplus%2Fpersistence%2Fpersistent_multimap.tpp;h=5f96a3dce2b20cf18dd4fa84bb5d270b5e7f6381;hb=6b0a0d0efafe34d48ab344fca3b479553bd4e62c;hp=0000000000000000000000000000000000000000;hpb=85783316365181491a3e3c0c63659972477cebba;p=chaz%2Fyoink diff --git a/src/stlplus/persistence/persistent_multimap.tpp b/src/stlplus/persistence/persistent_multimap.tpp new file mode 100644 index 0000000..5f96a3d --- /dev/null +++ b/src/stlplus/persistence/persistent_multimap.tpp @@ -0,0 +1,46 @@ +//////////////////////////////////////////////////////////////////////////////// + +// Author: Andy Rushton +// Copyright: (c) Southampton University 1999-2004 +// (c) Andy Rushton 2004-2009 +// License: BSD License, see ../docs/license.html + +//////////////////////////////////////////////////////////////////////////////// +#include "persistent_int.hpp" + +namespace stlplus +{ + + //////////////////////////////////////////////////////////////////////////////// + + template + void dump_multimap(dump_context& context, const std::multimap& data, DK key_fn, DT val_fn) + throw(persistent_dump_failed) + { + dump_unsigned(context,data.size()); + for (typename std::multimap::const_iterator i = data.begin(); i != data.end(); i++) + { + key_fn(context,i->first); + val_fn(context,i->second); + } + } + + template + void restore_multimap(restore_context& context, std::multimap& data, RK key_fn, RT val_fn) + throw(persistent_restore_failed) + { + data.clear(); + unsigned size = 0; + restore_unsigned(context,size); + for (unsigned j = 0; j < size; j++) + { + K key; + key_fn(context,key); + typename std::multimap::iterator v = data.insert(std::pair(key,T())); + val_fn(context,v->second); + } + } + + //////////////////////////////////////////////////////////////////////////////// + +} // end namespace stlplus