forked from Abc-Arbitrage/Disruptor-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTypeInfo.h
More file actions
62 lines (44 loc) · 1.29 KB
/
TypeInfo.h
File metadata and controls
62 lines (44 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include <string>
#include <typeinfo>
namespace Disruptor
{
struct TypeInfo
{
explicit TypeInfo(const std::type_info& typeInfo);
const std::type_info& intrinsicTypeInfo() const;
const std::string& fullyQualifiedName() const;
const std::string& name() const;
bool operator==(const TypeInfo& rhs) const;
static std::string dotNetify(const std::string& typeName);
static std::string unqualifyName(const std::string& fullyQualifiedName);
static std::string demangleTypeName(const std::string& typeName);
private:
const std::type_info* m_typeInfo;
std::string m_fullyQualifiedName;
std::string m_name;
};
namespace Utils
{
template <class T>
const TypeInfo& getMetaTypeInfo()
{
static TypeInfo result(typeid(T));
return result;
}
} // namespace Utils
} // namespace Disruptor
#include <functional>
#include <typeindex>
namespace std
{
template <>
struct hash< Disruptor::TypeInfo > : public unary_function< Disruptor::TypeInfo, size_t >
{
public:
size_t operator()(const Disruptor::TypeInfo& value) const
{
return hash< type_index >()(type_index(value.intrinsicTypeInfo()));
}
};
} // namespace std