]> Dogcows Code - chaz/yoink/blobdiff - src/stlplus/persistence/persistent_string.tpp
testing new non-autotools build system
[chaz/yoink] / src / stlplus / persistence / persistent_string.tpp
diff --git a/src/stlplus/persistence/persistent_string.tpp b/src/stlplus/persistence/persistent_string.tpp
new file mode 100644 (file)
index 0000000..c78f7e8
--- /dev/null
@@ -0,0 +1,47 @@
+////////////////////////////////////////////////////////////////////////////////\r
+\r
+//   Author:    Andy Rushton\r
+//   Copyright: (c) Southampton University 1999-2004\r
+//              (c) Andy Rushton           2004-2009\r
+//   License:   BSD License, see ../docs/license.html\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+#include "persistent_int.hpp"\r
+\r
+namespace stlplus\r
+{\r
+\r
+  ////////////////////////////////////////////////////////////////////////////////\r
+  // STL strings\r
+\r
+  template<typename charT, typename traits, typename allocator, typename D>\r
+  void dump_basic_string(dump_context& context, const std::basic_string<charT,traits,allocator>& data, D dump_fn)\r
+    throw(persistent_dump_failed)\r
+  {\r
+    unsigned size = data.size();\r
+    dump_unsigned(context, size);\r
+    for (unsigned i = 0; i < size; i++)\r
+    {\r
+      charT ch = data[i];\r
+      dump_fn(context,ch);\r
+    }\r
+  }\r
+\r
+  template<typename charT, typename traits, typename allocator, typename R>\r
+  void restore_basic_string(restore_context& context, std::basic_string<charT,traits,allocator>& data, R restore_fn)\r
+    throw(persistent_restore_failed)\r
+  {\r
+    data.erase();\r
+    unsigned size = 0;\r
+    restore_unsigned(context, size);\r
+    for (unsigned i = 0; i < size; i++)\r
+    {\r
+      charT ch;\r
+      restore_fn(context,ch);\r
+      data += ch;\r
+    }\r
+  }\r
+\r
+  ////////////////////////////////////////////////////////////////////////////////\r
+\r
+} // end namespace stlplus\r
This page took 0.022139 seconds and 4 git commands to generate.