aboutsummaryrefslogtreecommitdiff
path: root/src/archive.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-04-10 21:48:23 +0000
committerMike Buland <eichlan@xagasoft.com>2007-04-10 21:48:23 +0000
commit1fa3ca5f24c018126333ca2d6609730e1ae17386 (patch)
tree2877418e3b41c6fbd6505545cc01075899e5c7f8 /src/archive.h
parent070374dde0f53bff26078550997f7682e84412e5 (diff)
downloadlibbu++-1fa3ca5f24c018126333ca2d6609730e1ae17386.tar.gz
libbu++-1fa3ca5f24c018126333ca2d6609730e1ae17386.tar.bz2
libbu++-1fa3ca5f24c018126333ca2d6609730e1ae17386.tar.xz
libbu++-1fa3ca5f24c018126333ca2d6609730e1ae17386.zip
Added more comments, help, and socket actually reads and writes some, but it's
not done. I need to decide how I want to do the buffering...
Diffstat (limited to '')
-rw-r--r--src/archive.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/archive.h b/src/archive.h
index 9ac3303..2f782d3 100644
--- a/src/archive.h
+++ b/src/archive.h
@@ -9,6 +9,53 @@
9 9
10namespace Bu 10namespace Bu
11{ 11{
12 /**
13 * Provides a framework for serialization of objects and primitives. The
14 * archive will handle any basic primitive, a few special types, like char *
15 * strings, as well as STL classes and anything that inherits from the
16 * Archival class. Each Archive operates on a Stream, so you can send the
17 * data using an Archive almost anywhere.
18 *
19 * In order to use an Archive to store something to a file, try something
20 * like:
21 *@code
22 * File sOut("output", "wb"); // This is a stream subclass
23 * Archive ar( sOut, Archive::save );
24 * ar << myClass;
25 @endcode
26 * In this example myClass is any class that inherits from Archival. When
27 * the storage operator is called, the Archival::archive() function in the
28 * myClass object is called with a reference to the Archive. This can be
29 * handled in one of two ways:
30 *@code
31 * void MyClass::archive( Archive &ar )
32 * {
33 * ar && sName && nAge && sJob;
34 * }
35 @endcode
36 * Here we don't worry about weather we're loading or saving by using the
37 * smart && operator. This allows us to write very consistent, very simple
38 * archive functions that really do a lot of work. If we wanted to do
39 * something different in the case of loading or saving we would do:
40 *@code
41 * void MyClass::archive( Archive &ar )
42 * {
43 * if( ar.isLoading() )
44 * {
45 * ar >> sName >> nAge >> sJob;
46 * } else
47 * {
48 * ar << sName << nAge << sJob;
49 * }
50 * }
51 @endcode
52 * Archive currently does not provide facility to make fully portable
53 * archives. For example, it will not convert between endianness for you,
54 * nor will it take into account differences between primitive sizes on
55 * different platforms. This, at the moment, is up to the user to ensure.
56 * One way of dealing with the latter problem is to make sure and use
57 * explicit primitive types from the stdint.h header, i.e. int32_t.
58 */
12 class Archive 59 class Archive
13 { 60 {
14 private: 61 private: