+++ /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
-// format: magic_key [ data ]\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-#include "persistent_int.hpp"\r
-\r
-namespace stlplus\r
-{\r
-\r
- ////////////////////////////////////////////////////////////////////////////////\r
-\r
- template<typename T>\r
- void dump_xref(dump_context& context, const T* const data)\r
- throw(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
- // if this is the first view of this pointer, simply throw an exception\r
- if (!mapping.first) throw persistent_dump_failed("tried to dump a cross-reference not seen before");\r
- // otherwise, just dump the magic key\r
- dump_unsigned(context,mapping.second);\r
- }\r
-\r
- ////////////////////////////////////////////////////////////////////////////////>\r
-\r
- template<typename T>\r
- void restore_xref(restore_context& context, T*& data)\r
- throw(persistent_restore_failed)\r
- {\r
- // Note: I do not try to delete the old data because this is a cross-reference\r
- // get the magic key\r
- unsigned magic = 0;\r
- 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 this is the first view of this pointer, simply throw an exception\r
- if (!address.first) throw persistent_restore_failed("tried to restore a cross-reference not seen before");\r
- // seen before, so simply assign the old address\r
- data = (T*)address.second;\r
- }\r
-\r
- ////////////////////////////////////////////////////////////////////////////////\r
-\r
-} // end namespace stlplus\r