cgv
Loading...
Searching...
No Matches
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
7namespace cgv {
8 namespace type {
9 namespace info {
10
12template <TypeId type_id>
14{
15 static void* cast(void* ptr) { return ptr; }
16 static const void* cast(const void* ptr) { return ptr; }
17};
18
19template <>
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
26template <>
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};
32template <>
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};
38template <>
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};
44template <>
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};
50template <>
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};
56template <>
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};
62template <>
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};
68template <>
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};
74template <>
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};
80template <>
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};
86template <>
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
93template <>
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
100template <>
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}
complete implementation of method actions that only call one method when entering a node
Definition action.h:113
@ TI_INT16
signed integer stored in 8 bits
Definition type_id.h:20
@ TI_INT8
boolean
Definition type_id.h:19
@ TI_INT32
signed integer stored in 16 bits
Definition type_id.h:21
@ TI_STRING
wide character type
Definition type_id.h:31
@ TI_WCHAR
floating point type stored in 64 bits
Definition type_id.h:30
@ TI_FLT32
floating point type stored in 16 bits
Definition type_id.h:28
@ TI_WSTRING
string type
Definition type_id.h:32
@ TI_UINT32
unsigned integer stored in 16 bits
Definition type_id.h:25
@ TI_UINT8
signed integer stored in 64 bits
Definition type_id.h:23
@ TI_INT64
signed integer stored in 32 bits
Definition type_id.h:22
@ TI_BOOL
void
Definition type_id.h:18
@ TI_UINT16
unsigned integer stored in 8 bits
Definition type_id.h:24
@ TI_FLT64
floating point type stored in 32 bits
Definition type_id.h:29
@ TI_UINT64
unsigned integer stored in 32 bits
Definition type_id.h:26
wchar_t wchar_type
wide character type
the cgv namespace
Definition print.h:11
template to cast a pointer into a type known at compile time and specified as TypeId
Definition type_ptr.h:14