BitShares-Core  5.0.0
BitShares blockchain implementation and command-line interface software
typename.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <array>
4 #include <deque>
5 #include <map>
6 #include <set>
7 #include <string>
8 #include <vector>
9 
10 #include <fc/optional.hpp>
11 #include <fc/string.hpp>
13 
14 namespace fc {
15  template<typename...> class static_variant;
16  class value;
17  class exception;
18  namespace ip { class address; }
19 
20  template<typename... T> struct get_typename;
21 #if defined(__APPLE__) or defined(__OpenBSD__)
22  template<> struct get_typename<size_t> { static const char* name() { return "size_t"; } };
23 #endif
24  template<> struct get_typename<int32_t> { static const char* name() { return "int32_t"; } };
25  template<> struct get_typename<int64_t> { static const char* name() { return "int64_t"; } };
26  template<> struct get_typename<int16_t> { static const char* name() { return "int16_t"; } };
27  template<> struct get_typename<int8_t> { static const char* name() { return "int8_t"; } };
28  template<> struct get_typename<uint32_t> { static const char* name() { return "uint32_t"; } };
29  template<> struct get_typename<uint64_t> { static const char* name() { return "uint64_t"; } };
30  template<> struct get_typename<uint16_t> { static const char* name() { return "uint16_t"; } };
31  template<> struct get_typename<uint8_t> { static const char* name() { return "uint8_t"; } };
32  template<> struct get_typename<double> { static const char* name() { return "double"; } };
33  template<> struct get_typename<float> { static const char* name() { return "float"; } };
34  template<> struct get_typename<bool> { static const char* name() { return "bool"; } };
35  template<> struct get_typename<char> { static const char* name() { return "char"; } };
36  template<> struct get_typename<void> { static const char* name() { return "char"; } };
37  template<> struct get_typename<value> { static const char* name() { return "value"; } };
38  template<> struct get_typename<std::string> { static const char* name() { return "string"; } };
39  template<> struct get_typename<fc::exception> { static const char* name() { return "fc::exception"; } };
40  template<> struct get_typename<std::vector<char>> { static const char* name() { return "std::vector<char>"; } };
41  template<typename T> struct get_typename<std::vector<T>>
42  {
43  static const char* name() {
44  static std::string n = std::string("std::vector<") + get_typename<T>::name() + ">";
45  return n.c_str();
46  }
47  };
48  template<typename T> struct get_typename<flat_set<T>>
49  {
50  static const char* name() {
51  static std::string n = std::string("flat_set<") + get_typename<T>::name() + ">";
52  return n.c_str();
53  }
54  };
55  template<typename... Ts>
56  struct get_typename<flat_set<static_variant<Ts...>, typename static_variant<Ts...>::type_lt>>
57  {
58  static const char* name() {
59  using TN = get_typename<static_variant<Ts...>>;
60  static std::string n = std::string("flat_set<") + TN::name() + ", " + TN::name() + "::type_lt>";
61  return n.c_str();
62  }
63  };
64  template<typename T, typename U> struct get_typename<flat_map<T, U>>
65  {
66  static const char* name() {
67  static std::string n = std::string("flat_map<") + get_typename<T>::name() + ", " + get_typename<U>::name() + ">";
68  return n.c_str();
69  }
70  };
71  template<typename T> struct get_typename< std::deque<T> >
72  {
73  static const char* name()
74  {
75  static std::string n = std::string("std::deque<") + get_typename<T>::name() + ">";
76  return n.c_str();
77  }
78  };
79  template<typename T> struct get_typename<optional<T>>
80  {
81  static const char* name() {
82  static std::string n = std::string("optional<") + get_typename<T>::name() + ">";
83  return n.c_str();
84  }
85  };
86  template<typename K,typename V> struct get_typename<std::map<K,V>>
87  {
88  static const char* name() {
89  static std::string n = std::string("std::map<") + get_typename<K>::name() + ","+get_typename<V>::name()+">";
90  return n.c_str();
91  }
92  };
93  template<typename E> struct get_typename< std::set<E> >
94  {
95  static const char* name()
96  {
97  static std::string n = std::string("std::set<") + std::string(get_typename<E>::name()) + std::string(">");
98  return n.c_str();
99  }
100  };
101  template<typename A, typename B> struct get_typename< std::pair<A,B> >
102  {
103  static const char* name()
104  {
105  static std::string n = std::string("std::pair<") + get_typename<A>::name() + "," + get_typename<B>::name() + ">";
106  return n.c_str();
107  }
108  };
109  template<typename T,size_t N> struct get_typename< std::array<T,N> >
110  {
111  static const char* name()
112  {
113  static std::string _name = std::string("std::array<") + std::string(fc::get_typename<T>::name())
114  + "," + fc::to_string(N) + ">";
115  return _name.c_str();
116  }
117  };
118  template<typename T> struct get_typename< const T* >
119  {
120  static const char* name()
121  {
122  static std::string n = std::string("const ") + get_typename<T>::name() + "*";
123  return n.c_str();
124  }
125  };
126  template<typename T> struct get_typename< T* >
127  {
128  static const char* name()
129  {
130  static std::string n = std::string(get_typename<T>::name()) + "*";
131  return n.c_str();
132  }
133  };
134 
135  struct unsigned_int;
136  class variant_object;
137  template<> struct get_typename<unsigned_int> { static const char* name() { return "unsigned_int"; } };
138  template<> struct get_typename<variant_object> { static const char* name() { return "fc::variant_object"; } };
139 
140 }
static const char * name()
Definition: typename.hpp:88
static const char * name()
Definition: typename.hpp:36
static const char * name()
Definition: typename.hpp:35
An order-perserving dictionary of variant&#39;s.
static const char * name()
Definition: typename.hpp:120
static const char * name()
Definition: typename.hpp:66
static const char * name()
Definition: typename.hpp:24
Used to generate a useful error report when an exception is thrown.At each level in the stack where t...
Definition: exception.hpp:56
static const char * name()
Definition: typename.hpp:27
static const char * name()
Definition: typename.hpp:73
static const char * name()
Definition: typename.hpp:128
static const char * name()
Definition: typename.hpp:32
static const char * name()
Definition: typename.hpp:30
static const char * name()
Definition: typename.hpp:29
provides stack-based nullable value similar to boost::optional
Definition: optional.hpp:20
static const char * name()
Definition: typename.hpp:43
static const char * name()
Definition: typename.hpp:25
static const char * name()
Definition: typename.hpp:31
static const char * name()
Definition: typename.hpp:38
static const char * name()
Definition: typename.hpp:34
static const char * name()
Definition: typename.hpp:137
static const char * name()
Definition: typename.hpp:138
static const char * name()
Definition: typename.hpp:37
static const char * name()
Definition: typename.hpp:95
std::string to_string(double)
Definition: string.cpp:73
static const char * name()
Definition: typename.hpp:26
Definition: api.hpp:15
static const char * name()
Definition: typename.hpp:39
static const char * name()
Definition: typename.hpp:28
static const char * name()
Definition: typename.hpp:50
static const char * name()
Definition: typename.hpp:33
static const char * name()
Definition: typename.hpp:81