16#ifndef SIMICS_ATTRIBUTE_TYPE_STRING_H
17#define SIMICS_ATTRIBUTE_TYPE_STRING_H
28#include <unordered_map>
29#include <unordered_set>
38const std::unordered_map<std::type_index, const std::string>
type_strs {
39 {std::type_index(
typeid(
bool)),
"b"},
40 {std::type_index(
typeid(
char)),
"i"},
41 {std::type_index(
typeid(
signed char)),
"i"},
42 {std::type_index(
typeid(
unsigned char)),
"i"},
43 {std::type_index(
typeid(
short)),
"i"},
44 {std::type_index(
typeid(
unsigned short)),
"i"},
45 {std::type_index(
typeid(
int)),
"i"},
46 {std::type_index(
typeid(
unsigned int)),
"i"},
47 {std::type_index(
typeid(
long int)),
"i"},
48 {std::type_index(
typeid(
unsigned long int)),
"i"},
49 {std::type_index(
typeid(
long long int)),
"i"},
50 {std::type_index(
typeid(
unsigned long long int)),
52 {std::type_index(
typeid(
float)),
"f"},
53 {std::type_index(
typeid(
double)),
"f"},
55 {std::type_index(
typeid(std::string)),
"s"},
56 {std::type_index(
typeid(
const char *)),
"s|n"},
57 {std::type_index(
typeid(attr_value_t)),
"a"},
62 static std::string
f() {
return type_strs.at(std::type_index(
typeid(T))); }
69 static_assert(!std::is_member_pointer<T>::value,
70 "Use Foo::bar instead of &Foo::bar");
71 static_assert(!std::is_function<T>::value,
72 "Function type is not supported");
78template <
typename X,
typename Y>
80 static std::string
f() {
81 return std::string(
"[") + attr_type_str<X>() + attr_type_str<Y>() +
"]";
85template <
typename X,
typename Y>
87 static std::string
f() {
88 return std::string(
"[") + attr_type_str<std::pair<X, Y>>() +
"*]";
92template <
typename T, std::
size_t N>
94 static std::string
f() {
95 return std::string(
"[") + attr_type_str<T>() +
"{" \
96 + std::to_string(N) +
"}]";
100template <
typename... Args>
102 static std::string
f() {
103 return "[" + type_str() +
"]";
108 static std::string type_str() {
109 return concat_types<Args...>();
113 template <
typename First,
typename Second,
typename ...Rest>
114 static std::string concat_types() {
115 return attr_type_str<First>() + concat_types<Second, Rest...>();
118 template <
typename Last>
119 static std::string concat_types() {
120 return attr_type_str<Last>();
126 static std::string
f() {
127 return std::string(
"[") + attr_type_str<typename T::value_type>() + \
132#define _ATTR_LIST_TYPE_STR_HELPER(type) \
133 template <typename T> \
134 struct attr_type_str_helper<type<T>> : \
135 attr_list_type_str_helper<type<T>> {};
142#undef _ATTR_LIST_TYPE_STR_HELPER
147 static std::string
f() {
#define _ATTR_LIST_TYPE_STR_HELPER(type)
Definition: attribute-type-string.h:132
Represents Simics C type conf_object_t.
Definition: conf-object.h:38
const std::unordered_map< std::type_index, const std::string > type_strs
Definition: attribute-type-string.h:38
Definition: after-bank.h:33
std::string attr_type_str()
Definition: attribute-type-string.h:68
Definition: common-types.h:66
Definition: attribute-type-string.h:125
static std::string f()
Definition: attribute-type-string.h:126
static std::string f()
Definition: attribute-type-string.h:94
static std::string f()
Definition: attribute-type-string.h:87
static std::string f()
Definition: attribute-type-string.h:80
static std::string f()
Definition: attribute-type-string.h:102
static std::string f()
Definition: attribute-type-string.h:147
Definition: attribute-type-string.h:61
static std::string f()
Definition: attribute-type-string.h:62