Skip to content

Commit

Permalink
Merge pull request #247 from bitshares/fix-typename
Browse files Browse the repository at this point in the history
Add typename reflection for map<K,V,std::less<>>
  • Loading branch information
abitmore authored Oct 27, 2022
2 parents 41f31f8 + fd8afa3 commit 4d024a8
Showing 1 changed file with 45 additions and 35 deletions.
80 changes: 45 additions & 35 deletions include/fc/reflect/typename.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ namespace fc {
template<> struct get_typename<value> { static const char* name() { return "value"; } };
template<> struct get_typename<std::string> { static const char* name() { return "string"; } };
template<> struct get_typename<fc::exception> { static const char* name() { return "fc::exception"; } };
template<> struct get_typename<std::vector<char>> { static const char* name() { return "std::vector<char>"; } };
template<typename T> struct get_typename<std::vector<T>>
{
static const char* name() {
static std::string n = std::string("std::vector<") + get_typename<T>::name() + ">";
return n.c_str();
}
template<> struct get_typename<std::vector<char>> { static const char* name() { return "std::vector<char>"; } };
template<typename T> struct get_typename<std::vector<T>>
{
static const char* name() {
static std::string n = std::string("std::vector<") + get_typename<T>::name() + ">";
return n.c_str();
}
};
template<typename T> struct get_typename<flat_set<T>>
{
Expand All @@ -54,41 +54,50 @@ namespace fc {
};
template<typename... Ts>
struct get_typename<flat_set<static_variant<Ts...>, typename static_variant<Ts...>::type_lt>>
{
static const char* name() {
{
static const char* name() {
using TN = get_typename<static_variant<Ts...>>;
static std::string n = std::string("flat_set<") + TN::name() + ", " + TN::name() + "::type_lt>";
return n.c_str();
}
static std::string n = std::string("flat_set<") + TN::name() + "," + TN::name() + "::type_lt>";
return n.c_str();
}
};
template<typename T, typename U> struct get_typename<flat_map<T, U>>
{
static const char* name() {
static std::string n = std::string("flat_map<") + get_typename<T>::name() + ", " + get_typename<U>::name() + ">";
static std::string n = std::string("flat_map<") + get_typename<T>::name() + "," + get_typename<U>::name()
+ ">";
return n.c_str();
}
};
template<typename T> struct get_typename< std::deque<T> >
{
static const char* name()
{
static std::string n = std::string("std::deque<") + get_typename<T>::name() + ">";
return n.c_str();
static std::string n = std::string("std::deque<") + get_typename<T>::name() + ">";
return n.c_str();
}
};
template<typename T> struct get_typename<optional<T>>
{
static const char* name() {
static std::string n = std::string("optional<") + get_typename<T>::name() + ">";
return n.c_str();
}
};
template<typename T> struct get_typename<optional<T>>
{
static const char* name() {
static std::string n = std::string("optional<") + get_typename<T>::name() + ">";
return n.c_str();
}
template<typename K,typename V> struct get_typename<std::map<K,V>>
{
static const char* name() {
static std::string n = std::string("std::map<") + get_typename<K>::name() + ","+get_typename<V>::name()+">";
return n.c_str();
}
};
template<typename K,typename V> struct get_typename<std::map<K,V>>
{
static const char* name() {
static std::string n = std::string("std::map<") + get_typename<K>::name() + ","+get_typename<V>::name()+">";
return n.c_str();
}
template<typename K,typename V> struct get_typename<std::map<K,V,std::less<>>>
{
static const char* name() {
static std::string n = std::string("std::map<") + get_typename<K>::name() + ","+get_typename<V>::name()
+ ",std::less<>>";
return n.c_str();
}
};
template<typename E> struct get_typename< std::set<E> >
{
Expand All @@ -102,19 +111,20 @@ namespace fc {
{
static const char* name()
{
static std::string n = std::string("std::pair<") + get_typename<A>::name() + "," + get_typename<B>::name() + ">";
static std::string n = std::string("std::pair<") + get_typename<A>::name() + "," + get_typename<B>::name()
+ ">";
return n.c_str();
}
};
template<typename T,size_t N> struct get_typename< std::array<T,N> >
{
static const char* name()
{
};
template<typename T,size_t N> struct get_typename< std::array<T,N> >
{
static const char* name()
{
static std::string _name = std::string("std::array<") + std::string(fc::get_typename<T>::name())
+ "," + fc::to_string(N) + ">";
return _name.c_str();
}
};
}
};
template<typename T> struct get_typename< const T* >
{
static const char* name()
Expand Down

0 comments on commit 4d024a8

Please sign in to comment.