#pragma once #include #include #include #include #include "glm/gtc/quaternion.hpp" #include "glm/glm.hpp" #include "CAngle.h" //#include "CWrapableBase.h" #include "U_General.h" #include "CColor.h" #include "CColorInt.h" //#include "CWrapable.h" #include "SDL3/SDL_events.h" #define WRAP_TYPE_STRING_START(type, wrap) if constexpr (std::is_same_v) { return wrap; } #define WRAP_TYPE_STRING_END() else { return typeid(T).name(); } #define WRAP_TYPE_STRING(type, wrap) else if constexpr (std::is_same_v) { return wrap; } #define WRAP_TYPE_STRING_GLM(cond, basename) else if constexpr (cond) { return basename + GetGlmLengthString() + GetTypeNameFirstLetter(); } #define WRAP_TYPE_STRING_GLM_MAT(cond, basename) else if constexpr (cond) { return basename + GetGlmLengthString() + "x" + GetGlmColLengthString() + GetTypeNameFirstLetter(); } #define WRAP_TYPE_STRING_BASE(type, wrap) else if constexpr (are_same_template>::value) { return wrap; } #define WRAP_TYPE_STRING_BASE_WITH_TYPE(type, wrap) else if constexpr (are_same_template>::value) { return wrap + GetTypeName(); } #define WRAP_TYPE_STRING_BASE_WITH_TYPE_FIRST_LETTER(type, wrap) else if constexpr (are_same_template>::value) { return wrap + GetTypeNameFirstLetter(); } #define WRAP_TYPE_STRING_BASE_WITH_TYPE_SPACE(type, wrap) else if constexpr (are_same_template>::value) { return wrap + " " + GetTypeName(); } #define WRAP_TYPE_STRING_BASE_WITH_TYPE_UNDERSCORE(type, wrap) else if constexpr (are_same_template>::value) { return wrap + "_" + GetTypeName(); } template std::string GetTypeName(); template std::string GetTypeNameFirstLetter() { return std::string(1, GetTypeName()[0]); } template std::string GetGlmLengthString() { return std::to_string(T::length()); } template std::string GetGlmColLengthString() { return std::to_string(T::col_type::length()); } template struct is_glm_vec : std::false_type {}; template struct is_glm_vec> : std::true_type {}; template constexpr bool is_glm_vec_v = is_glm_vec::value; template struct is_glm_quat : std::false_type {}; template struct is_glm_quat> : std::true_type {}; template constexpr bool is_glm_quat_v = is_glm_quat::value; template struct is_glm_mat : std::false_type {}; template struct is_glm_mat> : std::true_type {}; template constexpr bool is_glm_mat_v = is_glm_mat::value; template struct is_glm_vec1 : std::false_type {}; template struct is_glm_vec1> : std::true_type {}; template constexpr bool is_glm_vec1_v = is_glm_vec1::value; template struct is_glm_vec2 : std::false_type {}; template struct is_glm_vec2> : std::true_type {}; template constexpr bool is_glm_vec2_v = is_glm_vec2::value; template struct is_glm_vec3 : std::false_type {}; template struct is_glm_vec3> : std::true_type {}; template constexpr bool is_glm_vec3_v = is_glm_vec3::value; template struct is_glm_vec4 : std::false_type {}; template struct is_glm_vec4> : std::true_type {}; template constexpr bool is_glm_vec4_v = is_glm_vec4::value; template struct is_glm_length_type : std::false_type {}; template struct is_glm_length_type> : std::bool_constant {}; template constexpr bool is_glm_length_type_v = is_glm_length_type::value; template constexpr bool IsSequentParseable() { return (is_glm_vec_v || is_glm_quat_v || std::is_same_v || std::is_same_v); } template std::string GetTypeName() { WRAP_TYPE_STRING_START(std::string, "string") WRAP_TYPE_STRING(std::wstring, "wstring") WRAP_TYPE_STRING(CAngle, "angle") WRAP_TYPE_STRING(CAngles, "angles") WRAP_TYPE_STRING(CColor, "color") WRAP_TYPE_STRING(CColorInt, "colorint") WRAP_TYPE_STRING_GLM(is_glm_vec_v, "vec") WRAP_TYPE_STRING_GLM(is_glm_quat_v, "quat") WRAP_TYPE_STRING_GLM_MAT(is_glm_mat_v, "mat") WRAP_TYPE_STRING(std::int8_t, "int8") WRAP_TYPE_STRING(std::uint8_t, "uint8") WRAP_TYPE_STRING(std::int16_t, "int16") WRAP_TYPE_STRING(std::uint16_t, "uint16") WRAP_TYPE_STRING(std::int32_t, "int32") WRAP_TYPE_STRING(std::uint32_t, "uint32") WRAP_TYPE_STRING(std::int64_t, "int64") WRAP_TYPE_STRING(std::uint64_t, "uint64") WRAP_TYPE_STRING(float, "float") WRAP_TYPE_STRING(double, "double") WRAP_TYPE_STRING(bool, "bool") WRAP_TYPE_STRING(SDL_Event, "sdlevent") WRAP_TYPE_STRING_END() return "unknown"; } //TODO wrapables #define TABLE_TYPE_STRING_DECLARE(name) extern std::unordered_map name; #define TABLE_TYPE_STRING_START(name) std::unordered_map name = { #define TABLE_TYPE_STRING_END() }; #define TABLE_TYPE_STRING(type, wrap) { typeid(type).hash_code(), wrap }, #define TABLE_TYPE_STRING_PRE_END(type, wrap) { typeid(type).hash_code(), wrap } #define TABLE_TYPE_STRING_GLM(type, basename) { typeid(type).hash_code(), basename + GetGlmLengthString() + GetTypeNameFirstLetter() }, #define TABLE_TYPE_STRING_GLM_MAT(type, basename) { typeid(type).hash_code(), basename + GetGlmLengthString() + "x" + GetGlmColLengthString() + GetTypeNameFirstLetter() }, TABLE_TYPE_STRING_DECLARE(TableStringTypes);