simple_type.h
1 /*************************************************************************/
2 /* simple_type.h */
3 /*************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* http://www.godotengine.org */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
9 /* */
10 /* Permission is hereby granted, free of charge, to any person obtaining */
11 /* a copy of this software and associated documentation files (the */
12 /* "Software"), to deal in the Software without restriction, including */
13 /* without limitation the rights to use, copy, modify, merge, publish, */
14 /* distribute, sublicense, and/or sell copies of the Software, and to */
15 /* permit persons to whom the Software is furnished to do so, subject to */
16 /* the following conditions: */
17 /* */
18 /* The above copyright notice and this permission notice shall be */
19 /* included in all copies or substantial portions of the Software. */
20 /* */
21 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
22 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
23 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
24 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
25 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
26 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
27 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
28 /*************************************************************************/
29 #ifndef SIMPLE_TYPE_H
30 #define SIMPLE_TYPE_H
31 
32 /* Batch of specializations to obtain the actual simple type */
33 
34 template<class T>
35 struct GetSimpleType {
36 
37  T type;
38 };
39 
40 template<class T>
42 
43  typedef T type_t;
44 };
45 
46 template<class T>
47 struct GetSimpleType<T&> {
48 
49  T type;
50 
51 };
52 
53 template<class T>
54 struct GetSimpleTypeT<T&> {
55 
56  typedef T type_t;
57 };
58 
59 template<class T>
60 struct GetSimpleType<T const> {
61 
62  T type;
63  _FORCE_INLINE_ GetSimpleType() { }
64 
65 };
66 
67 template<class T>
68 struct GetSimpleTypeT<T const> {
69 
70  typedef T type_t;
71 };
72 
73 template<class T>
74 struct GetSimpleType<const T&> {
75 
76  T type;
77  _FORCE_INLINE_ GetSimpleType() { }
78 
79 };
80 
81 template<class T>
82 struct GetSimpleType<T*> {
83 
84  T *type;
85  _FORCE_INLINE_ GetSimpleType() { type=NULL; }
86 };
87 
88 template<class T>
89 struct GetSimpleType<const T*> {
90 
91  T *type;
92  _FORCE_INLINE_ GetSimpleType() { type=NULL; }
93 };
94 
95 
96 #define SIMPLE_NUMERIC_TYPE(m_type)\
97 template<>\
98 struct GetSimpleType<m_type> { \
99  m_type type;\
100  _FORCE_INLINE_ GetSimpleType() { type=(m_type)0; } \
101 };\
102 template<>\
103 struct GetSimpleType<m_type const> { \
104  m_type type;\
105  _FORCE_INLINE_ GetSimpleType() { type=(m_type)0; } \
106 };\
107 template<>\
108 struct GetSimpleType<m_type&> { \
109  m_type type;\
110  _FORCE_INLINE_ GetSimpleType() { type=(m_type)0; } \
111 };\
112 template<>\
113 struct GetSimpleType<const m_type&> { \
114  m_type type;\
115  _FORCE_INLINE_ GetSimpleType() { type=(m_type)0; } \
116 };\
117 
118 SIMPLE_NUMERIC_TYPE(bool);
119 SIMPLE_NUMERIC_TYPE(uint8_t);
120 SIMPLE_NUMERIC_TYPE(int8_t);
121 SIMPLE_NUMERIC_TYPE(uint16_t);
122 SIMPLE_NUMERIC_TYPE(int16_t);
123 SIMPLE_NUMERIC_TYPE(uint32_t);
124 SIMPLE_NUMERIC_TYPE(int32_t);
125 SIMPLE_NUMERIC_TYPE(int64_t);
126 SIMPLE_NUMERIC_TYPE(uint64_t);
127 SIMPLE_NUMERIC_TYPE(float);
128 SIMPLE_NUMERIC_TYPE(double);
129 
130 
131 
132 
133 #endif
134 
Definition: simple_type.h:41
Definition: simple_type.h:35