annotate orange/serialization/archives/Archive.d @ 34:068e853b9c07 experimental

Cleaned up. Updated to latest D2 compiler.
author Jacob Carlborg <doob@me.com>
date Mon, 01 Aug 2011 20:34:54 +0200
parents 4fea56a5849f
children 511d1ef4e299
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
1 /**
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
2 * Copyright: Copyright (c) 2010 Jacob Carlborg.
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
3 * Authors: Jacob Carlborg
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
4 * Version: Initial created: Feb 6, 2010
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
6 */
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
7 module orange.serialization.archives.Archive;
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
8
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
9 version (Tango)
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
10 import tango.util.Convert;
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
11
9
99c52d46822a Serialization works now with D2, deserialization still doesn't work
Jacob Carlborg <doob@me.com>
parents: 0
diff changeset
12 else
99c52d46822a Serialization works now with D2, deserialization still doesn't work
Jacob Carlborg <doob@me.com>
parents: 0
diff changeset
13 {
99c52d46822a Serialization works now with D2, deserialization still doesn't work
Jacob Carlborg <doob@me.com>
parents: 0
diff changeset
14 import std.conv;
34
068e853b9c07 Cleaned up. Updated to latest D2 compiler.
Jacob Carlborg <doob@me.com>
parents: 33
diff changeset
15 alias ConvException ConversionException;
9
99c52d46822a Serialization works now with D2, deserialization still doesn't work
Jacob Carlborg <doob@me.com>
parents: 0
diff changeset
16 }
99c52d46822a Serialization works now with D2, deserialization still doesn't work
Jacob Carlborg <doob@me.com>
parents: 0
diff changeset
17
0
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
18 import orange.serialization.archives.ArchiveException;
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
19 import orange.core.string;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
20
25
b51e953f79eb Second step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 24
diff changeset
21 private enum ArchiveMode
b51e953f79eb Second step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 24
diff changeset
22 {
b51e953f79eb Second step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 24
diff changeset
23 archiving,
b51e953f79eb Second step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 24
diff changeset
24 unarchiving
b51e953f79eb Second step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 24
diff changeset
25 }
b51e953f79eb Second step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 24
diff changeset
26
24
55f0a9d5df8d First step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 20
diff changeset
27 struct Array
55f0a9d5df8d First step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 20
diff changeset
28 {
34
068e853b9c07 Cleaned up. Updated to latest D2 compiler.
Jacob Carlborg <doob@me.com>
parents: 33
diff changeset
29 version (Tango) void* ptr;
068e853b9c07 Cleaned up. Updated to latest D2 compiler.
Jacob Carlborg <doob@me.com>
parents: 33
diff changeset
30 else mixin("immutable(void)* ptr;");
068e853b9c07 Cleaned up. Updated to latest D2 compiler.
Jacob Carlborg <doob@me.com>
parents: 33
diff changeset
31
24
55f0a9d5df8d First step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 20
diff changeset
32 size_t length;
55f0a9d5df8d First step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 20
diff changeset
33 size_t elementSize;
55f0a9d5df8d First step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 20
diff changeset
34
55f0a9d5df8d First step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 20
diff changeset
35 bool isSliceOf (Array b)
55f0a9d5df8d First step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 20
diff changeset
36 {
55f0a9d5df8d First step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 20
diff changeset
37 return ptr >= b.ptr && ptr + length * elementSize <= b.ptr + b.length * b.elementSize;
55f0a9d5df8d First step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 20
diff changeset
38 }
55f0a9d5df8d First step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 20
diff changeset
39 }
0
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
40
20
9a575087b961 Added support for slices. Strings and arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents: 18
diff changeset
41 struct Slice
9a575087b961 Added support for slices. Strings and arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents: 18
diff changeset
42 {
9a575087b961 Added support for slices. Strings and arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents: 18
diff changeset
43 size_t length;
24
55f0a9d5df8d First step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 20
diff changeset
44 size_t offset;
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
45 size_t id = size_t.max;
20
9a575087b961 Added support for slices. Strings and arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents: 18
diff changeset
46 }
9a575087b961 Added support for slices. Strings and arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents: 18
diff changeset
47
28
bffcbc8c392b Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents: 26
diff changeset
48 interface Archive
0
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
49 {
34
068e853b9c07 Cleaned up. Updated to latest D2 compiler.
Jacob Carlborg <doob@me.com>
parents: 33
diff changeset
50 alias size_t Id;
068e853b9c07 Cleaned up. Updated to latest D2 compiler.
Jacob Carlborg <doob@me.com>
parents: 33
diff changeset
51
068e853b9c07 Cleaned up. Updated to latest D2 compiler.
Jacob Carlborg <doob@me.com>
parents: 33
diff changeset
52 version (Tango) alias void[] UntypedData;
068e853b9c07 Cleaned up. Updated to latest D2 compiler.
Jacob Carlborg <doob@me.com>
parents: 33
diff changeset
53 else mixin ("alias immutable(void)[] UntypedData;");
24
55f0a9d5df8d First step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 20
diff changeset
54
0
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
55 void beginArchiving ();
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
56 void beginUnarchiving (UntypedData data);
24
55f0a9d5df8d First step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 20
diff changeset
57
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
58 UntypedData untypedData ();
0
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
59 void reset ();
24
55f0a9d5df8d First step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 20
diff changeset
60
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
61 void archiveArray (Array array, string type, string key, Id id, void delegate () dg);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
62 void archiveAssociativeArray (string keyType, string valueType, size_t length, string key, Id id, void delegate () dg);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
63 void archiveAssociativeArrayKey (string key, void delegate () dg);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
64 void archiveAssociativeArrayValue (string key, void delegate () dg);
24
55f0a9d5df8d First step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 20
diff changeset
65
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
66 void archiveEnum (bool value, string baseType, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
67 void archiveEnum (byte value, string baseType, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
68 void archiveEnum (char value, string baseType, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
69 void archiveEnum (dchar value, string baseType, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
70 void archiveEnum (int value, string baseType, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
71 void archiveEnum (long value, string baseType, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
72 void archiveEnum (short value, string baseType, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
73 void archiveEnum (ubyte value, string baseType, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
74 void archiveEnum (uint value, string baseType, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
75 void archiveEnum (ulong value, string baseType, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
76 void archiveEnum (ushort value, string baseType, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
77 void archiveEnum (wchar value, string baseType, string key, Id id);
24
55f0a9d5df8d First step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 20
diff changeset
78
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
79 void archiveBaseClass (string type, string key, Id id);
24
55f0a9d5df8d First step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 20
diff changeset
80 void archiveNull (string type, string key);
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
81 void archiveObject (string runtimeType, string type, string key, Id id, void delegate () dg);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
82 void archivePointer (string key, Id id, void delegate () dg);
33
4fea56a5849f Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents: 29
diff changeset
83 void archivePointer (Id pointeeId, string key, Id id);
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
84 void archiveReference (string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
85 void archiveSlice (Slice slice, Id sliceId, Id arrayId);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
86 void archiveStruct (string type, string key, Id id, void delegate () dg);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
87 void archiveTypedef (string type, string key, Id id, void delegate () dg);
24
55f0a9d5df8d First step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 20
diff changeset
88
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
89 void archive (string value, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
90 void archive (wstring value, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
91 void archive (dstring value, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
92 void archive (bool value, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
93 void archive (byte value, string key, Id id);
33
4fea56a5849f Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents: 29
diff changeset
94 //void archive (cdouble value, string key, Id id); // currently not supported by to!()
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
95 //void archive (cent value, string key, Id id);
33
4fea56a5849f Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents: 29
diff changeset
96 //void archive (cfloat value, string key, Id id); // currently not supported by to!()
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
97 void archive (char value, string key, Id id); // currently not implemented but a reserved keyword
33
4fea56a5849f Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents: 29
diff changeset
98 //void archive (creal value, string key, Id id); // currently not supported by to!()
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
99 void archive (dchar value, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
100 void archive (double value, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
101 void archive (float value, string key, Id id);
33
4fea56a5849f Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents: 29
diff changeset
102 //void archive (idouble value, string key, Id id); // currently not supported by to!()
4fea56a5849f Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents: 29
diff changeset
103 //void archive (ifloat value, string key, Id id); // currently not supported by to!()
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
104 void archive (int value, string key, Id id);
33
4fea56a5849f Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents: 29
diff changeset
105 //void archive (ireal value, string key, Id id); // currently not supported by to!()
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
106 void archive (long value, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
107 void archive (real value, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
108 void archive (short value, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
109 void archive (ubyte value, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
110 //void archive (ucent value, string key, Id id); // currently not implemented but a reserved keyword
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
111 void archive (uint value, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
112 void archive (ulong value, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
113 void archive (ushort value, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
114 void archive (wchar value, string key, Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
115
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
116 Id unarchiveArray (string key, void delegate (size_t length) dg);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
117 void unarchiveArray (Id id, void delegate (size_t length) dg);
28
bffcbc8c392b Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents: 26
diff changeset
118 Id unarchiveAssociativeArray (string type, void delegate (size_t length) dg);
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
119 void unarchiveAssociativeArrayKey (string key, void delegate () dg);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
120 void unarchiveAssociativeArrayValue (string key, void delegate () dg);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
121
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
122 bool unarchiveEnumBool (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
123 byte unarchiveEnumByte (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
124 char unarchiveEnumChar (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
125 dchar unarchiveEnumDchar (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
126 int unarchiveEnumInt (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
127 long unarchiveEnumLong (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
128 short unarchiveEnumShort (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
129 ubyte unarchiveEnumUbyte (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
130 uint unarchiveEnumUint (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
131 ulong unarchiveEnumUlong (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
132 ushort unarchiveEnumUshort (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
133 wchar unarchiveEnumWchar (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
134
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
135 // Object unarchiveBaseClass (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
136 // void unarchiveNull (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
137 void unarchiveObject (string key, out Id id, out Object result, void delegate () dg);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
138 Id unarchivePointer (string key, void delegate () dg);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
139 Id unarchiveReference (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
140 Slice unarchiveSlice (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
141 void unarchiveStruct (string key, void delegate () dg);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
142 void unarchiveTypedef (string key, void delegate () dg);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
143
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
144 string unarchiveString (string key, out Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
145 wstring unarchiveWstring (string key, out Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
146 dstring unarchiveDstring (string key, out Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
147
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
148 string unarchiveString (Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
149 wstring unarchiveWstring (Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
150 dstring unarchiveDstring (Id id);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
151 bool unarchiveBool (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
152 byte unarchiveByte (string key);
33
4fea56a5849f Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents: 29
diff changeset
153 //cdouble unarchiveCdouble (string key); // currently not supported by to!()
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
154 //cent unarchiveCent (string key); // currently not implemented but a reserved keyword
33
4fea56a5849f Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents: 29
diff changeset
155 //cfloat unarchiveCfloat (string key); // currently not supported by to!()
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
156 char unarchiveChar (string key); // currently not implemented but a reserved keyword
33
4fea56a5849f Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents: 29
diff changeset
157 //creal unarchiveCreal (string key); // currently not supported by to!()
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
158 dchar unarchiveDchar (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
159 double unarchiveDouble (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
160 float unarchiveFloat (string key);
33
4fea56a5849f Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents: 29
diff changeset
161 //idouble unarchiveIdouble (string key); // currently not supported by to!()
4fea56a5849f Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents: 29
diff changeset
162 //ifloat unarchiveIfloat (string key); // currently not supported by to!()*/
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
163 int unarchiveInt (string key);
34
068e853b9c07 Cleaned up. Updated to latest D2 compiler.
Jacob Carlborg <doob@me.com>
parents: 33
diff changeset
164 //int unarchiveInt (Id id);
33
4fea56a5849f Now both internal and external pointers work.
Jacob Carlborg <doob@me.com>
parents: 29
diff changeset
165 //ireal unarchiveIreal (string key); // currently not supported by to!()
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
166 long unarchiveLong (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
167 real unarchiveReal (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
168 short unarchiveShort (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
169 ubyte unarchiveUbyte (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
170 //ucent unarchiveCcent (string key); // currently not implemented but a reserved keyword
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
171 uint unarchiveUint (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
172 ulong unarchiveUlong (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
173 ushort unarchiveUshort (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
174 wchar unarchiveWchar (string key);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
175
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
176 void postProcessArray (Id id);
29
c422ff6477dd Better handling of serializing pointers.
Jacob Carlborg <doob@me.com>
parents: 28
diff changeset
177 void postProcessPointer (Id id);
0
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
178 }
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
179
28
bffcbc8c392b Associative arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents: 26
diff changeset
180 abstract class Base (U) : Archive
0
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
181 {
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
182 version (Tango) alias U[] Data;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
183 else mixin ("alias immutable(U)[] Data;");
0
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
184
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
185 alias void delegate (ArchiveException exception, string[] data) ErrorCallback;
18
3d42ea434d46 Added an error callback. Fixes #3 and #4.
Jacob Carlborg <doob@me.com>
parents: 9
diff changeset
186
25
b51e953f79eb Second step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 24
diff changeset
187 protected ErrorCallback errorCallback;
b51e953f79eb Second step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 24
diff changeset
188
b51e953f79eb Second step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 24
diff changeset
189 protected this (ErrorCallback errorCallback)
b51e953f79eb Second step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 24
diff changeset
190 {
b51e953f79eb Second step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 24
diff changeset
191 this.errorCallback = errorCallback;
b51e953f79eb Second step in refactoring the API.
Jacob Carlborg <doob@me.com>
parents: 24
diff changeset
192 }
18
3d42ea434d46 Added an error callback. Fixes #3 and #4.
Jacob Carlborg <doob@me.com>
parents: 9
diff changeset
193
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
194 protected Data toData (T) (T value)
0
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
195 {
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
196 try
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
197 return to!(Data)(value);
0
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
198
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
199 catch (ConversionException e)
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
200 throw new ArchiveException(e);
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
201 }
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
202
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
203 protected T fromData (T) (Data value)
0
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
204 {
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
205 try
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
206 return to!(T)(value);
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
207
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
208 catch (ConversionException e)
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
209 throw new ArchiveException(e);
20
9a575087b961 Added support for slices. Strings and arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents: 18
diff changeset
210 }
9a575087b961 Added support for slices. Strings and arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents: 18
diff changeset
211
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
212 protected Id toId (Data value)
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
213 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
214 return fromData!(Id)(value);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
215 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents: 25
diff changeset
216
20
9a575087b961 Added support for slices. Strings and arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents: 18
diff changeset
217 protected bool isSliceOf (T, U = T) (T[] a, U[] b)
9a575087b961 Added support for slices. Strings and arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents: 18
diff changeset
218 {
9a575087b961 Added support for slices. Strings and arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents: 18
diff changeset
219 void* aPtr = a.ptr;
9a575087b961 Added support for slices. Strings and arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents: 18
diff changeset
220 void* bPtr = b.ptr;
9a575087b961 Added support for slices. Strings and arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents: 18
diff changeset
221
9a575087b961 Added support for slices. Strings and arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents: 18
diff changeset
222 return aPtr >= bPtr && aPtr + a.length * T.sizeof <= bPtr + b.length * U.sizeof;
9a575087b961 Added support for slices. Strings and arrays are now treated as references.
Jacob Carlborg <doob@me.com>
parents: 18
diff changeset
223 }
0
f7b078e85f7f First commit
Jacob Carlborg <doob@me.com>
parents:
diff changeset
224 }