persistence/persistent_cstring.hpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef STLPLUS_PERSISTENT_CSTRING
#define STLPLUS_PERSISTENT_CSTRING
////////////////////////////////////////////////////////////////////////////////
 
//   Author:    Andy Rushton
//   Copyright: (c) Southampton University 1999-2004
//              (c) Andy Rushton           2004 onwards
//   License:   BSD License, see ../docs/license.html
 
//   Persistence of C-style char* strings
 
//   These are handled differently to other pointer types
 
//   Warning! This means that pointers to char cannot be supported, since there
//   is no type difference between a pointer to char and a C-style array of char.
 
//   Warning! The restore deletes any old value of the data parameter and
//   allocates a new char* which is (just) big enough and assigns it to the data
//   field. This is because there is no way of knowing how long a char* is so
//   the passed parameter is not safe to use. The allocation is done using
//   standard new. If the data field is non-null on entry it will be deleted by
//   standard delete. Best to make it null in the first place.
 
////////////////////////////////////////////////////////////////////////////////
 
#include "persistence_fixes.hpp"
#include "persistent_contexts.hpp"
 
////////////////////////////////////////////////////////////////////////////////
 
namespace stlplus
{
 
  // exceptions: persistent_dump_failed
  void dump_cstring(dump_context&, const char* data) ;
  // exceptions: persistent_restore_failed
  void restore_cstring(restore_context&, char*& data) ;
 
} // end namespace stlplus
 
  ////////////////////////////////////////////////////////////////////////////////
#endif