4#include "../Foundation/Compiler.h"
5#include "../Foundation/Span.h"
16template <
typename T, u
int32_t N>
31 if (values[i] == value)
45 template <u
int32_t N2>
48 if (size + other.size >= N)
50 for (
uint32_t i = 0; i < other.size; ++i)
52 values[size++] = other.values[i];
60 [[nodiscard]]
constexpr bool push_back(
const T& value)
64 values[size++] = value;
77template <
typename Type>
84 : iterator(iteratorStart), iteratorEnd(iteratorStart + capacity)
87 [[nodiscard]]
constexpr bool writeAndAdvance(
const Type& value)
89 if (iterator < iteratorEnd)
116 template <u
int32_t N>
120 constexpr bool operator==(
const Sv other)
const
137static constexpr Sv ClNm()
140#if SC_COMPILER_CLANG || SC_COMPILER_GCC
141 const char* name = __PRETTY_FUNCTION__;
142 constexpr char separating_char =
'=';
146 const char* it = name;
147 while (*it != separating_char)
150 while (it[length] != 0)
152 return Sv(it, length - trim_chars);
154 const char* name = __FUNCSIG__;
155 constexpr char separating_char =
'<';
156 constexpr char ending_char =
'>';
157 const char* it = name;
158 while (*it != separating_char)
160 auto itStart = it + 1;
161 while (*it != ending_char)
167 return Sv(itStart,
static_cast<int>(it - itStart));
172using TypeStringView = Sv;
179#if SC_LANGUAGE_CPP_AT_LEAST_17
182 [[nodiscard]]
static constexpr auto TrimClassName()
184 constexpr auto className = ClNm<T>();
187 for (
uint32_t i = 0; i < className.length; ++i)
189 trimmedName.values[i] = className.data[i];
191 trimmedName.size = className.length;
196 static inline constexpr auto value = TrimClassName();
203 auto className = ClNm<T>();
unsigned int uint32_t
Platform independent (4) bytes unsigned int.
Definition: PrimitiveTypes.h:38
A constexpr array.
Definition: ReflectionFoundation.h:18
constexpr bool push_back(const T &value)
Append a single item to this array.
Definition: ReflectionFoundation.h:60
constexpr bool append(const ArrayWithSize< T, N2 > &other)
Appends another sized array to this one (assuming enough space)
Definition: ReflectionFoundation.h:46
constexpr bool contains(T value, uint32_t *outIndex=nullptr) const
Check if array contains given value, and retrieve index where such item exists.
Definition: ReflectionFoundation.h:27
A minimal ASCII StringView with shortened name to be used in TypeToString.
Definition: ReflectionFoundation.h:101
constexpr Sv()
Construct empty Sv.
Definition: ReflectionFoundation.h:106
uint32_t length
Number of bytes of the ASCII string.
Definition: ReflectionFoundation.h:103
constexpr Sv(const char *data, uint32_t length)
Construct Sv from a pointer to a char* and a length.
Definition: ReflectionFoundation.h:111
constexpr Sv(const char(&data)[N])
Construct Sv from a string literal.
Definition: ReflectionFoundation.h:117
const char * data
Pointer to the start of ASCII string.
Definition: ReflectionFoundation.h:102
Strips down class name produced by ClNm to reduce binary size (from C++17 going forward)
Definition: ReflectionFoundation.h:178
A writable span of objects.
Definition: ReflectionFoundation.h:79
View over a contiguous sequence of items (pointer + size in elements).
Definition: Span.h:20
constexpr const Type * data() const
Returns pointer to first element of the span.
Definition: Span.h:88
constexpr SizeType sizeInBytes() const
Size of Span in bytes.
Definition: Span.h:108
constexpr SizeType sizeInElements() const
Size of Span in elements.
Definition: Span.h:104