ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/traits.h
(Generate patch)

Comparing deliantra/server/include/traits.h (file contents):
Revision 1.1 by root, Thu Aug 31 09:19:34 2006 UTC vs.
Revision 1.7 by root, Tue Dec 19 04:58:05 2006 UTC

1#ifndef TRAITS_H__ 1#ifndef TRAITS_H__
2#define TRAITS_H__ 2#define TRAITS_H__
3 3
4struct client;
4struct pl; 5struct player;
5struct object; 6struct object;
6struct mapstruct; 7struct maptile;
7struct archt; 8struct archetype;
8struct region; 9struct region;
9struct party; 10struct party;
10struct mapstruct; 11struct treasurelist;
11 12
12// could have used templates, but a more traditional C api 13// could have used templates, but a more traditional C api
13// uses more explicit typing which is ok for this purpose. 14// uses more explicit typing which is ok for this purpose.
14enum data_type 15enum data_type
15{ 16{
20 DT_DOUBLE, 21 DT_DOUBLE,
21 DT_STRING, // 0-terminated string 22 DT_STRING, // 0-terminated string
22 DT_DATA, // string + length 23 DT_DATA, // string + length
23 DT_OBJECT, 24 DT_OBJECT,
24 DT_MAP, 25 DT_MAP,
26 DT_CLIENT,
25 DT_PLAYER, 27 DT_PLAYER,
26 DT_ARCH, 28 DT_ARCH,
27 DT_PARTY, 29 DT_PARTY,
28 DT_REGION, 30 DT_REGION,
29 31
33template<typename T> 35template<typename T>
34struct cftype { }; 36struct cftype { };
35 37
36template<> 38template<>
37struct cftype<int> { 39struct cftype<int> {
38 enum { dt = DT_INT }; 40 static const data_type dt = DT_INT;
39}; 41};
40 42
41template<> 43template<>
42struct cftype<sint64> { 44struct cftype<sint64> {
43 enum { dt = DT_INT64 }; 45 static const data_type dt = DT_INT64;
44}; 46};
45 47
46template<> 48template<>
47struct cftype<double> { 49struct cftype<double> {
48 enum { dt = DT_DOUBLE }; 50 static const data_type dt = DT_DOUBLE;
49}; 51};
50 52
51template<> 53template<>
52struct cftype<const char *> { 54struct cftype<const char *> {
53 enum { dt = DT_STRING }; 55 static const data_type dt = DT_STRING;
54}; 56};
55 57
56template<> 58template<>
57struct cftype<object> { 59struct cftype<object> {
58 enum { dt = DT_OBJECT }; 60 static const data_type dt = DT_OBJECT;
59}; 61};
60 62
61template<> 63template<>
62struct cftype<struct pl> { 64struct cftype<client> {
63 enum { dt = DT_PLAYER }; 65 static const data_type dt = DT_CLIENT;
64}; 66};
65 67
66template<> 68template<>
67struct cftype<mapstruct> { 69struct cftype<player> {
68 enum { dt = DT_MAP }; 70 static const data_type dt = DT_PLAYER;
69}; 71};
70 72
71template<> 73template<>
74struct cftype<maptile> {
75 static const data_type dt = DT_MAP;
76};
77
78template<>
72struct cftype<struct archt> { 79struct cftype<archetype> {
73 enum { dt = DT_ARCH }; 80 static const data_type dt = DT_ARCH;
74}; 81};
75 82
76template<> 83template<>
77struct cftype<party> { 84struct cftype<party> {
78 enum { dt = DT_PARTY }; 85 static const data_type dt = DT_PARTY;
79}; 86};
80 87
81template<> 88template<>
82struct cftype<region> { 89struct cftype<region> {
83 enum { dt = DT_REGION }; 90 static const data_type dt = DT_REGION;
91};
92
93template<>
94struct cftype<treasurelist> {
95 static const data_type dt = DT_REGION;
84}; 96};
85 97
86#endif 98#endif
87 99

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines