comparison orange/util/Traits.d @ 0:f7b078e85f7f

First commit
author Jacob Carlborg <doob@me.com>
date Wed, 26 May 2010 17:19:13 +0200
parents
children 11a31bd929f9
comparison
equal deleted inserted replaced
-1:000000000000 0:f7b078e85f7f
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 }