cgv
type_ptr.h
1 #pragma once
2 
3 #include <string>
4 #include <cgv/type/standard_types.h>
5 #include <cgv/type/info/type_id.h>
6 
7 namespace cgv {
8  namespace type {
9  namespace info {
10 
12 template <TypeId type_id>
13 struct type_ptr
14 {
15  static void* cast(void* ptr) { return ptr; }
16  static const void* cast(const void* ptr) { return ptr; }
17 };
18 
19 template <>
20 struct type_ptr<TI_BOOL>
21 {
22  static bool* cast(void* ptr) { return static_cast<bool*>(ptr); }
23  static const bool* cast(const void* ptr) { return static_cast<const bool*>(ptr); }
24 };
25 
26 template <>
27 struct type_ptr<TI_INT8>
28 {
29  static int8_type* cast(void* ptr) { return static_cast<int8_type*>(ptr); }
30  static const int8_type* cast(const void* ptr) { return static_cast<const int8_type*>(ptr); }
31 };
32 template <>
33 struct type_ptr<TI_INT16>
34 {
35  static int16_type* cast(void* ptr) { return static_cast<int16_type*>(ptr); }
36  static const int16_type* cast(const void* ptr) { return static_cast<const int16_type*>(ptr); }
37 };
38 template <>
39 struct type_ptr<TI_INT32>
40 {
41  static int32_type* cast(void* ptr) { return static_cast<int32_type*>(ptr); }
42  static const int32_type* cast(const void* ptr) { return static_cast<const int32_type*>(ptr); }
43 };
44 template <>
45 struct type_ptr<TI_INT64>
46 {
47  static int64_type* cast(void* ptr) { return static_cast<int64_type*>(ptr); }
48  static const int64_type* cast(const void* ptr) { return static_cast<const int64_type*>(ptr); }
49 };
50 template <>
51 struct type_ptr<TI_UINT8>
52 {
53  static uint8_type* cast(void* ptr) { return static_cast<uint8_type*>(ptr); }
54  static const uint8_type* cast(const void* ptr) { return static_cast<const uint8_type*>(ptr); }
55 };
56 template <>
57 struct type_ptr<TI_UINT16>
58 {
59  static uint16_type* cast(void* ptr) { return static_cast<uint16_type*>(ptr); }
60  static const uint16_type* cast(const void* ptr) { return static_cast<const uint16_type*>(ptr); }
61 };
62 template <>
63 struct type_ptr<TI_UINT32>
64 {
65  static uint32_type* cast(void* ptr) { return static_cast<uint32_type*>(ptr); }
66  static const uint32_type* cast(const void* ptr) { return static_cast<const uint32_type*>(ptr); }
67 };
68 template <>
69 struct type_ptr<TI_UINT64>
70 {
71  static uint64_type* cast(void* ptr) { return static_cast<uint64_type*>(ptr); }
72  static const uint64_type* cast(const void* ptr) { return static_cast<const uint64_type*>(ptr); }
73 };
74 template <>
75 struct type_ptr<TI_FLT32>
76 {
77  static flt32_type* cast(void* ptr) { return static_cast<flt32_type*>(ptr); }
78  static const flt32_type* cast(const void* ptr) { return static_cast<const flt32_type*>(ptr); }
79 };
80 template <>
81 struct type_ptr<TI_FLT64>
82 {
83  static flt64_type* cast(void* ptr) { return static_cast<flt64_type*>(ptr); }
84  static const flt64_type* cast(const void* ptr) { return static_cast<const flt64_type*>(ptr); }
85 };
86 template <>
87 struct type_ptr<TI_STRING>
88 {
89  static std::string* cast(void* ptr) { return static_cast<std::string*>(ptr); }
90  static const std::string* cast(const void* ptr) { return static_cast<const std::string*>(ptr); }
91 };
92 
93 template <>
94 struct type_ptr<TI_WCHAR>
95 {
96  static wchar_type* cast(void* ptr) { return static_cast<wchar_type*>(ptr); }
97  static const wchar_type* cast(const void* ptr) { return static_cast<const wchar_type*>(ptr); }
98 };
99 
100 template <>
101 struct type_ptr<TI_WSTRING>
102 {
103  static std::wstring* cast(void* ptr) { return static_cast<std::wstring*>(ptr); }
104  static const std::wstring* cast(const void* ptr) { return static_cast<const std::wstring*>(ptr); }
105 };
106 
107 
108  }
109  }
110 }
cgv::type::int32_type
int int32_type
this type provides an 32 bit signed integer type
Definition: standard_types.h:12
cgv::type::info::TI_WCHAR
@ TI_WCHAR
floating point type stored in 64 bits
Definition: type_id.h:30
cgv::type::flt64_type
double flt64_type
this type provides a 64 bit floating point type
Definition: standard_types.h:26
cgv::type::info::TI_INT32
@ TI_INT32
signed integer stored in 16 bits
Definition: type_id.h:21
cgv::type::uint8_type
unsigned char uint8_type
this type provides an 8 bit unsigned integer type
Definition: standard_types.h:16
cgv::type::info::TI_UINT64
@ TI_UINT64
unsigned integer stored in 32 bits
Definition: type_id.h:26
cgv::type::info::TI_STRING
@ TI_STRING
wide character type
Definition: type_id.h:31
cgv::type::uint16_type
unsigned short uint16_type
this type provides an 16 bit unsigned integer type
Definition: standard_types.h:18
cgv::type::int16_type
short int16_type
this type provides an 16 bit signed integer type
Definition: standard_types.h:10
cgv::type::info::TI_FLT64
@ TI_FLT64
floating point type stored in 32 bits
Definition: type_id.h:29
cgv::type::info::TI_INT16
@ TI_INT16
signed integer stored in 8 bits
Definition: type_id.h:20
cgv::type::info::TI_UINT32
@ TI_UINT32
unsigned integer stored in 16 bits
Definition: type_id.h:25
cgv::type::info::TI_UINT16
@ TI_UINT16
unsigned integer stored in 8 bits
Definition: type_id.h:24
cgv::type::info::TI_INT8
@ TI_INT8
boolean
Definition: type_id.h:19
cgv::type::info::TI_FLT32
@ TI_FLT32
floating point type stored in 16 bits
Definition: type_id.h:28
cgv::type::int64_type
long long int64_type
this type provides an 64 bit signed integer type
Definition: standard_types.h:14
cgv::type::info::TI_INT64
@ TI_INT64
signed integer stored in 32 bits
Definition: type_id.h:22
cgv::type::info::TI_WSTRING
@ TI_WSTRING
string type
Definition: type_id.h:32
cgv::type::uint32_type
unsigned int uint32_type
this type provides an 32 bit unsigned integer type
Definition: standard_types.h:20
cgv::type::flt32_type
float flt32_type
this type provides a 32 bit floating point type
Definition: standard_types.h:24
cgv::type::info::TI_BOOL
@ TI_BOOL
void
Definition: type_id.h:18
cgv::type::info::TI_UINT8
@ TI_UINT8
signed integer stored in 64 bits
Definition: type_id.h:23
cgv::type::wchar_type
wchar_t wchar_type
wide character type
Definition: standard_types.h:28
cgv
the cgv namespace
Definition: vr_calib.cxx:9
cgv::type::info::type_ptr
template to cast a pointer into a type known at compile time and specified as TypeId
Definition: type_ptr.h:14
cgv::type::uint64_type
unsigned long long uint64_type
this type provides an 64 bit unsigned integer type
Definition: standard_types.h:22
cgv::type::int8_type
char int8_type
this type provides an 8 bit signed integer type
Definition: standard_types.h:8