cgv
type_id.h
1 #pragma once
2 
3 #include <string>
4 #include <cgv/type/standard_types.h>
5 #include <cgv/type/lib_begin.h>
6 
7 namespace cgv {
8  namespace type {
9  namespace info {
10 
12 enum TypeId {
13  TI_UNDEF,
15 
17 
33 
44 
59 
61 
63  TI_FIRST = TI_UNDEF,
68 };
69 
71 inline bool is_unsigned_integral(TypeId tid) { return tid>=TI_UINT8 && tid<=TI_UINT64; }
72 inline bool is_signed_integral(TypeId tid) { return tid>=TI_INT8 && tid<=TI_INT64; }
73 inline bool is_integral(TypeId tid) { return tid>=TI_INT8 && tid<=TI_UINT64; }
74 inline bool is_floating(TypeId tid) { return tid>=TI_FLT16 && tid<=TI_FLT64; }
75 inline bool is_number(TypeId tid) { return tid>=TI_INT8 && tid<=TI_FLT64; }
76 inline bool is_fundamental(TypeId tid) { return tid>=TI_FIRST_STD_TYPE && tid<=TI_LAST_STD_TYPE; }
77 inline bool is_compound(TypeId tid) { return tid>=TI_STRUCT && tid<=TI_UNION; }
78 inline bool is_type(TypeId tid) { return tid>=TI_FIRST_TYPE && tid<=TI_LAST_TYPE || tid > TI_LAST; }
79 
80 extern CGV_API TypeId get_new_type_id();
81 
83 
85 template <typename T>
86 struct type_id {
87  static TypeId get_id() { static TypeId ti = get_new_type_id(); return ti; }
88 };
89 
90 template <> struct type_id<void> { static TypeId get_id() { return TI_VOID; } };
91 template <> struct type_id<bool> { static TypeId get_id() { return TI_BOOL; } };
92 template <> struct type_id<int8_type> { static TypeId get_id() { return TI_INT8; } };
93 template <> struct type_id<int16_type> { static TypeId get_id() { return TI_INT16; } };
94 template <> struct type_id<int32_type> { static TypeId get_id() { return TI_INT32; } };
95 template <> struct type_id<int64_type> { static TypeId get_id() { return TI_INT64; } };
96 template <> struct type_id<uint8_type> { static TypeId get_id() { return TI_UINT8; } };
97 template <> struct type_id<uint16_type> { static TypeId get_id() { return TI_UINT16; } };
98 template <> struct type_id<uint32_type> { static TypeId get_id() { return TI_UINT32; } };
99 template <> struct type_id<uint64_type> { static TypeId get_id() { return TI_UINT64; } };
100 template <> struct type_id<flt32_type> { static TypeId get_id() { return TI_FLT32; } };
101 template <> struct type_id<flt64_type> { static TypeId get_id() { return TI_FLT64; } };
102 template <> struct type_id<wchar_type> { static TypeId get_id() { return TI_WCHAR; } };
103 template <> struct type_id<std::string> { static TypeId get_id() { return TI_STRING; } };
104 template <> struct type_id<std::wstring> { static TypeId get_id() { return TI_WSTRING; } };
105 
107 extern CGV_API unsigned int get_type_size(TypeId tid);
108 
110 extern CGV_API const char* get_type_name(TypeId tid);
111 
113 extern CGV_API TypeId get_type_id(const std::string& _type_name);
114 
115  }
116  }
117 }
118 
119 #include <cgv/config/lib_end.h>
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::info::TI_BIT
@ TI_BIT
used for undefined type
Definition: type_id.h:14
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::info::TI_METHOD
@ TI_METHOD
member of a compound
Definition: type_id.h:52
cgv::type::info::TypeId
TypeId
ids for the different types and type constructs
Definition: type_id.h:12
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::info::TI_SIGNATURE
@ TI_SIGNATURE
function or method parameter
Definition: type_id.h:48
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_UNION
@ TI_UNION
class type compound
Definition: type_id.h:43
cgv::type::info::TI_FLT64
@ TI_FLT64
floating point type stored in 32 bits
Definition: type_id.h:29
cgv::type::info::TI_PARAMETER
@ TI_PARAMETER
expression used for default parameters
Definition: type_id.h:47
cgv::type::info::TI_CHAR
@ TI_CHAR
always the index after the last type construct
Definition: type_id.h:62
cgv::type::info::TI_INT16
@ TI_INT16
signed integer stored in 8 bits
Definition: type_id.h:20
cgv::type::info::is_unsigned_integral
bool is_unsigned_integral(TypeId tid)
query if a kind is an unsigned integral type
Definition: type_id.h:71
cgv::type::info::TI_UINT32
@ TI_UINT32
unsigned integer stored in 16 bits
Definition: type_id.h:25
cgv::type::info::TI_METHOD_POINTER
@ TI_METHOD_POINTER
member pointer type construct
Definition: type_id.h:40
cgv::type::info::TI_LAST
@ TI_LAST
a template construct
Definition: type_id.h:60
cgv::type::info::TI_UINT16
@ TI_UINT16
unsigned integer stored in 8 bits
Definition: type_id.h:24
cgv::type::info::TI_CLASSNAME
@ TI_CLASSNAME
an undefined typename used as template parameter
Definition: type_id.h:57
cgv::type::info::TI_TYPEDEF
@ TI_TYPEDEF
an instance not a type
Definition: type_id.h:55
cgv::type::info::TI_INT8
@ TI_INT8
boolean
Definition: type_id.h:19
cgv::type::info::TI_CLASS
@ TI_CLASS
struct type compound
Definition: type_id.h:42
cgv::type::info::TI_FIRST_STD_TYPE
@ TI_FIRST_STD_TYPE
always the first type construct
Definition: type_id.h:64
cgv::type::info::TI_FIRST_TYPE
@ TI_FIRST_TYPE
always the last standard type
Definition: type_id.h:66
cgv::type::info::TI_LAST_STD_TYPE
@ TI_LAST_STD_TYPE
always the first standard type
Definition: type_id.h:65
cgv::type::info::TI_VOID
@ TI_VOID
bit based types
Definition: type_id.h:16
cgv::type::info::TI_FLT32
@ TI_FLT32
floating point type stored in 16 bits
Definition: type_id.h:28
cgv::type::info::type_id
template with a static member function get_id() of type TypeId returning the TypeId of the template a...
Definition: type_id.h:86
cgv::type::info::TI_ARRAY
@ TI_ARRAY
pointer type construct
Definition: type_id.h:37
cgv::type::info::TI_FUNCTION_POINTER
@ TI_FUNCTION_POINTER
array type construct
Definition: type_id.h:38
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::get_type_size
unsigned int get_type_size(TypeId tid)
function that returns the size of a type specified through TypeId
Definition: type_id.cxx:18
cgv::type::info::TI_INT64
@ TI_INT64
signed integer stored in 32 bits
Definition: type_id.h:22
cgv::type::info::TI_FLT16
@ TI_FLT16
unsigned integer stored in 64 bits
Definition: type_id.h:27
cgv::type::info::TI_WSTRING
@ TI_WSTRING
string type
Definition: type_id.h:32
cgv::type::info::TI_TYPENAME
@ TI_TYPENAME
a type definition
Definition: type_id.h:56
cgv::type::info::TI_MEMBER
@ TI_MEMBER
base type of a compound type
Definition: type_id.h:51
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_CONSTRUCTOR
@ TI_CONSTRUCTOR
method of a compound, not a method pointer
Definition: type_id.h:53
cgv::type::info::TI_INSTANCE
@ TI_INSTANCE
constructor of a compound
Definition: type_id.h:54
cgv::type::info::TI_UINT8
@ TI_UINT8
signed integer stored in 64 bits
Definition: type_id.h:23
cgv::type::info::TI_REFERENCE
@ TI_REFERENCE
all enum types
Definition: type_id.h:35
cgv::type::info::get_type_name
const char * get_type_name(TypeId tid)
function that returns the name of a type specified through TypeId
Definition: type_id.cxx:117
cgv::type::wchar_type
wchar_t wchar_type
wide character type
Definition: standard_types.h:28
cgv::type::info::TI_POINTER
@ TI_POINTER
reference type construct
Definition: type_id.h:36
cgv::type::info::TI_LAST_TYPE
@ TI_LAST_TYPE
always the first standard type
Definition: type_id.h:67
cgv::type::info::get_type_id
TypeId get_type_id(const std::string &_type_name)
function that returns the type id of a type name
Definition: type_id.cxx:53
cgv::type::info::TI_ENUM
@ TI_ENUM
string type
Definition: type_id.h:34
cgv::type::info::TI_BASE
@ TI_BASE
function not a function pointer
Definition: type_id.h:50
cgv::type::info::TI_MEMBER_POINTER
@ TI_MEMBER_POINTER
function pointer type construct
Definition: type_id.h:39
cgv::type::info::TI_STRUCT
@ TI_STRUCT
method pointer type construct
Definition: type_id.h:41
cgv::type::info::TI_FUNCTION
@ TI_FUNCTION
function or method signature
Definition: type_id.h:49
cgv
the cgv namespace
Definition: vr_calib.cxx:9
cgv::type::info::TI_TEMPLATE
@ TI_TEMPLATE
an undefined class name used as template parameter
Definition: type_id.h:58
cgv::type::info::TI_FIRST
@ TI_FIRST
alias for character type
Definition: type_id.h:63
cgv::type::info::TI_CONST
@ TI_CONST
union type compound
Definition: type_id.h:45
cgv::type::info::TI_EXPRESSION
@ TI_EXPRESSION
const modifier
Definition: type_id.h:46
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