Refureku v2.2.0
C++17 runtime reflection library.
Type.h
1
8#pragma once
9
10#include <cstddef> //std::size_t
11#include <type_traits> //std::is_const_v, std::is_volatile_v, std::is_array_v, ...
12
13#include "Refureku/Misc/Pimpl.h"
14#include "Refureku/TypeInfo/TypePart.h"
15#include "Refureku/TypeInfo/Archetypes/GetArchetype.h"
16
17namespace rfk
18{
19 class Type
20 {
21 public:
22 REFUREKU_API Type() noexcept;
23 Type(Type const&) noexcept;
24 Type(Type&&) noexcept;
25 REFUREKU_API ~Type() noexcept;
26
35 REFUREKU_API TypePart const& getTypePartAt(std::size_t index) const noexcept;
36
42 REFUREKU_API std::size_t getTypePartsCount() const noexcept;
43
48 REFUREKU_API bool isPointer() const noexcept;
49
54 REFUREKU_API bool isLValueReference() const noexcept;
55
60 REFUREKU_API bool isRValueReference() const noexcept;
61
66 REFUREKU_API bool isCArray() const noexcept;
67
72 REFUREKU_API bool isValue() const noexcept;
73
78 REFUREKU_API bool isConst() const noexcept;
79
84 REFUREKU_API bool isVolatile() const noexcept;
85
90 REFUREKU_API uint32 getCArraySize() const noexcept;
91
98 REFUREKU_API bool match(Type const& other) const noexcept;
99
105 REFUREKU_API Archetype const* getArchetype() const noexcept;
106
112 REFUREKU_API void setArchetype(Archetype const* archetype) noexcept;
113
119 REFUREKU_API TypePart& addTypePart() noexcept;
120
124 REFUREKU_API void optimizeMemory() noexcept;
125
126
127 REFUREKU_API bool operator==(Type const&) const noexcept;
128 REFUREKU_API bool operator!=(Type const&) const noexcept;
129
130 protected:
131 //Forward declaration
132 class TypeImpl;
133
134 private:
136 Pimpl<TypeImpl> _pimpl;
137
138 //The rfk::getType<T> method can access Type internal methods to fill the type
139 template <typename T>
140 friend Type const& getType() noexcept;
141
147 template <typename T>
148 static void fillType(Type& out_type) noexcept;
149 };
150
157 template <typename T>
158 Type const& getType() noexcept;
159
160 #include "Refureku/TypeInfo/Type.inl"
161
162 /*
163 * Export getType<T> instantiations for all fundamental types so that their address is shared among all consumers
164 */
165 template REFUREKU_API Type const& getType<void>() noexcept;
166 template REFUREKU_API Type const& getType<std::nullptr_t>() noexcept;
167 template REFUREKU_API Type const& getType<bool>() noexcept;
168 template REFUREKU_API Type const& getType<char>() noexcept;
169 template REFUREKU_API Type const& getType<signed char>() noexcept;
170 template REFUREKU_API Type const& getType<unsigned char>() noexcept;
171 template REFUREKU_API Type const& getType<wchar_t>() noexcept;
172 template REFUREKU_API Type const& getType<char16_t>() noexcept;
173 template REFUREKU_API Type const& getType<char32_t>() noexcept;
174 template REFUREKU_API Type const& getType<short>() noexcept;
175 template REFUREKU_API Type const& getType<unsigned short>() noexcept;
176 template REFUREKU_API Type const& getType<int>() noexcept;
177 template REFUREKU_API Type const& getType<unsigned int>() noexcept;
178 template REFUREKU_API Type const& getType<long>() noexcept;
179 template REFUREKU_API Type const& getType<unsigned long>() noexcept;
180 template REFUREKU_API Type const& getType<long long>() noexcept;
181 template REFUREKU_API Type const& getType<unsigned long long>() noexcept;
182 template REFUREKU_API Type const& getType<float>() noexcept;
183 template REFUREKU_API Type const& getType<double>() noexcept;
184 template REFUREKU_API Type const& getType<long double>() noexcept;
185}
Definition: Archetype.h:16
Definition: Pimpl.h:20
Definition: Type.h:20
REFUREKU_API Archetype const * getArchetype() const noexcept
Get this type's archetype.
REFUREKU_API TypePart & addTypePart() noexcept
Add a default-constructed type part to this type.
REFUREKU_API bool isConst() const noexcept
REFUREKU_API bool isRValueReference() const noexcept
REFUREKU_API void optimizeMemory() noexcept
Reallocate the underlying dynamic memory to use no more than needed.
REFUREKU_API bool isPointer() const noexcept
REFUREKU_API bool isCArray() const noexcept
REFUREKU_API bool match(Type const &other) const noexcept
REFUREKU_API uint32 getCArraySize() const noexcept
REFUREKU_API bool isValue() const noexcept
REFUREKU_API TypePart const & getTypePartAt(std::size_t index) const noexcept
Get the type part at the specified index. If index is greater or equal to the type parts count,...
friend Type const & getType() noexcept
Retrieve the Type object from a given type. Identical types will return the same Type object (the ret...
REFUREKU_API bool isVolatile() const noexcept
REFUREKU_API void setArchetype(Archetype const *archetype) noexcept
Set this type's archetype.
REFUREKU_API bool isLValueReference() const noexcept
REFUREKU_API std::size_t getTypePartsCount() const noexcept
Get the number of type parts constituting this type.
Definition: TypePart.h:17
Definition: Allocator.h:16