15 enum class ValueType : uint8_t {
85 _ObjectStart = String,
86 _ObjectEnd = ArrayMatrix4x4,
88 _ArrayStart = ArrayBool,
89 _ArrayEnd = ArrayMatrix4x4,
91 _StructStart = Vector2,
92 _StructEnd = Matrix4x4,
95#if _WIN32 && !_M_ARM64 || INTPTR_MAX == INT32_MAX
96 _HiddenParamStart = Vector3,
98 _HiddenParamStart = Matrix4x4,
100 _LastAssigned = Matrix4x4,
107 static constexpr std::string_view Void =
"void";
108 static constexpr std::string_view Bool =
"bool";
109 static constexpr std::string_view Char8 =
"char8";
110 static constexpr std::string_view Char16 =
"char16";
111 static constexpr std::string_view Int8 =
"int8";
112 static constexpr std::string_view Int16 =
"int16";
113 static constexpr std::string_view Int32 =
"int32";
114 static constexpr std::string_view Int64 =
"int64";
115 static constexpr std::string_view UInt8 =
"uint8";
116 static constexpr std::string_view UInt16 =
"uint16";
117 static constexpr std::string_view UInt32 =
"uint32";
118 static constexpr std::string_view UInt64 =
"uint64";
119 static constexpr std::string_view Float =
"float";
120 static constexpr std::string_view Double =
"double";
121 static constexpr std::string_view Function =
"function";
122 static constexpr std::string_view String =
"string";
123 static constexpr std::string_view Any =
"any";
124 static constexpr std::string_view ArrayBool =
"bool[]";
125 static constexpr std::string_view ArrayChar8 =
"char8[]";
126 static constexpr std::string_view ArrayChar16 =
"char16[]";
127 static constexpr std::string_view ArrayInt8 =
"int8[]";
128 static constexpr std::string_view ArrayInt16 =
"int16[]";
129 static constexpr std::string_view ArrayInt32 =
"int32[]";
130 static constexpr std::string_view ArrayInt64 =
"int64[]";
131 static constexpr std::string_view ArrayUInt8 =
"uint8[]";
132 static constexpr std::string_view ArrayUInt16 =
"uint16[]";
133 static constexpr std::string_view ArrayUInt32 =
"uint32[]";
134 static constexpr std::string_view ArrayUInt64 =
"uint64[]";
135 static constexpr std::string_view ArrayFloat =
"float[]";
136 static constexpr std::string_view ArrayDouble =
"double[]";
137 static constexpr std::string_view ArrayString =
"string[]";
138 static constexpr std::string_view ArrayAny =
"any[]";
139 static constexpr std::string_view ArrayVector2 =
"vec2[]";
140 static constexpr std::string_view ArrayVector3 =
"vec3[]";
141 static constexpr std::string_view ArrayVector4 =
"vec4[]";
142 static constexpr std::string_view ArrayMatrix4x4 =
"mat4x4[]";
143 static constexpr std::string_view Vector2 =
"vec2";
144 static constexpr std::string_view Vector3 =
"vec3";
145 static constexpr std::string_view Vector4 =
"vec4";
146 static constexpr std::string_view Matrix4x4 =
"mat4x4";
147 static constexpr std::string_view Invalid =
"invalid";
148#if INTPTR_MAX == INT32_MAX
149 static constexpr std::string_view Pointer =
"ptr32";
150 static constexpr std::string_view ArrayPointer =
"ptr32[]";
151#elif INTPTR_MAX == INT64_MAX
152 static constexpr std::string_view Pointer =
"ptr64";
153 static constexpr std::string_view ArrayPointer =
"ptr64[]";
155#error "Environment not 32 or 64-bit."
173 template <
typename T>
174 static constexpr bool IsBetween(T x, T a, T b)
noexcept {
175 return x >= a && x <= b;
184 static constexpr bool IsVoid(ValueType type)
noexcept {
185 return type == ValueType::Void;
194 static constexpr bool IsValid(ValueType type)
noexcept {
195 return IsBetween(type, ValueType::Void, ValueType::_LastAssigned);
204 static constexpr bool IsScalar(ValueType type)
noexcept {
205 return IsBetween(type, ValueType::_BaseStart, ValueType::_BaseEnd);
215 return IsBetween(type, ValueType::_FloatStart, ValueType::_FloatEnd);
224 static constexpr bool IsBool(ValueType type)
noexcept {
225 return type == ValueType::Bool;
234 static constexpr bool IsChar8(ValueType type)
noexcept {
235 return type == ValueType::Char8;
244 static constexpr bool IsChar16(ValueType type)
noexcept {
245 return type == ValueType::Char16;
254 static constexpr bool IsInt8(ValueType type)
noexcept {
255 return type == ValueType::Int8;
264 static constexpr bool IsUInt8(ValueType type)
noexcept {
265 return type == ValueType::UInt8;
274 static constexpr bool IsInt16(ValueType type)
noexcept {
275 return type == ValueType::Int16;
284 static constexpr bool IsUInt16(ValueType type)
noexcept {
285 return type == ValueType::UInt16;
294 static constexpr bool IsInt32(ValueType type)
noexcept {
295 return type == ValueType::Int32;
304 static constexpr bool IsUInt32(ValueType type)
noexcept {
305 return type == ValueType::UInt32;
314 static constexpr bool IsInt64(ValueType type)
noexcept {
315 return type == ValueType::Int64;
324 static constexpr bool IsUInt64(ValueType type)
noexcept {
325 return type == ValueType::UInt64;
334 static constexpr bool IsPointer(ValueType type)
noexcept {
335 return type == ValueType::Pointer;
344 static constexpr bool IsFloat(ValueType type)
noexcept {
345 return type == ValueType::Float;
354 static constexpr bool IsDouble(ValueType type)
noexcept {
355 return type == ValueType::Double;
365 return type == ValueType::Function;
374 static constexpr bool IsString(ValueType type)
noexcept {
375 return type == ValueType::String;
384 static constexpr bool IsAny(ValueType type)
noexcept {
385 return type == ValueType::Any;
394 static constexpr bool IsObject(ValueType type)
noexcept {
395 return IsBetween(type, ValueType::_ObjectStart, ValueType::_ObjectEnd);
404 static constexpr bool IsArray(ValueType type)
noexcept {
405 return IsBetween(type, ValueType::_ArrayStart, ValueType::_ArrayEnd);
414 static constexpr bool IsStruct(ValueType type)
noexcept {
415 return IsBetween(type, ValueType::_StructStart, ValueType::_StructEnd);
430 return IsObject(type) ||
IsBetween(type, ValueType::_HiddenParamStart, ValueType::_StructEnd);
442 static constexpr size_t SizeOf(ValueType type)
noexcept {
444 case ValueType::Bool:
446 case ValueType::Char8:
448 case ValueType::Char16:
449 return sizeof(char16_t);
450 case ValueType::Int8:
451 return sizeof(int8_t);
452 case ValueType::Int16:
453 return sizeof(int16_t);
454 case ValueType::Int32:
455 return sizeof(int32_t);
456 case ValueType::Int64:
457 return sizeof(int64_t);
458 case ValueType::UInt8:
459 return sizeof(uint8_t);
460 case ValueType::UInt16:
461 return sizeof(uint16_t);
462 case ValueType::UInt32:
463 return sizeof(uint32_t);
464 case ValueType::UInt64:
465 return sizeof(uint64_t);
466 case ValueType::Pointer:
467 return sizeof(
void*);
468 case ValueType::Float:
469 return sizeof(float);
470 case ValueType::Double:
471 return sizeof(double);
473 case ValueType::String:
479 case ValueType::ArrayBool:
481 case ValueType::ArrayChar8:
483 case ValueType::ArrayChar16:
485 case ValueType::ArrayInt8:
487 case ValueType::ArrayInt16:
489 case ValueType::ArrayInt32:
491 case ValueType::ArrayInt64:
493 case ValueType::ArrayUInt8:
495 case ValueType::ArrayUInt16:
497 case ValueType::ArrayUInt32:
499 case ValueType::ArrayUInt64:
501 case ValueType::ArrayPointer:
503 case ValueType::ArrayFloat:
505 case ValueType::ArrayDouble:
507 case ValueType::ArrayString:
509 case ValueType::ArrayAny:
511 case ValueType::ArrayVector2:
513 case ValueType::ArrayVector3:
515 case ValueType::ArrayVector4:
517 case ValueType::ArrayMatrix4x4:
521 case ValueType::Vector2:
523 case ValueType::Vector3:
525 case ValueType::Vector4:
527 case ValueType::Matrix4x4:
531 case ValueType::Function:
533 case ValueType::Void:
543 static_assert(ValueType::Void ==
static_cast<ValueType
>(plg::any::index_of<plg::none>));
544 static_assert(ValueType::Bool ==
static_cast<ValueType
>(plg::any::index_of<bool>));
545 static_assert(ValueType::Char8 ==
static_cast<ValueType
>(plg::any::index_of<char>));
546 static_assert(ValueType::Char16 ==
static_cast<ValueType
>(plg::any::index_of<char16_t>));
547 static_assert(ValueType::Int8 ==
static_cast<ValueType
>(plg::any::index_of<int8_t>));
548 static_assert(ValueType::Int16 ==
static_cast<ValueType
>(plg::any::index_of<int16_t>));
549 static_assert(ValueType::Int32 ==
static_cast<ValueType
>(plg::any::index_of<int32_t>));
550 static_assert(ValueType::Int64 ==
static_cast<ValueType
>(plg::any::index_of<int64_t>));
551 static_assert(ValueType::UInt8 ==
static_cast<ValueType
>(plg::any::index_of<uint8_t>));
552 static_assert(ValueType::UInt16 ==
static_cast<ValueType
>(plg::any::index_of<uint16_t>));
553 static_assert(ValueType::UInt32 ==
static_cast<ValueType
>(plg::any::index_of<uint32_t>));
554 static_assert(ValueType::UInt64 ==
static_cast<ValueType
>(plg::any::index_of<uint64_t>));
555 static_assert(ValueType::Pointer ==
static_cast<ValueType
>(plg::any::index_of<void*>));
556 static_assert(ValueType::Float ==
static_cast<ValueType
>(plg::any::index_of<float>));
557 static_assert(ValueType::Double ==
static_cast<ValueType
>(plg::any::index_of<double>));
558 static_assert(ValueType::Function ==
static_cast<ValueType
>(plg::any::index_of<plg::function>));
559 static_assert(ValueType::String ==
static_cast<ValueType
>(plg::any::index_of<plg::string>));
560 static_assert(ValueType::Any ==
static_cast<ValueType
>(plg::any::index_of<plg::variant<plg::none>>));
561 static_assert(ValueType::ArrayBool ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<bool>>));
562 static_assert( ValueType::ArrayChar8 ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<char>>));
563 static_assert( ValueType::ArrayChar16 ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<char16_t>>));
564 static_assert( ValueType::ArrayInt8 ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<int8_t>>));
565 static_assert( ValueType::ArrayInt16 ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<int16_t>>));
566 static_assert( ValueType::ArrayInt32 ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<int32_t>>));
567 static_assert( ValueType::ArrayInt64 ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<int64_t>>));
568 static_assert( ValueType::ArrayUInt8 ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<uint8_t>>));
569 static_assert( ValueType::ArrayUInt16 ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<uint16_t>>));
570 static_assert( ValueType::ArrayUInt32 ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<uint32_t>>));
571 static_assert( ValueType::ArrayUInt64 ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<uint64_t>>));
572 static_assert( ValueType::ArrayPointer ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<void*>>));
573 static_assert( ValueType::ArrayFloat ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<float>>));
574 static_assert( ValueType::ArrayDouble ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<double>>));
575 static_assert( ValueType::ArrayString ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<plg::string>>));
576 static_assert( ValueType::ArrayAny ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<plg::variant<plg::none>>>));
577 static_assert( ValueType::ArrayVector2 ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<plg::vec2>>));
578 static_assert( ValueType::ArrayVector3 ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<plg::vec3>>));
579 static_assert( ValueType::ArrayVector4 ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<plg::vec4>>));
580 static_assert( ValueType::ArrayMatrix4x4 ==
static_cast<ValueType
>(plg::any::index_of<plg::vector<plg::mat4x4>>));
581 static_assert(ValueType::Vector2 ==
static_cast<ValueType
>(plg::any::index_of<plg::vec2>));
582 static_assert(ValueType::Vector3 ==
static_cast<ValueType
>(plg::any::index_of<plg::vec3>));
583 static_assert(ValueType::Vector4 ==
static_cast<ValueType
>(plg::any::index_of<plg::vec4>));
Namespace containing string representations of ValueType enum values.
Namespace containing utility functions of ValueType enum.
static constexpr bool IsFloating(ValueType type) noexcept
Tests whether a given type is a scalar floating point of any size.
static constexpr bool IsValid(ValueType type) noexcept
Tests whether a given type is a valid non-void type.
static constexpr bool IsHiddenParam(ValueType type) noexcept
Checks if a given ValueType is considered a hidden object parameter.
static constexpr size_t SizeOf(ValueType type) noexcept
Returns the size in bytes of the given ValueType.
static constexpr bool IsObject(ValueType type) noexcept
Tests whether a given type is an object of any size.
static constexpr bool IsAny(ValueType type) noexcept
Tests whether a given type is an any.
static constexpr bool IsString(ValueType type) noexcept
Tests whether a given type is a string.
static constexpr bool IsFunction(ValueType type) noexcept
Tests whether a given type is a C-function pointer.
static constexpr bool IsBool(ValueType type) noexcept
Tests whether a given type is a 1-bit boolean.
static constexpr bool IsUInt32(ValueType type) noexcept
Tests whether a given type is a 32-bit unsigned integer.
static constexpr bool IsScalar(ValueType type) noexcept
Tests whether a given type is scalar (has no vector part).
static constexpr bool IsUInt8(ValueType type) noexcept
Tests whether a given type is an 8-bit unsigned integer.
static constexpr bool IsInt8(ValueType type) noexcept
Tests whether a given type is an 8-bit integer.
static constexpr bool IsArray(ValueType type) noexcept
Tests whether a given type is an array of any size.
static constexpr bool IsInt32(ValueType type) noexcept
Tests whether a given type is a 32-bit integer.
static constexpr bool IsPointer(ValueType type) noexcept
Tests whether a given type is a pointer.
static constexpr bool IsVoid(ValueType type) noexcept
Tests whether a given type is ValueType::Void.
static constexpr bool IsUInt64(ValueType type) noexcept
Tests whether a given type is a 64-bit unsigned integer.
static constexpr bool IsInt64(ValueType type) noexcept
Tests whether a given type is a 64-bit integer.
static constexpr bool IsChar16(ValueType type) noexcept
Tests whether a given type is a 16-bit character.
static constexpr bool IsDouble(ValueType type) noexcept
Tests whether a given type is a double.
static constexpr bool IsFloat(ValueType type) noexcept
Tests whether a given type is a float.
static constexpr bool IsStruct(ValueType type) noexcept
Tests whether a given type is a POD (plain old data) structure of any size.
static constexpr bool IsInt16(ValueType type) noexcept
Tests whether a given type is a 16-bit integer.
static constexpr bool IsChar8(ValueType type) noexcept
Tests whether a given type is an 8-bit character.
static constexpr bool IsBetween(T x, T a, T b) noexcept
Checks if a value is between two other values.
static constexpr bool IsUInt16(ValueType type) noexcept
Tests whether a given type is a 16-bit unsigned integer.
Represents a function pointer as a union for flexibility.