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