summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-11-18 11:18:14 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-11-18 11:18:14 +0100
commit7bd1ca56bd9bc561d987fce90e0ba52eeb6636d9 (patch)
tree7101b93da1cf5ce7bfac2bbdce38ac613ce78ef2
parentb65b34a976b586f4e407f7a89567163c85b94aa6 (diff)
entity: split enum specialization into own header
-rw-r--r--entity/entity.hpp26
-rw-r--r--entity/types.hpp38
-rw-r--r--test/entity.cpp1
3 files changed, 39 insertions, 26 deletions
diff --git a/entity/entity.hpp b/entity/entity.hpp
index 8f0980ae..4754204c 100644
--- a/entity/entity.hpp
+++ b/entity/entity.hpp
@@ -231,32 +231,6 @@ constexpr bool find_in_tuple(F&& fun, Tuple&& tuple)
return false;
}
-enum class erased_field_type : std::uint32_t {
- none,
- string,
- u8, u16, u32, u64, s8, s16, s32, s64,
- user_type_start,
- MAX = (1u << 31) - 1u,
- DYNAMIC = (std::uint32_t)-1,
-};
-
-template<erased_field_type> struct type_of_erased_field;
-template<typename T> struct erased_field_type_v_ : std::integral_constant<erased_field_type, erased_field_type::DYNAMIC> {};
-
-#define FM_ERASED_FIELD_TYPE(TYPE, ENUM) \
- template<> struct erased_field_type_v_<TYPE> : std::integral_constant<erased_field_type, erased_field_type::ENUM> {}; \
- template<> struct type_of_erased_field<erased_field_type::ENUM> { using type = TYPE; }
-FM_ERASED_FIELD_TYPE(std::uint8_t, u8);
-FM_ERASED_FIELD_TYPE(std::uint16_t, u16);
-FM_ERASED_FIELD_TYPE(std::uint32_t, u32);
-FM_ERASED_FIELD_TYPE(std::uint64_t, u64);
-FM_ERASED_FIELD_TYPE(std::int8_t, s8);
-FM_ERASED_FIELD_TYPE(std::int16_t, s16);
-FM_ERASED_FIELD_TYPE(std::int32_t, s32);
-FM_ERASED_FIELD_TYPE(std::int64_t, s64);
-FM_ERASED_FIELD_TYPE(StringView, string);
-#undef FM_ERASED_FIELD_TYPE
-
} // namespace floormat::entities
namespace floormat {
diff --git a/entity/types.hpp b/entity/types.hpp
new file mode 100644
index 00000000..88391725
--- /dev/null
+++ b/entity/types.hpp
@@ -0,0 +1,38 @@
+#pragma once
+#include <cstdint>
+#include <type_traits>
+
+namespace Corrade::Containers {
+template<typename T> class BasicStringView;
+using StringView = BasicStringView<const char>;
+} // namespace Corrade::Containers
+
+namespace floormat::entities {
+
+enum class erased_field_type : std::uint32_t {
+ none,
+ string,
+ u8, u16, u32, u64, s8, s16, s32, s64,
+ user_type_start,
+ MAX = (1u << 31) - 1u,
+ DYNAMIC = (std::uint32_t)-1,
+};
+
+template<erased_field_type> struct type_of_erased_field;
+template<typename T> struct erased_field_type_v_ : std::integral_constant<erased_field_type, erased_field_type::DYNAMIC> {};
+
+#define FM_ERASED_FIELD_TYPE(TYPE, ENUM) \
+ template<> struct erased_field_type_v_<TYPE> : std::integral_constant<erased_field_type, erased_field_type::ENUM> {}; \
+ template<> struct type_of_erased_field<erased_field_type::ENUM> { using type = TYPE; }
+FM_ERASED_FIELD_TYPE(std::uint8_t, u8);
+FM_ERASED_FIELD_TYPE(std::uint16_t, u16);
+FM_ERASED_FIELD_TYPE(std::uint32_t, u32);
+FM_ERASED_FIELD_TYPE(std::uint64_t, u64);
+FM_ERASED_FIELD_TYPE(std::int8_t, s8);
+FM_ERASED_FIELD_TYPE(std::int16_t, s16);
+FM_ERASED_FIELD_TYPE(std::int32_t, s32);
+FM_ERASED_FIELD_TYPE(std::int64_t, s64);
+FM_ERASED_FIELD_TYPE(StringView, string);
+#undef FM_ERASED_FIELD_TYPE
+
+} // namespace floormat::entities
diff --git a/test/entity.cpp b/test/entity.cpp
index afec3f7c..2b46cbeb 100644
--- a/test/entity.cpp
+++ b/test/entity.cpp
@@ -1,6 +1,7 @@
#include "app.hpp"
#include "compat/assert.hpp"
#include "entity/entity.hpp"
+#include "entity/types.hpp"
#include <tuple>
using namespace floormat;