X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fstlplus%2Fpersistence%2Fpersistent_deque.tpp;fp=src%2Fstlplus%2Fpersistence%2Fpersistent_deque.tpp;h=26854ce730c3ccc4f94cc609959e500697f824a9;hb=6b0a0d0efafe34d48ab344fca3b479553bd4e62c;hp=0000000000000000000000000000000000000000;hpb=85783316365181491a3e3c0c63659972477cebba;p=chaz%2Fyoink diff --git a/src/stlplus/persistence/persistent_deque.tpp b/src/stlplus/persistence/persistent_deque.tpp new file mode 100644 index 0000000..26854ce --- /dev/null +++ b/src/stlplus/persistence/persistent_deque.tpp @@ -0,0 +1,41 @@ +//////////////////////////////////////////////////////////////////////////////// + +// 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_deque(dump_context& context, const std::deque& data, D dump_fn) + throw(persistent_dump_failed) + { + dump_unsigned(context,data.size()); + for (typename std::deque::const_iterator i = data.begin(); i != data.end(); i++) + dump_fn(context,*i); + } + + template + void restore_deque(restore_context& context, std::deque& data, R restore_fn) + throw(persistent_restore_failed) + { + data.clear(); + unsigned size = 0; + restore_unsigned(context,size); + for (unsigned i = 0; i < size; i++) + { + data.push_back(T()); + restore_fn(context,data.back()); + } + } + + //////////////////////////////////////////////////////////////////////////////// + +} // end namespace stlplus