0
|
1 /**
|
|
2 * Copyright: Copyright (c) 2010 Jacob Carlborg.
|
|
3 * Authors: Jacob Carlborg
|
|
4 * Version: Initial created: Jan 26, 2010
|
|
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
|
|
6 */
|
|
7 module orange.util.Traits;
|
|
8
|
|
9 public import mambo.util.Traits;
|
|
10
|
|
11 import orange.serialization.Serializable;
|
|
12 import orange.serialization.archives.Archive;
|
|
13 import orange.util._;
|
|
14
|
|
15 template isArchive (T)
|
|
16 {
|
|
17 const isArchive = is(typeof({
|
|
18 alias T.DataType Foo;
|
|
19 })) &&
|
|
20
|
|
21 is(typeof(T.archive(0, TypeOfDataType!(T).init, {}))) &&
|
|
22 is(typeof(T.unarchive!(int))) &&
|
|
23 is(typeof(T.beginArchiving)) &&
|
|
24 is(typeof(T.beginUnarchiving(TypeOfDataType!(T).init))) &&
|
|
25 is(typeof(T.archiveBaseClass!(Object))) &&
|
|
26 is(typeof(T.unarchiveBaseClass!(Object))) &&
|
|
27 is(typeof(T.reset)) &&
|
|
28 is(typeof({TypeOfDataType!(T) a = T.data;})) &&
|
|
29 is(typeof(T.unarchiveAssociativeArrayVisitor!(int[string])));
|
|
30
|
|
31 }
|
|
32
|
|
33 template isSerializable (T, ArchiveType)
|
|
34 {
|
|
35 const isSerializable = is(typeof(T.toData(ArchiveType.init, ArchiveType.DataType.init))) && is(typeof(T.fromData(ArchiveType.init, ArchiveType.DataType.init)));
|
|
36 }
|
|
37
|
|
38 template isISerializable (T)
|
|
39 {
|
|
40 const isISerializable = is(T : ISerializable);
|
|
41 }
|
|
42
|
|
43 template TypeOfDataType (T)
|
|
44 {
|
|
45 alias T.DataType TypeOfDataType;
|
|
46 } |