introspection: rename type_string to type_name

This commit is contained in:
Danny Robson 2016-07-28 13:45:09 +10:00
parent ed7c466d8d
commit 25a9c6fafc
2 changed files with 36 additions and 38 deletions

View File

@ -18,21 +18,21 @@
///////////////////////////////////////////////////////////////////////////////
constexpr char util::type_string<bool>::value[];
constexpr char util::type_name<bool>::value[];
constexpr char util::type_string< int8_t>::value[];
constexpr char util::type_string< int16_t>::value[];
constexpr char util::type_string< int32_t>::value[];
constexpr char util::type_string< int64_t>::value[];
constexpr char util::type_name< int8_t>::value[];
constexpr char util::type_name< int16_t>::value[];
constexpr char util::type_name< int32_t>::value[];
constexpr char util::type_name< int64_t>::value[];
constexpr char util::type_string< uint8_t>::value[];
constexpr char util::type_string<uint16_t>::value[];
constexpr char util::type_string<uint32_t>::value[];
constexpr char util::type_string<uint64_t>::value[];
constexpr char util::type_name< uint8_t>::value[];
constexpr char util::type_name<uint16_t>::value[];
constexpr char util::type_name<uint32_t>::value[];
constexpr char util::type_name<uint64_t>::value[];
constexpr char util::type_string<float>::value[];
constexpr char util::type_string<double>::value[];
constexpr char util::type_name<float>::value[];
constexpr char util::type_name<double>::value[];
constexpr char util::type_string<std::string>::value[];
constexpr char util::type_string<char*>::value[];
constexpr char util::type_string<const char*>::value[];
constexpr char util::type_name<std::string>::value[];
constexpr char util::type_name<char*>::value[];
constexpr char util::type_name<const char*>::value[];

View File

@ -29,40 +29,38 @@ namespace util {
template <
typename T
>
struct type_string {
// static const std::string value
};
struct type_name { };
template <> struct type_string<bool> { static constexpr const char value[] = "bool"; };
template <> struct type_name<bool> { static constexpr const char value[] = "bool"; };
template <> struct type_string<char> { static constexpr const char value[] = "char"; };
template <> struct type_string<void*> { static constexpr const char value[] = "void*"; };
template <> struct type_name<char> { static constexpr const char value[] = "char"; };
template <> struct type_name<void*> { static constexpr const char value[] = "void*"; };
template <> struct type_string< int8_t> { static constexpr const char value[] = "int8"; };
template <> struct type_string< int16_t> { static constexpr const char value[] = "int16"; };
template <> struct type_string< int32_t> { static constexpr const char value[] = "int32"; };
template <> struct type_string< int64_t> { static constexpr const char value[] = "int64"; };
template <> struct type_name< int8_t> { static constexpr const char value[] = "int8"; };
template <> struct type_name< int16_t> { static constexpr const char value[] = "int16"; };
template <> struct type_name< int32_t> { static constexpr const char value[] = "int32"; };
template <> struct type_name< int64_t> { static constexpr const char value[] = "int64"; };
template <> struct type_string< uint8_t> { static constexpr const char value[] = "uint8"; };
template <> struct type_string<uint16_t> { static constexpr const char value[] = "uint16"; };
template <> struct type_string<uint32_t> { static constexpr const char value[] = "uint32"; };
template <> struct type_string<uint64_t> { static constexpr const char value[] = "uint64"; };
template <> struct type_name< uint8_t> { static constexpr const char value[] = "uint8"; };
template <> struct type_name<uint16_t> { static constexpr const char value[] = "uint16"; };
template <> struct type_name<uint32_t> { static constexpr const char value[] = "uint32"; };
template <> struct type_name<uint64_t> { static constexpr const char value[] = "uint64"; };
template <> struct type_string<float > { static constexpr const char value[] = "float32"; };
template <> struct type_string<double > { static constexpr const char value[] = "float64"; };
template <> struct type_name<float > { static constexpr const char value[] = "float32"; };
template <> struct type_name<double > { static constexpr const char value[] = "float64"; };
template <> struct type_string<std::string> { static constexpr const char value[] = "string"; };
template <> struct type_string<char*> { static constexpr const char value[] = "cstring"; };
template <> struct type_string<const char*> { static constexpr const char value[] = "cstring"; };
template <> struct type_name<std::string> { static constexpr const char value[] = "string"; };
template <> struct type_name<char*> { static constexpr const char value[] = "cstring"; };
template <> struct type_name<const char*> { static constexpr const char value[] = "cstring"; };
template <typename T>
constexpr
const char* type_string_v = type_string<T>::value;
const char* type_name_v = type_name<T>::value;
template <typename T>
const char*
to_string (void)
{ return type_string_v<T>; }
{ return type_name_v<T>; }
///////////////////////////////////////////////////////////////////////////
@ -107,7 +105,7 @@ namespace util {
}; \
\
template <> \
struct type_string<::NS::E> { \
struct type_name<::NS::E> { \
static constexpr const char ns[] = #NS; \
static constexpr const char value[] = #E; \
}; \
@ -134,10 +132,10 @@ namespace util {
> util::enum_traits<::NS::E>::names; \
\
constexpr \
const char util::type_string<::NS::E>::ns[]; \
const char util::type_name<::NS::E>::ns[]; \
\
constexpr \
const char util::type_string<::NS::E>::value[]; \
const char util::type_name<::NS::E>::value[]; \
///------------------------------------------------------------------------