25 #ifndef vtkTypeTraits_h
26 #define vtkTypeTraits_h
34 #define VTK_TYPE_TRAITS(type, macro, isSigned, name, print, format) \
35 VTK_TEMPLATE_SPECIALIZE struct vtkTypeTraits< type > \
38 typedef type ValueType; \
41 enum { VTK_TYPE_ID = VTK_##macro }; \
42 static int VTKTypeID() { return VTK_##macro; } \
45 static type Min() { return VTK_##macro##_MIN; } \
48 static type Max() { return VTK_##macro##_MAX; } \
51 static int IsSigned() { return isSigned; } \
54 typedef vtkType##name SizedType; \
57 static const char* SizedName() { return #name; } \
60 typedef print PrintType; \
63 static const char* ParseFormat() { return format; } \
67 #define VTK_TYPE_NAME_FLOAT float
68 #define VTK_TYPE_NAME_DOUBLE double
69 #define VTK_TYPE_SIZED_FLOAT FLOAT32
70 #define VTK_TYPE_SIZED_DOUBLE FLOAT64
76 #define VTK_TYPE_NAME_CHAR char
77 #if VTK_TYPE_CHAR_IS_SIGNED
78 # define VTK_TYPE_SIZED_CHAR INT8
81 # define VTK_TYPE_SIZED_CHAR UINT8
84 #define VTK_TYPE_NAME_SIGNED_CHAR signed char
85 #define VTK_TYPE_NAME_UNSIGNED_CHAR unsigned char
86 #define VTK_TYPE_SIZED_SIGNED_CHAR INT8
87 #define VTK_TYPE_SIZED_UNSIGNED_CHAR UINT8
89 VTK_TYPE_TRAITS(
unsigned char, UNSIGNED_CHAR, 0, UInt8,
unsigned short,
"%hu");
92 #define VTK_TYPE_NAME_SHORT short
93 #define VTK_TYPE_NAME_UNSIGNED_SHORT unsigned short
94 #define VTK_TYPE_SIZED_SHORT INT16
95 #define VTK_TYPE_SIZED_UNSIGNED_SHORT UINT16
97 VTK_TYPE_TRAITS(
unsigned short, UNSIGNED_SHORT, 0, UInt16,
unsigned short,
101 #define VTK_TYPE_NAME_INT int
102 #define VTK_TYPE_NAME_UNSIGNED_INT unsigned int
103 #define VTK_TYPE_SIZED_INT INT32
104 #define VTK_TYPE_SIZED_UNSIGNED_INT UINT32
106 VTK_TYPE_TRAITS(
unsigned int, UNSIGNED_INT, 0, UInt32,
unsigned int,
"%u");
109 #define VTK_TYPE_NAME_LONG long
110 #define VTK_TYPE_NAME_UNSIGNED_LONG unsigned long
111 #if VTK_SIZEOF_LONG == 4
112 # define VTK_TYPE_SIZED_LONG INT32
113 # define VTK_TYPE_SIZED_UNSIGNED_LONG UINT32
115 VTK_TYPE_TRAITS(
unsigned long, UNSIGNED_LONG, 0, UInt32,
unsigned long,
"%lu");
116 #elif VTK_SIZEOF_LONG == 8
117 # define VTK_TYPE_SIZED_LONG INT64
118 # define VTK_TYPE_SIZED_UNSIGNED_LONG UINT64
120 VTK_TYPE_TRAITS(
unsigned long, UNSIGNED_LONG, 0, UInt64,
unsigned long,
"%lu");
122 # error "Type long is not 4 or 8 bytes in size."
126 #if defined(VTK_TYPE_USE_LONG_LONG)
127 # define VTK_TYPE_NAME_LONG_LONG long long
128 # define VTK_TYPE_NAME_UNSIGNED_LONG_LONG unsigned long long
129 # if VTK_SIZEOF_LONG_LONG == 8
130 # define VTK_TYPE_SIZED_LONG_LONG INT64
131 # define VTK_TYPE_SIZED_UNSIGNED_LONG_LONG UINT64
132 # define VTK_TYPE_LONG_LONG_FORMAT "%ll"
134 VTK_TYPE_LONG_LONG_FORMAT
"d");
136 unsigned long long, VTK_TYPE_LONG_LONG_FORMAT
"u");
137 # undef VTK_TYPE_LONG_LONG_FORMAT
139 # error "Type long long is not 8 bytes in size."
144 #if defined(VTK_TYPE_USE___INT64)
145 # define VTK_TYPE_NAME___INT64 __int64
146 # define VTK_TYPE_NAME_UNSIGNED___INT64 unsigned __int64
147 # if VTK_SIZEOF___INT64 == 8
148 # define VTK_TYPE_SIZED___INT64 INT64
149 # define VTK_TYPE_SIZED_UNSIGNED___INT64 UINT64
152 unsigned __int64,
"%I64u");
154 # error "Type __int64 is not 8 bytes in size."
160 #define VTK_TYPE_NAME_ID_TYPE vtkIdType
161 #if defined(VTK_USE_64BIT_IDS)
162 # define VTK_TYPE_SIZED_ID_TYPE INT64
164 # define VTK_TYPE_SIZED_ID_TYPE INT32
167 #undef VTK_TYPE_TRAITS
#define VTK_TYPE_TRAITS(type, macro, isSigned, name, print, format)
Template defining traits of native types used by VTK.