4#include "../Containers/Array.h"
5#include "../Containers/Vector.h"
6#include "../Containers/VectorMap.h"
7#include "../Strings/String.h"
18template <
typename MemberVisitor,
typename Container,
typename ItemType,
int N>
21 [[nodiscard]]
static constexpr bool build(MemberVisitor&) {
return true; }
24template <
typename T,
int N>
27 static constexpr bool IsPacked =
false;
30 [[nodiscard]]
static auto data(
SC::Array<T, N>&
object) {
return object.data(); }
31 [[nodiscard]]
static bool resizeWithoutInitializing(
SC::Array<T, N>&
object,
size_t newSize)
33 return object.resizeWithoutInitializing(
min(newSize,
static_cast<size_t>(N)));
35 [[nodiscard]]
static bool resize(
SC::Array<T, N>&
object,
size_t newSize)
37 return object.resize(
min(newSize,
static_cast<size_t>(N)));
41template <
typename T,
int N>
42struct Reflect<SC::Array<T, N>>
46 template <
typename MemberVisitor>
47 [[nodiscard]]
static constexpr bool build(MemberVisitor& builder)
50 if (not VectorArrayVTable<MemberVisitor,
SC::Array<T, N>, T, N>::build(builder))
54 constexpr TypeInfo::ArrayInfo arrayInfo = {
false, N};
55 if (not builder.addType(MemberVisitor::Type::template createArray<
SC::Array<T, N>>(
"SC::Array", 1, arrayInfo)))
59 return builder.addType(MemberVisitor::Type::template createGeneric<T>());
64struct Reflect<SC::Vector<T>>
68 template <
typename MemberVisitor>
69 [[nodiscard]]
static constexpr bool build(MemberVisitor& builder)
72 if (not VectorArrayVTable<MemberVisitor,
SC::Vector<T>, T, -1>::build(builder))
76 constexpr TypeInfo::ArrayInfo arrayInfo = {
false, 0};
77 if (not builder.addType(MemberVisitor::Type::template createArray<
SC::Vector<T>>(
"SC::Vector", 1, arrayInfo)))
81 return builder.addType(MemberVisitor::Type::template createGeneric<T>());
86struct ExtendedTypeInfo<SC::Vector<T>>
88 static constexpr bool IsPacked =
false;
90 [[nodiscard]]
static auto size(
const SC::Vector<T>&
object) {
return object.size(); }
91 [[nodiscard]]
static auto data(
SC::Vector<T>&
object) {
return object.data(); }
92 [[nodiscard]]
static bool resizeWithoutInitializing(
SC::Vector<T>&
object,
size_t newSize)
94 return object.resizeWithoutInitializing(newSize);
96 [[nodiscard]]
static bool resize(
SC::Vector<T>&
object,
size_t newSize) {
return object.resize(newSize); }
99template <
typename Key,
typename Value,
typename Container>
100struct Reflect<VectorMap<Key, Value, Container>> : ReflectStruct<VectorMap<Key, Value, Container>>
104 template <
typename MemberVisitor>
105 [[nodiscard]]
static constexpr bool visit(MemberVisitor&& builder)
122SC_REFLECT_STRUCT_FIELD(0, encoding)
123SC_REFLECT_STRUCT_FIELD(1, data)
124SC_REFLECT_STRUCT_LEAVE()
constexpr const T & min(const T &t1, const T &t2)
Finds the minimum of two values.
Definition: Compiler.h:300
#define SC_COMPILER_OFFSETOF(Class, Field)
Returns offset of Class::Field in bytes.
Definition: Compiler.h:111
unsigned char uint8_t
Platform independent (1) byte unsigned int.
Definition: PrimitiveTypes.h:36
TypeCategory
Enumeration of possible category types recognized by Reflection.
Definition: Reflection.h:32
@ TypeVector
Type is a vector type.
StringEncoding
String Encoding (Ascii, Utf8, Utf16)
Definition: StringIterator.h:17
A contiguous sequence of elements kept inside its inline storage.
Definition: Array.h:43
size_t size() const
Gets size of the array.
Definition: Array.h:198
Class template used to check if a given type IsPacked property is true at compile time.
Definition: Reflection.h:334
Definition: ReflectionSC.h:20
A non-modifiable owning string with associated encoding.
Definition: String.h:30
A contiguous sequence of heap allocated elements.
Definition: Vector.h:51
A map holding VectorMapItem key-value pairs in an unsorted Vector.
Definition: VectorMap.h:33