+++ /dev/null
-////////////////////////////////////////////////////////////////////////////////\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
-\r
-#include "persistent_cstring.hpp"\r
-#include "persistent_int.hpp"\r
-#include <string.h>\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Null-terminated char arrays\r
-// Format: address [ size data ]\r
-\r
-void stlplus::dump_cstring(stlplus::dump_context& context, const char* data) throw(stlplus::persistent_dump_failed)\r
-{\r
- // register the address and get the magic key for it\r
- std::pair<bool,unsigned> mapping = context.pointer_map(data);\r
- stlplus::dump_unsigned(context,mapping.second);\r
- // if the address is null, then that is all that we need to do\r
- // however, if it is non-null and this is the first sight of the address, dump the contents\r
- if (data && !mapping.first)\r
- {\r
- unsigned size = strlen(data);\r
- stlplus::dump_unsigned(context,size);\r
- for (unsigned i = 0; i < size; i++)\r
- stlplus::dump_char(context,data[i]);\r
- }\r
-}\r
-\r
-void stlplus::restore_cstring(restore_context& context, char*& data) throw(stlplus::persistent_restore_failed)\r
-{\r
- // destroy any previous contents\r
- if (data)\r
- {\r
- delete[] data;\r
- data = 0;\r
- }\r
- // get the magic key\r
- unsigned magic = 0;\r
- stlplus::restore_unsigned(context,magic);\r
- // now lookup the magic key to see if this pointer has already been restored\r
- // null pointers are always flagged as already restored\r
- std::pair<bool,void*> address = context.pointer_map(magic);\r
- if (!address.first)\r
- {\r
- // this pointer has never been seen before and is non-null\r
- // restore the string\r
- unsigned size = 0;\r
- stlplus::restore_unsigned(context,size);\r
- data = new char[size+1];\r
- for (unsigned i = 0; i < size; i++)\r
- stlplus::restore_char(context,data[i]);\r
- data[size] = '\0';\r
- // add this pointer to the set of already seen objects\r
- context.pointer_add(magic,data);\r
- }\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r