16#ifndef SIMICS_ATTRIBUTE_TYPE_STRING_H
17#define SIMICS_ATTRIBUTE_TYPE_STRING_H
21#include <unordered_map>
22#include <unordered_set>
37const std::unordered_map<std::type_index, const std::string>
type_strs {
38 {std::type_index(
typeid(
bool)),
"b"},
39 {std::type_index(
typeid(
char)),
"i"},
40 {std::type_index(
typeid(
signed char)),
"i"},
41 {std::type_index(
typeid(
unsigned char)),
"i"},
42 {std::type_index(
typeid(
short)),
"i"},
43 {std::type_index(
typeid(
unsigned short)),
"i"},
44 {std::type_index(
typeid(
int)),
"i"},
45 {std::type_index(
typeid(
unsigned int)),
"i"},
46 {std::type_index(
typeid(
long int)),
"i"},
47 {std::type_index(
typeid(
unsigned long int)),
"i"},
48 {std::type_index(
typeid(
long long int)),
"i"},
49 {std::type_index(
typeid(
unsigned long long int)),
51 {std::type_index(
typeid(
float)),
"f"},
52 {std::type_index(
typeid(
double)),
"f"},
54 {std::type_index(
typeid(std::string)),
"s"},
55 {std::type_index(
typeid(
const char *)),
"s|n"},
56 {std::type_index(
typeid(attr_value_t)),
"a"},
61 static std::string
f() {
return type_strs.at(std::type_index(
typeid(T))); }
68 static_assert(!std::is_member_pointer<T>::value,
69 "Use Foo::bar instead of &Foo::bar");
70 static_assert(!std::is_function<T>::value,
71 "Function type is not supported");
77template <
typename X,
typename Y>
79 static std::string
f() {
80 return std::string(
"[") + attr_type_str<X>() + attr_type_str<Y>() +
"]";
84template <
typename X,
typename Y>
86 static std::string
f() {
87 return std::string(
"[") + attr_type_str<std::pair<X, Y>>() +
"*]";
91template <
typename T, std::
size_t N>
93 static std::string
f() {
94 return std::string(
"[") + attr_type_str<T>() +
"{" \
95 + std::to_string(N) +
"}]";
101 static std::string
f() {
102 return std::string(
"[") + attr_type_str<typename T::value_type>() + \
107#define _ATTR_LIST_TYPE_STR_HELPER(type) \
108 template <typename T> \
109 struct attr_type_str_helper<type<T>> : \
110 attr_list_type_str_helper<type<T>> {};
117#undef _ATTR_LIST_TYPE_STR_HELPER
122 static std::string
f() {
#define _ATTR_LIST_TYPE_STR_HELPER(type)
Definition: attribute-type-string.h:107
Represents Simics C type conf_object_t.
Definition: conf-object.h:37
const std::unordered_map< std::type_index, const std::string > type_strs
Definition: attribute-type-string.h:37
Definition: attr-value.h:23
std::string attr_type_str()
Definition: attribute-type-string.h:67
Definition: common-types.h:63
Definition: attribute-type-string.h:100
static std::string f()
Definition: attribute-type-string.h:101
static std::string f()
Definition: attribute-type-string.h:93
static std::string f()
Definition: attribute-type-string.h:86
static std::string f()
Definition: attribute-type-string.h:79
static std::string f()
Definition: attribute-type-string.h:122
Definition: attribute-type-string.h:60
static std::string f()
Definition: attribute-type-string.h:61