cgv
Loading...
Searching...
No Matches
type_name.h
1#pragma once
2
3#include <string>
4#include <cgv/type/info/type_id.h>
5#include <cgv/type/cond/is_standard_type.h>
6#include <typeinfo>
7
8#include <cgv/type/lib_begin.h>
9
10namespace cgv {
11 namespace type {
13 namespace info {
14
16extern CGV_API std::string extract_type_name(const std::type_info& ti);
17
18namespace detail {
19 // implementation of type_name traits for standard types
20 template <typename T, bool is_std = true>
22 {
23 // use type id to determine name of standard type
24 static const char* get_name() { return get_type_name(type_id<T>::get_id()); }
25 };
26
27 // implementation of type_name traits for all other types
28 template <typename T>
29 struct dispatch_type_name<T,false>
30 {
31 // use RTTI and clean up the resulting name from unwanted keywords
32 static const char* get_name() {
33 static std::string type_name = extract_type_name(typeid(T));
34 return type_name.c_str();
35 }
36 };
37}
38
52template <typename T>
58
59 }
60 }
61}
62
63#include <cgv/config/lib_end.h>
const char * get_type_name(TypeId tid)
function that returns the name of a type specified through TypeId
Definition type_id.cxx:117
std::string extract_type_name(const std::type_info &ti)
extract a type name from an type_info structure that does not contain the class, struct nor enum keyw...
Definition type_name.cxx:9
the cgv namespace
Definition print.h:11
template with a static member function get_id() of type TypeId returning the TypeId of the template a...
Definition type_id.h:86
traits class with a static function get_name() of type const char* that returns the type name of the ...
Definition type_name.h:54
static const char * get_name()
return special name for standard types or type name from RTTI cleaned from keywords for all other typ...
Definition type_name.h:56