X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fstlplus%2Fpersistence%2Fpersistent_string.tpp;fp=src%2Fstlplus%2Fpersistence%2Fpersistent_string.tpp;h=c78f7e8a1b5844596b84a17c8ec5f175dd4e7a59;hp=0000000000000000000000000000000000000000;hb=6b0a0d0efafe34d48ab344fca3b479553bd4e62c;hpb=85783316365181491a3e3c0c63659972477cebba diff --git a/src/stlplus/persistence/persistent_string.tpp b/src/stlplus/persistence/persistent_string.tpp new file mode 100644 index 0000000..c78f7e8 --- /dev/null +++ b/src/stlplus/persistence/persistent_string.tpp @@ -0,0 +1,47 @@ +//////////////////////////////////////////////////////////////////////////////// + +// 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 +{ + + //////////////////////////////////////////////////////////////////////////////// + // STL strings + + template + void dump_basic_string(dump_context& context, const std::basic_string& data, D dump_fn) + throw(persistent_dump_failed) + { + unsigned size = data.size(); + dump_unsigned(context, size); + for (unsigned i = 0; i < size; i++) + { + charT ch = data[i]; + dump_fn(context,ch); + } + } + + template + void restore_basic_string(restore_context& context, std::basic_string& data, R restore_fn) + throw(persistent_restore_failed) + { + data.erase(); + unsigned size = 0; + restore_unsigned(context, size); + for (unsigned i = 0; i < size; i++) + { + charT ch; + restore_fn(context,ch); + data += ch; + } + } + + //////////////////////////////////////////////////////////////////////////////// + +} // end namespace stlplus