diff --git a/source/code/core/collections/natvis/string.natvis b/source/code/core/collections/natvis/string.natvis index ca5c81cc..f825e1a7 100644 --- a/source/code/core/collections/natvis/string.natvis +++ b/source/code/core/collections/natvis/string.natvis @@ -1,6 +1,26 @@ + + 0 <invalid> + {_value} + + _value + _width + _value * _width + + + + + 0 <invalid> + {_value} + + _value + _width + _value * _width + + + HeapString {{ { _data,s8 } }} diff --git a/source/code/core/collections/public/ice/array.hxx b/source/code/core/collections/public/ice/array.hxx new file mode 100644 index 00000000..2bafdca5 --- /dev/null +++ b/source/code/core/collections/public/ice/array.hxx @@ -0,0 +1,412 @@ +#pragma once +#include +#include +#include +#include + +namespace ice +{ + + //! \brief A simple contaier storing items in contignous memory. + //! + //! \details Manages a memory block big enough to hold the items that it holds. + //! + //! \tparam Logic The logic used during memory operations for the given type. + //! This value cab be set by the user to enforce expected behavior for stored types. + template> + struct Array + : public ice::container::ContiguousContainer + , public ice::container::ResizableContainer + { + static_assert( + Logic == ContainerLogic::Complex || ice::TrivialContainerLogicAllowed, + "Collection element type is not allowed with 'Trivial' logic!" + ); + + using ValueType = Type; + using ConstContainerValueType = Type const; + using Iterator = Type*; + using ReverseIterator = std::reverse_iterator; + using ConstIterator = Type const*; + using ConstReverseIterator = std::reverse_iterator; + using SizeType = ice::ncount; + using ContainerTag = ice::concepts::ContiguousContainerTag; + + ice::Allocator* _allocator; + ice::u32 _capacity; + ice::u32 _count; + ValueType* _data; + + inline explicit Array(ice::Allocator& alloc) noexcept; + inline Array(Array&& other) noexcept; + inline Array(Array const& other) noexcept + requires std::copy_constructible; + inline ~Array() noexcept; + + inline Array( + ice::Allocator& alloc, + ice::Span values + ) noexcept requires std::copy_constructible; + + // API Requirements Of: Container and Resizable Container + template + constexpr auto data(this Self& self) noexcept -> ice::container::ValuePtr { return self._data; } + constexpr auto size() const noexcept -> ice::ncount { return { _count, sizeof(ValueType) }; } + + // API Requirements Of: Resizable Container + constexpr auto capacity() const noexcept -> ice::ncount { return { _capacity, sizeof(ValueType) }; } + constexpr void set_capacity(ice::ncount new_capacity) noexcept; + constexpr void resize(ice::ncount new_size) noexcept; + constexpr void clear() noexcept; + + // API Manipulation + template + requires std::convertible_to && std::is_constructible_v + inline void push_back(ItemType&& item) noexcept; + + template + requires (std::convertible_to, Type> + && std::is_constructible_v>) + inline void push_back(ContainerT const& other) noexcept; + + inline void pop_back(ice::ncount count = 1_count) noexcept; + + // API Requirements Of: Data and Memory + constexpr auto data_view(this Array const& self) noexcept -> ice::Data; + constexpr auto memory_view(this Array& self) noexcept -> ice::Memory; + + inline auto operator=(Array&& other) noexcept -> Array&; + inline auto operator=(Array const& other) noexcept -> Array& + requires std::copy_constructible; + + inline operator ice::Span() noexcept; + inline operator ice::Span() const noexcept; + }; + + template + auto data_view(ice::Array const& arr) noexcept -> ice::Data + { + return arr.data_view(); + } + + template + inline Array::Array(ice::Allocator& alloc) noexcept + : _allocator{ &alloc } + , _capacity{ 0 } + , _count{ 0 } + , _data{ nullptr } + { } + + template + inline Array::Array(Array&& other) noexcept + : _allocator{ other._allocator } + , _capacity{ ice::exchange(other._capacity, 0) } + , _count{ ice::exchange(other._count, 0) } + , _data{ ice::exchange(other._data, nullptr) } + { } + + template + inline Array::Array(Array const& other) noexcept + requires std::copy_constructible + : _allocator{ other._allocator } + , _capacity{ 0 } + , _count{ 0 } + , _data{ nullptr } + { + if (other._count > 0) + { + set_capacity(other.size()); + + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_copy_construct_n_at( + memory_view(), + other.data(), + other.size() + ); + } + else + { + ice::memcpy( + memory_view(), + other.data_view() + ); + } + + _count = other._count; + } + } + + template + inline Array::~Array() noexcept + { + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_destruct_n_at(_data, _count); + } + + _allocator->deallocate(memory_view()); + } + + template + inline Array::Array( + ice::Allocator& alloc, + ice::Span values + ) noexcept + requires std::copy_constructible + : _allocator{ &alloc } + , _capacity{ 0 } + , _count{ 0 } + , _data{ nullptr } + { + if (values.not_empty()) + { + set_capacity(values.size()); + + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_copy_construct_n_at( + memory_view(), + values.data(), + values.size() + ); + } + else + { + ice::memcpy(memory_view(), values.data_view()); + } + + _count = values.size().u32(); + } + } + + template + inline auto Array::operator=(Array&& other) noexcept -> Array& + { + if (this != &other) + { + set_capacity(0); + + _allocator = other._allocator; + _capacity = ice::exchange(other._capacity, 0); + _data = ice::exchange(other._data, nullptr); + _count = ice::exchange(other._count, 0); + } + return *this; + } + + template + inline auto Array::operator=(Array const& other) noexcept -> Array& + requires std::copy_constructible + { + if (this != &other) + { + this->clear(); + this->reserve(other.capacity()); + + if (other.size() > 0) + { + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_copy_construct_n_at( + memory_view(), + other.data(), + other.size() + ); + } + else + { + ice::memcpy( + memory_view(), + other.data_view() + ); + } + } + + _count = other._count; + } + return *this; + } + + template + inline Array::operator ice::Span() noexcept + { + return Span{ _data, _count }; + } + + template + inline Array::operator ice::Span() const noexcept + { + return Span{ _data, _count }; + } + + template + inline constexpr void ice::Array::set_capacity(ice::ncount new_capacity) noexcept + { + if (new_capacity == _capacity) + { + return; + } + + if (new_capacity < _count) + { + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_destruct_n_at(_data + new_capacity, _count - new_capacity); + } + + _count = new_capacity.u32(); + } + + ValueType* new_data = nullptr; + if (new_capacity > 0) + { + ice::AllocResult new_buffer = _allocator->allocate(ice::meminfo_of * new_capacity); + ICE_ASSERT_CORE(new_buffer.memory != nullptr); + if (_count > 0) + { + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_move_construct_n_at(new_buffer, _data, _count); + ice::mem_destruct_n_at(_data, _count); + } + else + { + ice::memcpy(new_buffer, data_view()); + } + } + new_data = reinterpret_cast(new_buffer.memory); + } + + _allocator->deallocate(memory_view()); + _data = new_data; + _capacity = new_capacity.u32(); + } + + template + inline constexpr void ice::Array::resize(ice::ncount new_size) noexcept + { + if (_capacity < new_size) + { + set_capacity(new_size); + } + + if (new_size > _count) + { + ice::ncount const missing_items = new_size - _count; + ice::Memory const uninitialized_memory = ice::ptr_add(memory_view(), size()); + + ice::mem_default_construct_n_at( + uninitialized_memory, + missing_items + ); + } + else if constexpr (Logic == ContainerLogic::Complex) + { + static_assert(Logic != ContainerLogic::Trivial); + ice::ncount const destroyed_items = _count - new_size; + + ice::mem_destruct_n_at( + _data + new_size, + destroyed_items + ); + } + + _count = new_size.u32(); + } + + template + inline constexpr void ice::Array::clear() noexcept + { + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_destruct_n_at(_data, _count); + } + _count = 0; + } + + template + template + requires std::convertible_to && std::is_constructible_v + inline void Array::push_back(ItemType&& item) noexcept + { + if (size() == capacity()) + { + this->grow(); + } + + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_construct_at(this->end(), ice::forward(item)); + } + else + { + _data[_count] = Type{ ice::forward(item) }; + } + + _count += 1; + } + + template + template + requires (std::convertible_to, Type> + && std::is_constructible_v>) + inline void ice::Array::push_back(ContainerT const& other) noexcept + { + ice::ncount const current_size = size(); + ice::ncount const required_capacity = other.size() + current_size; + if (required_capacity > _capacity) + { + this->grow(required_capacity); + } + + ice::Memory target_memory = ice::ptr_add(memory_view(), current_size); + if constexpr (ice::concepts::ContiguousContainer && Logic == ContainerLogic::Trivial) + { + ice::memcpy(target_memory, other.data_view()); + } + else + { + ice::mem_copy_construct_it_at( + target_memory, other.begin(), other.end() + ); + } + + _count = required_capacity.u32(); + } + + template + inline void ice::Array::pop_back(ice::ncount count) noexcept + { + ice::ncount const current_count = size(); + ice::ncount const final_count = current_count - ice::min(count, current_count); + if constexpr (Logic == ContainerLogic::Complex) + { + ice::mem_destruct_n_at(data() + final_count, current_count - final_count); + } + + _count = final_count.u32(); + } + + template + inline constexpr auto Array::data_view(this Array const& self) noexcept -> ice::Data + { + return ice::Data{ + .location = self.data(), + .size = self.size(), + .alignment = ice::align_of + }; + } + + template + inline constexpr auto Array::memory_view(this Array& self) noexcept -> ice::Memory + { + return ice::Memory{ + .location = self.data(), + .size = self.capacity(), + .alignment = ice::align_of + }; + } + + +} // namespace ice diff --git a/source/code/core/collections/public/ice/container/array.hxx b/source/code/core/collections/public/ice/container/array.hxx deleted file mode 100644 index 3f80208b..00000000 --- a/source/code/core/collections/public/ice/container/array.hxx +++ /dev/null @@ -1,144 +0,0 @@ -/// Copyright 2022 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - -#pragma once -#include -#include - -namespace ice::array -{ - - template - inline void set_capacity(ice::Array& arr, ice::ucount new_capacity) noexcept; - - template - inline void reserve(ice::Array& arr, ice::ucount min_capacity) noexcept; - - template - inline void grow(ice::Array& arr, ice::ucount min_capacity = 0) noexcept; - - template - inline void resize(ice::Array& arr, ice::ucount new_size) noexcept; - - template - inline void shrink(ice::Array& arr) noexcept; - - template - inline void clear(ice::Array& arr) noexcept; - - template - inline auto slice( - ice::Array& arr, - ice::ucount from_idx = 0, - ice::ucount count = ice::ucount_max - ) noexcept -> ice::Span; - - template - requires std::move_constructible - inline void push_back(ice::Array& arr, Type&& item) noexcept; - - template - requires std::copy_constructible && std::convertible_to - inline void push_back(ice::Array& arr, Value const& item) noexcept; - - template - requires std::copy_constructible - inline void push_back(ice::Array& arr, ice::Array const& items) noexcept; - - template - requires std::copy_constructible - inline void push_back(ice::Array& arr, ice::Span items) noexcept; - - template - requires std::copy_constructible && (std::is_same_v == false) - inline void push_back(ice::Array& arr, ice::Span items, Type(*fn)(Source const&) noexcept) noexcept; - - template - inline void pop_back(ice::Array& arr, ice::ucount count = 1) noexcept; - - template - inline auto begin(ice::Array& arr) noexcept -> typename ice::Array::Iterator; - - template - inline auto end(ice::Array& arr) noexcept -> typename ice::Array::Iterator; - - template - inline auto rbegin(ice::Array& arr) noexcept -> typename ice::Array::ReverseIterator; - - template - inline auto rend(ice::Array& arr) noexcept -> typename ice::Array::ReverseIterator; - - template - inline auto front(ice::Array& arr) noexcept -> Type&; - - template - inline auto back(ice::Array& arr) noexcept -> Type&; - - - - template - inline auto count(ice::Array const& arr) noexcept -> ice::ucount; - - template - inline auto capacity(ice::Array const& arr) noexcept -> ice::ucount; - - template - inline auto size_bytes(ice::Array const& arr) noexcept -> ice::usize; - - template - inline bool any(ice::Array const& arr) noexcept; - - template - inline bool empty(ice::Array const& arr) noexcept; - - template - inline auto slice( - ice::Array const& arr, - ice::ucount from_idx = 0, - ice::ucount count = ice::ucount_max - )noexcept -> ice::Span; - - template - inline auto begin(ice::Array const& arr) noexcept -> typename ice::Array::ConstIterator; - - template - inline auto end(ice::Array const& arr) noexcept -> typename ice::Array::ConstIterator; - - template - inline auto rbegin(ice::Array const& arr) noexcept -> typename ice::Array::ConstReverseIterator; - - template - inline auto rend(ice::Array const& arr) noexcept -> typename ice::Array::ConstReverseIterator; - - template - inline auto front(ice::Array const& arr) noexcept -> Type const&; - - template - inline auto back(ice::Array const& arr) noexcept -> Type const&; - - - - template - inline auto data_view(ice::Array const& arr) noexcept -> ice::Data; - - template - inline auto memory(ice::Array& arr) noexcept -> ice::Memory; - - template - inline auto memset(ice::Array& arr, ice::u8 value) noexcept -> ice::Memory; - - template - inline auto meminfo(ice::Array const& arr) noexcept -> ice::meminfo; - -} // namespace ice::array - -namespace ice -{ - - using ice::array::count; - using ice::array::begin; - using ice::array::end; - -} // namespace ice - -#include "impl/array_impl.inl" diff --git a/source/code/core/collections/public/ice/container/basic_container.hxx b/source/code/core/collections/public/ice/container/basic_container.hxx new file mode 100644 index 00000000..7e574ced --- /dev/null +++ b/source/code/core/collections/public/ice/container/basic_container.hxx @@ -0,0 +1,34 @@ +#pragma once +#include + +namespace ice::container +{ + + struct BasicContainer + { + template + constexpr bool is_empty(this Self const& self) noexcept + { + return self.size() == 0; + } + + template + constexpr bool not_empty(this Self const& self) noexcept + { + return self.is_empty() == false; + } + + template + constexpr auto first(this Self&& self) noexcept -> ice::container::ValueRef + { + return self.data()[0]; + } + + template + constexpr auto last(this Self&& self) noexcept -> ice::container::ValueRef + { + return self.data()[self.size() - 1]; + } + }; + +} // namespace ice::container diff --git a/source/code/core/collections/public/ice/container/container_concepts.hxx b/source/code/core/collections/public/ice/container/container_concepts.hxx new file mode 100644 index 00000000..cc7c5e3e --- /dev/null +++ b/source/code/core/collections/public/ice/container/container_concepts.hxx @@ -0,0 +1,117 @@ +#pragma once +#include +#include +#include + +namespace ice::concepts +{ + + template + concept ContainerType = requires(T t) { + typename std::remove_reference_t::SizeType; + typename std::remove_reference_t::ValueType; + typename std::remove_reference_t::ConstContainerValueType; + typename std::remove_reference_t::Iterator; + typename std::remove_reference_t::ReverseIterator; + typename std::remove_reference_t::ConstIterator; + typename std::remove_reference_t::ConstReverseIterator; + }; + + template + concept Container = ContainerType && requires(T t) { + { t.size() } -> std::convertible_to; + { t.data() } -> std::convertible_to::ValueType const*>; + }; + + template + concept ResizableContainer = Container && requires(T t, ice::ncount size) { + { t.data() } -> std::convertible_to::ValueType*>; + { t.capacity() } -> std::convertible_to; + { t.set_capacity(size) } -> std::convertible_to; + { t.resize(size) } -> std::convertible_to; + { t.clear() } -> std::convertible_to; + }; + + struct ContiguousContainerTag{ }; + + template + concept ContiguousContainer = Container && requires(T t) { + std::is_same_v::ContainerTag, ContiguousContainerTag>; + { t.data_view() } -> std::convertible_to; + }; + + template + concept TrivialContainerLogic = ContainerType + && TrivialContainerLogicAllowed::ValueType>; + + template + concept RegularContainerLogic = ContainerType + && not TrivialContainerLogicAllowed::ValueType>; + +} // namespace ice::concepts + +namespace ice +{ + + template + struct Span; + +} // namespace ice + +namespace ice::container +{ + + template + using ConstCorrectContainerValueType = std::conditional_t< + std::is_const_v>, + typename std::remove_reference_t::ConstContainerValueType, + typename std::remove_reference_t::ValueType + >; + + template + using ConstCorrectContainerIterator = std::conditional_t< + std::is_const_v>, + typename std::remove_reference_t::ConstIterator, + typename std::remove_reference_t::Iterator + >; + + template + using ConstCorrectContainerReverseIterator = std::conditional_t< + std::is_const_v>, + typename std::remove_reference_t::ConstReverseIterator, + typename std::remove_reference_t::ReverseIterator + >; + + template + using ValueType = ConstCorrectContainerValueType; + + template + using ValueRef = ValueType&; + + template + using ValuePtr = ValueType*; + + template + using Iterator = ConstCorrectContainerIterator; + + template + using ReverseIterator = ConstCorrectContainerReverseIterator; + + template + using ContainerType = typename std::remove_reference_t; + + template + using SpanType = ice::Span>; + +} // namespace ice::container + +namespace ice::concepts +{ + + template + concept IterableContainer = ContainerType && requires(T t) { + { t.begin() } -> std::convertible_to>; + { t.end() } -> std::convertible_to>; + }; + +} // namespace ice::concepts diff --git a/source/code/core/collections/public/ice/container/contiguous_container.hxx b/source/code/core/collections/public/ice/container/contiguous_container.hxx new file mode 100644 index 00000000..5b0b9e14 --- /dev/null +++ b/source/code/core/collections/public/ice/container/contiguous_container.hxx @@ -0,0 +1,106 @@ +#pragma once +#include + +namespace ice::container +{ + + template + struct Span; + + struct ContiguousContainer : ice::container::BasicContainer + { + // Accessing Data with Spans + template + constexpr auto subspan( + this Self&& self, + ice::nindex from, + ice::ncount count = ice::ncount_none + ) noexcept -> ice::container::SpanType + { + ice::ncount const item_count = self.size(); + ice::nindex const from_start = ice::min(from, item_count); + ice::ncount const remaining_count = item_count - from_start; + return { self.data() + from_start.native(), count.min_value_or(remaining_count, remaining_count)}; + } + + template + constexpr auto subspan( + this Self&& self, + ice::ref32 refval + ) noexcept -> ice::container::SpanType + { + return self.subspan(refval.offset, refval.size); + } + + template + constexpr auto headspan( + this Self&& self, + ice::ncount count = 1 + ) noexcept -> ice::container::SpanType + { + // If 'count' is not valid we default to '0' so the returned span is empty. + return { self.data(), count.min_value_or(self.size(), 0_count) }; + } + + template + constexpr auto tailspan( + this Self&& self, + ice::nindex offset = 1 + ) noexcept -> ice::container::SpanType + { + ice::nindex const max_offset = self.size(); + offset = offset.min_value_or(max_offset, max_offset); + + // If 'offset' is not valid we default to 'max_size' so the returned span is empty. + return { self.data() + offset, max_offset - offset }; + } + + // Iteration interface + template + constexpr auto begin(this Self&& self) noexcept -> ice::container::Iterator + { + return { self.data() }; + } + + template + constexpr auto end(this Self&& self) noexcept -> ice::container::Iterator + { + return { self.data() + self.size() }; + } + + template + constexpr auto rbegin(this Self&& self) noexcept -> ice::container::ReverseIterator + { + return ice::container::ReverseIterator{ self.data() + self.size() }; + } + + template + constexpr auto rend(this Self&& self) noexcept -> ice::container::ReverseIterator + { + return ice::container::ReverseIterator{ self.data() }; + } + + // Operators + template + constexpr auto operator[](this Self&& self, ice::nindex index) noexcept -> ice::container::ValueRef + { + return self.data()[index]; + } + + // Data API + template + inline auto meminfo(this Self const& self) noexcept -> ice::meminfo + { + return ice::meminfo_of * self.size(); + } + + template requires (ice::concepts::TrivialContainerLogic) + inline auto memset(this Self const& self, ice::u8 value) noexcept -> ice::Memory + { + ice::Memory mem{ self.data(), self.size(), ice::align_of> }; + ice::memset(mem.location, value, mem.size.value); + return mem; + } + }; + +} // namespace ice::container diff --git a/source/code/core/collections/public/ice/container/hashmap.hxx b/source/code/core/collections/public/ice/container/hashmap.hxx index edd7eb4c..c88b1218 100644 --- a/source/code/core/collections/public/ice/container/hashmap.hxx +++ b/source/code/core/collections/public/ice/container/hashmap.hxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include namespace ice @@ -13,7 +13,7 @@ namespace ice { template - inline void reserve(ice::HashMap& map, ice::ucount new_capacity) noexcept; + inline void reserve(ice::HashMap& map, ice::u32 new_capacity) noexcept; template inline void clear(ice::HashMap& map) noexcept; @@ -48,7 +48,7 @@ namespace ice template requires HashMapReadAccess - inline auto count(HashMapType const& map) noexcept -> ice::ucount; + inline auto count(HashMapType const& map) noexcept -> ice::u32; template requires HashMapReadAccess inline bool full(HashMapType const& map) noexcept; @@ -115,7 +115,7 @@ namespace ice template - inline auto count(ice::HashMap const& map, ice::u64 key) noexcept -> ice::ucount; + inline auto count(ice::HashMap const& map, ice::u64 key) noexcept -> ice::u32; template inline void get(ice::HashMap const& map, ice::u64 key, ice::Array& items) noexcept; diff --git a/source/code/core/collections/public/ice/container/impl/array_impl.inl b/source/code/core/collections/public/ice/container/impl/array_impl.inl deleted file mode 100644 index 356915c5..00000000 --- a/source/code/core/collections/public/ice/container/impl/array_impl.inl +++ /dev/null @@ -1,573 +0,0 @@ -/// Copyright 2022 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - -namespace ice -{ - - template - inline Array::Array(ice::Allocator& alloc) noexcept - : _allocator{ &alloc } - , _capacity{ 0 } - , _count{ 0 } - , _data{ nullptr } - { } - - template - inline Array::Array(Array&& other) noexcept - : _allocator{ other._allocator } - , _capacity{ ice::exchange(other._capacity, 0) } - , _count{ ice::exchange(other._count, 0) } - , _data{ ice::exchange(other._data, nullptr) } - { - } - - template - inline Array::Array(Array const& other) noexcept - requires std::copy_constructible - : _allocator{ other._allocator } - , _capacity{ 0 } - , _count{ 0 } - , _data{ nullptr } - { - if (other._count > 0) - { - ice::array::set_capacity(*this, other._count); - - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_copy_construct_n_at( - ice::array::memory(*this), - other._data, - other._count - ); - } - else - { - ice::memcpy( - ice::array::memory(*this), - ice::array::data_view(other) - ); - } - - _count = other._count; - } - } - - template - inline Array::~Array() noexcept - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_destruct_n_at(_data, _count); - } - - _allocator->deallocate(ice::array::memory(*this)); - } - - template - inline Array::Array( - ice::Allocator& alloc, - ice::Span values - ) noexcept - requires std::copy_constructible - : _allocator{ &alloc } - , _capacity{ 0 } - , _count{ 0 } - , _data{ nullptr } - { - if (ice::span::count(values) > 0) - { - ice::array::set_capacity(*this, ice::span::count(values)); - - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_copy_construct_n_at( - ice::array::memory(*this), - ice::span::data(values), - ice::span::count(values) - ); - } - else - { - ice::memcpy(_data, ice::span::data(values), ice::span::size_bytes(values)); - } - - _count = ice::span::count(values); - } - } - - template - inline auto Array::operator=(Array&& other) noexcept -> Array& - { - if (this != &other) - { - ice::array::set_capacity(*this, 0); - - _allocator = other._allocator; - _capacity = ice::exchange(other._capacity, 0); - _data = ice::exchange(other._data, nullptr); - _count = ice::exchange(other._count, 0); - } - return *this; - } - - template - inline auto Array::operator=(Array const& other) noexcept -> Array& - requires std::copy_constructible - { - if (this != &other) - { - ice::array::clear(*this); - ice::array::reserve(*this, other._capacity); - - if (other._count > 0) - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_copy_construct_n_at( - ice::array::memory(*this), - other._data, - other._count - ); - } - else - { - ice::memcpy( - ice::array::memory(*this), - ice::array::data_view(other) - ); - } - } - - _count = other._count; - } - return *this; - } - - template - inline auto Array::operator[](ice::ucount idx) noexcept -> Type& - { - // TODO: Assert - return _data[idx]; - } - - template - inline auto Array::operator[](ice::ucount idx) const noexcept -> Type const& - { - // TODO: Assert - return _data[idx]; - } - - template - inline Array::operator ice::Span() noexcept - { - return Span{ _data, _count }; - } - - template - inline Array::operator ice::Span() const noexcept - { - return Span{ _data, _count }; - } - - namespace array - { - - template - inline void set_capacity(ice::Array& arr, ice::ucount new_capacity) noexcept - { - if (new_capacity == arr._capacity) - { - return; - } - - if (new_capacity < arr._count) - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_destruct_n_at(arr._data + new_capacity, arr._count - new_capacity); - } - - arr._count = new_capacity; - } - - Type* new_data = nullptr; - if (new_capacity > 0) - { - ice::AllocResult new_buffer = arr._allocator->allocate(ice::meminfo_of * new_capacity); - ICE_ASSERT_CORE(new_buffer.memory != nullptr); - if (arr._count > 0) - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_move_construct_n_at(new_buffer, arr._data, arr._count); - ice::mem_destruct_n_at(arr._data, arr._count); - } - else - { - ice::memcpy(new_buffer, ice::array::data_view(arr)); - } - } - new_data = reinterpret_cast(new_buffer.memory); - } - - arr._allocator->deallocate(ice::array::memory(arr)); - arr._data = new_data; - arr._capacity = new_capacity; - } - - template - inline void reserve(ice::Array& arr, ice::ucount min_capacity) noexcept - { - if (arr._capacity < min_capacity) - { - ice::array::set_capacity(arr, min_capacity); - } - } - - template - inline void grow(ice::Array& arr, ice::ucount min_capacity) noexcept - { - ice::ucount new_capacity = arr._capacity * 2 + 4; - if (new_capacity < min_capacity) - { - new_capacity = min_capacity; - } - ice::array::set_capacity(arr, new_capacity); - } - - template - inline void resize(ice::Array& arr, ice::ucount new_count) noexcept - { - if (arr._capacity < new_count) - { - ice::array::set_capacity(arr, new_count); - } - - if (new_count > arr._count) - { - ice::ucount const missing_items = new_count - arr._count; - - // Even for trivial logic we construct items so at least the default ctor is called. - ice::mem_construct_n_at( - Memory{ .location = arr._data + arr._count, .size = ice::size_of * missing_items, .alignment = ice::align_of }, - missing_items - ); - } - else if constexpr (Logic == ContainerLogic::Complex) - { - static_assert(Logic != ContainerLogic::Trivial); - ice::ucount const destroyed_items = arr._count - new_count; - - ice::mem_destruct_n_at( - arr._data + new_count, - destroyed_items - ); - } - - arr._count = new_count; - } - - template - inline void shrink(ice::Array& arr) noexcept - { - ice::array::set_capacity(arr, arr._count); - } - - template - inline void clear(ice::Array& arr) noexcept - { - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_destruct_n_at(arr._data, arr._count); - } - - arr._count = 0; - } - - template - inline auto slice(ice::Array& arr, ice::u32 from_idx, ice::u32 count) noexcept -> ice::Span - { - return ice::span::subspan(arr, from_idx, count); - } - - template - requires std::move_constructible - inline void push_back(ice::Array& arr, Type&& item) noexcept - { - if (arr._count == arr._capacity) - { - ice::array::grow(arr); - } - - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_move_construct_at( - Memory{ .location = arr._data + arr._count, .size = ice::size_of, .alignment = ice::align_of }, - ice::forward(item) - ); - } - else - { - arr._data[arr._count] = Type{ item }; - } - - arr._count += 1; - } - - template - requires std::copy_constructible && std::convertible_to - inline void push_back(ice::Array& arr, Value const& item) noexcept - { - if (arr._count == arr._capacity) - { - ice::array::grow(arr); - } - - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_copy_construct_at( - Memory{ .location = arr._data + arr._count, .size = ice::size_of, .alignment = ice::align_of }, - item - ); - } - else - { - arr._data[arr._count] = Type{ item }; - } - - arr._count += 1; - } - - template - requires std::copy_constructible - inline void push_back(ice::Array& arr, ice::Array const& items) noexcept - { - return ice::array::push_back(arr, ice::array::slice(items)); - } - - template - requires std::copy_constructible - inline void push_back(ice::Array& arr, ice::Span items) noexcept - { - ice::ucount const required_capacity = arr._count + ice::span::count(items); - if (required_capacity > arr._capacity) - { - ice::array::grow(arr, required_capacity); - } - - ice::ucount const missing_items = required_capacity - arr._count; - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_copy_construct_n_at( - Memory{ .location = arr._data + arr._count, .size = ice::size_of * missing_items, .alignment = ice::align_of }, - ice::span::data(items), - ice::span::count(items) - ); - } - else - { - ice::memcpy( - Memory{ .location = arr._data + arr._count, .size = ice::size_of * missing_items, .alignment = ice::align_of }, - ice::span::data_view(items) - ); - } - - arr._count += ice::span::count(items); - } - - template - requires std::copy_constructible && (std::is_same_v == false) - inline void push_back(ice::Array& arr, ice::Span items, Type(*fn)(Source const&) noexcept) noexcept - { - ice::ucount const required_capacity = arr._count + ice::span::count(items); - if (required_capacity > arr._capacity) - { - ice::array::grow(arr, required_capacity); - } - - ice::ucount const missing_items = required_capacity - arr._count; - for (ice::u32 src_idx = 0; src_idx < missing_items; ++src_idx) - { - ice::array::push_back(arr, fn(items[src_idx])); - } - } - - template - inline void pop_back(ice::Array& arr, ice::ucount count /*= 1*/) noexcept - { - count = ice::min(count, arr._count); - if constexpr (Logic == ContainerLogic::Complex) - { - ice::mem_destruct_n_at(arr._data + (arr._count - count), count); - } - - if (arr._count > count) - { - arr._count -= count; - } - else - { - arr._count = 0; - } - } - - template - inline auto begin(ice::Array& arr) noexcept -> typename ice::Array::Iterator - { - return arr._data; - } - - template - inline auto end(ice::Array& arr) noexcept -> typename ice::Array::Iterator - { - return arr._data + arr._count; - } - - template - inline auto rbegin(ice::Array& arr) noexcept -> typename ice::Array::ReverseIterator - { - return typename ice::Array::ReverseIterator{ arr._data + arr._count }; - } - - template - inline auto rend(ice::Array& arr) noexcept -> typename ice::Array::ReverseIterator - { - return typename ice::Array::ReverseIterator{ arr._data }; - } - - template - inline auto front(ice::Array& arr) noexcept -> Type& - { - // #todo assert - return arr._data[0]; - } - - template - inline auto back(ice::Array& arr) noexcept -> Type& - { - // #todo assert - return arr._data[arr._count - 1]; - } - - - - template - inline auto count(ice::Array const& arr) noexcept -> ice::ucount - { - return arr._count; - } - - template - inline auto capacity(ice::Array const& arr) noexcept -> ice::ucount - { - return arr._capacity; - } - - template - inline auto size_bytes(ice::Array const& arr) noexcept -> ice::usize - { - return ice::size_of * arr._count; - } - - template - inline bool any(ice::Array const& arr) noexcept - { - return arr._count != 0; - } - - template - inline bool empty(ice::Array const& arr) noexcept - { - return arr._count == 0; - } - - template - inline auto slice(ice::Array const& arr, ice::ucount from_idx, ice::ucount count) noexcept -> ice::Span - { - return ice::span::subspan(arr, from_idx, count); - } - - template - inline auto slice(ice::Array const& arr, ice::ref32 ref) noexcept -> ice::Span - { - return ice::span::subspan(arr, ref); - } - - template - inline auto begin(ice::Array const& arr) noexcept -> typename ice::Array::ConstIterator - { - return arr._data; - } - - template - inline auto end(ice::Array const& arr) noexcept -> typename ice::Array::ConstIterator - { - return arr._data + arr._count; - } - - template - inline auto rbegin(ice::Array const& arr) noexcept -> typename ice::Array::ConstReverseIterator - { - return typename ice::Array::ConstReverseIterator{ arr._data + arr._count }; - } - - template - inline auto rend(ice::Array const& arr) noexcept -> typename ice::Array::ConstReverseIterator - { - return typename ice::Array::ConstReverseIterator{ arr._data }; - } - - template - inline auto front(ice::Array const& arr) noexcept -> Type const& - { - // #todo assert - return arr._data[0]; - } - - template - inline auto back(ice::Array const& arr) noexcept -> Type const& - { - // #todo assert - return arr._data[arr._size - 1]; - } - - - - template - inline auto data_view(ice::Array const& arr) noexcept -> ice::Data - { - return ice::Data{ - .location = arr._data, - .size = ice::size_of * arr._count, - .alignment = ice::align_of - }; - } - - template - inline auto memory(ice::Array& arr) noexcept -> ice::Memory - { - return ice::Memory{ - .location = arr._data, - .size = ice::size_of * arr._capacity, - .alignment = ice::align_of - }; - } - - template - inline auto memset(ice::Array& arr, ice::u8 value) noexcept -> ice::Memory - { - ice::Memory const mem = ice::array::memory(arr); - ice::memset(mem.location, value, mem.size.value); - return mem; - } - - template - inline auto meminfo(ice::Array const& arr) noexcept -> ice::meminfo - { - return ice::meminfo_of * ice::array::count(arr); - } - - } // namespace array - -} // namespace ice diff --git a/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl b/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl index d7420a1e..6cbd4917 100644 --- a/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl +++ b/source/code/core/collections/public/ice/container/impl/hashmap_impl.inl @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT namespace ice @@ -11,31 +11,31 @@ namespace ice struct FindResult; - constexpr auto calc_storage_capacity(ice::ucount max_count) noexcept -> ice::ucount; + constexpr auto calc_storage_capacity(ice::u32 max_count) noexcept -> ice::u32; template - inline bool can_store_count(ice::HashMap const& map, ice::ucount expected_count) noexcept; + inline bool can_store_count(ice::HashMap const& map, ice::u32 expected_count) noexcept; template requires HashMapReadAccess inline auto find(HashMapType const& map, ice::u64 key) noexcept -> FindResult; template - inline auto make(ice::HashMap& map, ice::u64 key) noexcept -> ice::ucount; + inline auto make(ice::HashMap& map, ice::u64 key) noexcept -> ice::u32; template inline void erase(ice::HashMap& map, FindResult const fr) noexcept; template requires HashMapReadAccess - inline auto find_or_fail(HashMapType const& map, ice::u64 key) noexcept -> ice::ucount; + inline auto find_or_fail(HashMapType const& map, ice::u64 key) noexcept -> ice::u32; template - inline auto find_or_make(ice::HashMap& map, ice::u64 key, bool& found) noexcept -> ice::ucount; + inline auto find_or_make(ice::HashMap& map, ice::u64 key, bool& found) noexcept -> ice::u32; template inline void find_and_erase(ice::HashMap& map, ice::u64 key) noexcept; template - inline void rehash(ice::HashMap& map, ice::ucount new_capacity) noexcept; + inline void rehash(ice::HashMap& map, ice::u32 new_capacity) noexcept; template inline auto find(ice::HashMap& map, typename ice::HashMap::ConstIterator it) noexcept -> FindResult; @@ -217,22 +217,22 @@ namespace ice struct FindResult { - ice::ucount hash_i; - ice::ucount entry_prev; - ice::ucount entry_i; + ice::u32 hash_i; + ice::u32 entry_prev; + ice::u32 entry_i; }; - constexpr auto calc_storage_capacity(ice::ucount max_count) noexcept -> ice::ucount + constexpr auto calc_storage_capacity(ice::u32 max_count) noexcept -> ice::u32 { - return ice::ucount(max_count / Constant_HashMapMaxFill + 0.99f /* magic */); + return ice::u32(max_count / Constant_HashMapMaxFill + 0.99f /* magic */); } template - inline bool can_store_count(ice::HashMap const& map, ice::ucount expected_count) noexcept + inline bool can_store_count(ice::HashMap const& map, ice::u32 expected_count) noexcept { - ice::ucount const max_ucount = ice::ucount(map._capacity * Constant_HashMapMaxFill); - return max_ucount >= expected_count; + ice::u32 const max_u32 = ice::u32(map._capacity * Constant_HashMapMaxFill); + return max_u32 >= expected_count; } template requires HashMapReadAccess @@ -266,7 +266,7 @@ namespace ice } template - inline auto make(ice::HashMap& map, ice::u64 key) noexcept -> ice::ucount + inline auto make(ice::HashMap& map, ice::u64 key) noexcept -> ice::u32 { FindResult fr = ice::hashmap::detail::find(map, key); if (fr.hash_i == Constant_EndOfList) @@ -275,7 +275,7 @@ namespace ice } // The count is now the new index. - ice::ucount const index = map._count; + ice::u32 const index = map._count; // Set the key we are use to make the new entry. map._entries[index].key = key; @@ -366,13 +366,13 @@ namespace ice } template requires HashMapReadAccess - inline auto find_or_fail(HashMapType const& map, ice::u64 key) noexcept -> ice::ucount + inline auto find_or_fail(HashMapType const& map, ice::u64 key) noexcept -> ice::u32 { return ice::hashmap::detail::find(map, key).entry_i; } template - inline auto find_or_make(ice::HashMap& map, ice::u64 key, bool& found) noexcept -> ice::ucount + inline auto find_or_make(ice::HashMap& map, ice::u64 key, bool& found) noexcept -> ice::u32 { FindResult fr = ice::hashmap::detail::find(map, key); @@ -389,7 +389,7 @@ namespace ice } // The count is now the new index. - ice::ucount const index = map._count; + ice::u32 const index = map._count; // Set the key we are use to make the new entry. map._entries[index].key = key; @@ -417,32 +417,32 @@ namespace ice } template - inline void rehash(ice::HashMap& map, ice::ucount new_capacity) noexcept + inline void rehash(ice::HashMap& map, ice::u32 new_capacity) noexcept { using Entry = typename ice::HashMap::Entry; ICE_ASSERT_CORE(new_capacity * Constant_HashMapMaxFill >= map._count); - ice::ucount* new_hashes_ptr = nullptr; + ice::u32* new_hashes_ptr = nullptr; Entry* new_entries_ptr = nullptr; Type* new_value_ptr = nullptr; if (new_capacity > 0) { - ice::ucount const new_capacity_values = ice::ucount(new_capacity * Constant_HashMapMaxFill); + ice::u32 const new_capacity_values = ice::u32(new_capacity * Constant_HashMapMaxFill); ice::meminfo alloc_info = ice::meminfo_of * new_capacity; ice::usize const offset_entries = alloc_info += ice::meminfo_of * new_capacity_values; ice::usize const offset_values = alloc_info += ice::meminfo_of * new_capacity_values; ice::AllocResult const new_data = map._allocator->allocate(alloc_info); - new_hashes_ptr = reinterpret_cast(new_data.memory); + new_hashes_ptr = reinterpret_cast(new_data.memory); new_entries_ptr = reinterpret_cast(ice::ptr_add(new_data.memory, offset_entries)); new_value_ptr = reinterpret_cast(ice::ptr_add(new_data.memory, offset_values)); // Prepare hashes memory // TODO: memset? - for (ice::ucount& hashed_idx : ice::Span{ new_hashes_ptr, new_capacity }) + for (ice::u32& hashed_idx : ice::Span{ new_hashes_ptr, new_capacity }) { hashed_idx = Constant_EndOfList; } @@ -547,7 +547,7 @@ namespace ice //! //! \note Keep in mind, the number of valies a hashmap can store is lower than it's total capacity. template - inline void reserve(ice::HashMap& map, ice::ucount new_count) noexcept + inline void reserve(ice::HashMap& map, ice::u32 new_count) noexcept { ice::hashmap::detail::rehash(map, ice::hashmap::detail::calc_storage_capacity(new_count)); } @@ -561,7 +561,7 @@ namespace ice } map._count = 0; - for (ice::ucount hash_idx = 0; hash_idx < map._capacity; ++hash_idx) + for (ice::u32 hash_idx = 0; hash_idx < map._capacity; ++hash_idx) { // TODO: memset? map._hashes[hash_idx] = ice::hashmap::detail::Constant_EndOfList; @@ -584,7 +584,7 @@ namespace ice } bool found = false; - ice::ucount const index = ice::hashmap::detail::find_or_make(map, key, found); + ice::u32 const index = ice::hashmap::detail::find_or_make(map, key, found); if constexpr (Logic == ContainerLogic::Complex) { // If the index was found we need to destroy the previous value. @@ -618,7 +618,7 @@ namespace ice } bool found = false; - ice::ucount const index = ice::hashmap::detail::find_or_make(map, key, found); + ice::u32 const index = ice::hashmap::detail::find_or_make(map, key, found); if constexpr (Logic == ContainerLogic::Complex) { // If the index was found we need to destroy the previous value. @@ -651,7 +651,7 @@ namespace ice ice::hashmap::set(map, key, ice::forward(value)); } - ice::ucount const index = ice::hashmap::detail::find_or_fail(map, key); + ice::u32 const index = ice::hashmap::detail::find_or_fail(map, key); ICE_ASSERT_CORE(index != ice::hashmap::detail::Constant_EndOfList); return *(map._data + index); } @@ -659,7 +659,7 @@ namespace ice template inline auto try_get(ice::HashMap& map, ice::u64 key) noexcept -> Type* { - ice::ucount const index = ice::hashmap::detail::find_or_fail(map, key); + ice::u32 const index = ice::hashmap::detail::find_or_fail(map, key); return index == ice::hashmap::detail::Constant_EndOfList ? nullptr : map._data + index; @@ -680,7 +680,7 @@ namespace ice template requires HashMapReadAccess - inline auto count(HashMapType const& map) noexcept -> ice::ucount + inline auto count(HashMapType const& map) noexcept -> ice::u32 { return map._count; } @@ -688,7 +688,7 @@ namespace ice template requires HashMapReadAccess inline bool full(HashMapType const& map) noexcept { - ice::ucount const max_count = ice::ucount(map._capacity * ice::hashmap::detail::Constant_HashMapMaxFill); + ice::u32 const max_count = ice::u32(map._capacity * ice::hashmap::detail::Constant_HashMapMaxFill); ICE_ASSERT_CORE(max_count >= map._count); return max_count == map._count; @@ -715,7 +715,7 @@ namespace ice template requires HashMapReadAccess inline auto get(HashMapType const& map, ice::u64 key, typename HashMapType::ValueType const& fallback_value) noexcept -> typename HashMapType::ValueType const& { - ice::ucount const index = ice::hashmap::detail::find_or_fail(map, key); + ice::u32 const index = ice::hashmap::detail::find_or_fail(map, key); return index == ice::hashmap::detail::Constant_EndOfList ? fallback_value : map._data[index]; @@ -724,7 +724,7 @@ namespace ice template requires HashMapReadAccess inline auto get(HashMapType const& map, ice::u64 key, std::nullptr_t) noexcept -> typename HashMapType::ValueType { - ice::ucount const index = ice::hashmap::detail::find_or_fail(map, key); + ice::u32 const index = ice::hashmap::detail::find_or_fail(map, key); return index == ice::hashmap::detail::Constant_EndOfList ? nullptr : map._data[index]; @@ -733,7 +733,7 @@ namespace ice template requires HashMapReadAccess inline auto try_get(HashMapType const& map, ice::u64 key) noexcept -> typename HashMapType::ValueType const* { - ice::ucount const index = ice::hashmap::detail::find_or_fail(map, key); + ice::u32 const index = ice::hashmap::detail::find_or_fail(map, key); return index == ice::hashmap::detail::Constant_EndOfList ? nullptr : map._data + index; @@ -767,7 +767,7 @@ namespace ice template inline auto memory(ice::HashMap& map) noexcept -> ice::Memory { - ice::ucount const capacity_values = ice::ucount(map._capacity * ice::hashmap::detail::Constant_HashMapMaxFill); + ice::u32 const capacity_values = ice::u32(map._capacity * ice::hashmap::detail::Constant_HashMapMaxFill); // TODO: Easier way to calculate the allocated size. ice::meminfo alloc_info = ice::meminfo_of * map._capacity; @@ -795,7 +795,7 @@ namespace ice ice::hashmap::detail::grow(map); } - ice::ucount const index = ice::hashmap::detail::make(map, key); + ice::u32 const index = ice::hashmap::detail::make(map, key); if constexpr (Logic == ContainerLogic::Complex) { // If the index is below the current map._count we need to destroy the previous value. @@ -827,7 +827,7 @@ namespace ice ice::hashmap::detail::grow(map); } - ice::ucount const index = ice::hashmap::detail::make(map, key); + ice::u32 const index = ice::hashmap::detail::make(map, key); if constexpr (Logic == ContainerLogic::Complex) { // If the index is below the current map._count we need to destroy the previous value. @@ -871,11 +871,11 @@ namespace ice } template - inline auto count(ice::HashMap const& map, ice::u64 key) noexcept -> ice::ucount + inline auto count(ice::HashMap const& map, ice::u64 key) noexcept -> ice::u32 { using ConstIterator = typename ice::HashMap::ConstIterator; - ice::ucount result = 0; + ice::u32 result = 0; ConstIterator it = ice::multi_hashmap::find_first(map, key); while (it._entry != nullptr) { @@ -893,7 +893,7 @@ namespace ice while (it._entry != nullptr) { - ice::array::push_back(items, *it._value); + items.push_back(*it._value); it = ice::multi_hashmap::find_next(map, it); } } @@ -903,7 +903,7 @@ namespace ice { using ConstIterator = typename ice::HashMap::ConstIterator; - ice::ucount const index = ice::hashmap::detail::find_or_fail(map, key); + ice::u32 const index = ice::hashmap::detail::find_or_fail(map, key); if (index == ice::hashmap::detail::Constant_EndOfList) { return ConstIterator{ nullptr, nullptr }; @@ -924,7 +924,7 @@ namespace ice using ConstIterator = typename ice::HashMap::ConstIterator; - ice::ucount index = it._entry->next; + ice::u32 index = it._entry->next; while (index != ice::hashmap::detail::Constant_EndOfList) { if (map._entries[index].key == it._entry->key) diff --git a/source/code/core/collections/public/ice/container/impl/queue_impl.inl b/source/code/core/collections/public/ice/container/impl/queue_impl.inl index 044d40a9..e2b7a320 100644 --- a/source/code/core/collections/public/ice/container/impl/queue_impl.inl +++ b/source/code/core/collections/public/ice/container/impl/queue_impl.inl @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT namespace ice @@ -8,10 +8,10 @@ namespace ice { template - inline void destroy_head_items(ice::Queue& queue, ice::ucount destroy_count) noexcept; + inline void destroy_head_items(ice::Queue& queue, ice::u32 destroy_count) noexcept; template - inline void destroy_tail_items(ice::Queue& queue, ice::ucount destroy_count) noexcept; + inline void destroy_tail_items(ice::Queue& queue, ice::u32 destroy_count) noexcept; template inline void copy_items_to_new_location(ice::Memory dest, ice::Queue const& queue) noexcept; @@ -76,10 +76,10 @@ namespace ice { if constexpr (Logic == ContainerLogic::Complex) { - ice::ucount const last_raw_idx = _offset + _count; + ice::u32 const last_raw_idx = _offset + _count; if (last_raw_idx > _capacity) { - ice::ucount const wrapped_count = last_raw_idx - _capacity; + ice::u32 const wrapped_count = last_raw_idx - _capacity; ice::mem_destruct_n_at(_data + _offset, _count - wrapped_count); // Destroyes elements at the end of the ring buffer [_offset, count_until_capacity) ice::mem_destruct_n_at(_data, wrapped_count); // Destroys wrapped tail elements [0, tail_size) } @@ -134,13 +134,13 @@ namespace ice } template - inline auto Queue::operator[](ice::ucount idx) noexcept -> Type& + inline auto Queue::operator[](ice::u32 idx) noexcept -> Type& { return _data[(idx + _offset) % _capacity]; } template - inline auto Queue::operator[](ice::ucount idx) const noexcept -> Type const& + inline auto Queue::operator[](ice::u32 idx) const noexcept -> Type const& { return _data[(idx + _offset) % _capacity]; } @@ -149,11 +149,11 @@ namespace ice { template - void destroy_head_items(ice::Queue& queue, ice::ucount destroy_count) noexcept + void destroy_head_items(ice::Queue& queue, ice::u32 destroy_count) noexcept { - ice::ucount const raw_end_idx = queue._offset + destroy_count; - ice::ucount const start_idx = queue._offset; - ice::ucount const end_idx = raw_end_idx % queue._capacity; + ice::u32 const raw_end_idx = queue._offset + destroy_count; + ice::u32 const start_idx = queue._offset; + ice::u32 const end_idx = raw_end_idx % queue._capacity; // We got a wrapped case if (start_idx > end_idx) @@ -168,11 +168,11 @@ namespace ice } template - void destroy_tail_items(ice::Queue& queue, ice::ucount destroy_count) noexcept + void destroy_tail_items(ice::Queue& queue, ice::u32 destroy_count) noexcept { - ice::ucount const raw_end_idx = queue._offset + queue._count; - ice::ucount const start_idx = (raw_end_idx - destroy_count) % queue._capacity; - ice::ucount const end_idx = raw_end_idx % queue._capacity; + ice::u32 const raw_end_idx = queue._offset + queue._count; + ice::u32 const start_idx = (raw_end_idx - destroy_count) % queue._capacity; + ice::u32 const end_idx = raw_end_idx % queue._capacity; // We got a wrapped case if (start_idx > end_idx) @@ -189,8 +189,8 @@ namespace ice template inline void copy_items_to_new_location(ice::Memory dest, ice::Queue const& queue) noexcept { - ice::ucount const start_idx = queue._offset; - ice::ucount const head_count = queue._capacity - start_idx; + ice::u32 const start_idx = queue._offset; + ice::u32 const head_count = queue._capacity - start_idx; ice::usize const head_size = ice::size_of * head_count; ice::mem_copy_construct_n_at(dest, queue._data + start_idx, head_count); @@ -203,8 +203,8 @@ namespace ice template inline void move_items_to_new_location(ice::Memory dest, ice::Queue& queue) noexcept { - ice::ucount const start_idx = queue._offset; - ice::ucount const head_count = queue._capacity - start_idx; + ice::u32 const start_idx = queue._offset; + ice::u32 const head_count = queue._capacity - start_idx; ice::usize const head_size = ice::size_of * head_count; ice::mem_move_construct_n_at(dest, queue._data + start_idx, head_count); @@ -223,8 +223,8 @@ namespace ice { ice::usize const total_size = ice::size_of * queue._count; - ice::ucount const head_count = std::min(queue._offset + queue._count, queue._capacity) - queue._offset; - ice::ucount const tail_count = queue._count - head_count; + ice::u32 const head_count = std::min(queue._offset + queue._count, queue._capacity) - queue._offset; + ice::u32 const tail_count = queue._count - head_count; ice::usize const head_size = ice::size_of * head_count; ice::usize const head_end_offset = ice::size_of * head_count; @@ -257,7 +257,7 @@ namespace ice { template - inline void set_capacity(ice::Queue& queue, ice::ucount new_capacity) noexcept + inline void set_capacity(ice::Queue& queue, ice::u32 new_capacity) noexcept { if (new_capacity == queue._capacity) { @@ -299,7 +299,7 @@ namespace ice } template - inline void reserve(ice::Queue& queue, ice::ucount min_capacity) noexcept + inline void reserve(ice::Queue& queue, ice::u32 min_capacity) noexcept { if (queue._capacity < min_capacity) { @@ -308,9 +308,9 @@ namespace ice } template - inline void grow(ice::Queue& queue, ice::ucount min_capacity /*= 0*/) noexcept + inline void grow(ice::Queue& queue, ice::u32 min_capacity /*= 0*/) noexcept { - ice::ucount new_capacity = queue._count * 2 + 4; + ice::u32 new_capacity = queue._count * 2 + 4; if (new_capacity < min_capacity) { new_capacity = min_capacity; @@ -319,7 +319,7 @@ namespace ice } template - inline void resize(ice::Queue& queue, ice::ucount new_count) noexcept + inline void resize(ice::Queue& queue, ice::u32 new_count) noexcept { if (queue._capacity < new_count) { @@ -329,14 +329,14 @@ namespace ice // Even for trivial logic we construct items so at least the default ctor is called. if (new_count > queue._count) { - ice::ucount const missing_items = new_count - queue._count; - ice::ucount const start_idx = (queue._offset + queue._count) % queue._capacity; + ice::u32 const missing_items = new_count - queue._count; + ice::u32 const start_idx = (queue._offset + queue._count) % queue._capacity; - ice::ucount const end_idx = ice::min(start_idx + missing_items, queue._capacity); - ice::ucount const wrapped_end_idx = missing_items - (end_idx - start_idx); + ice::u32 const end_idx = ice::min(start_idx + missing_items, queue._capacity); + ice::u32 const wrapped_end_idx = missing_items - (end_idx - start_idx); // Construct until we hit end of the queue buffer - ice::mem_construct_n_at( + ice::mem_default_construct_n_at( Memory{ .location = queue._data + start_idx, .size = ice::size_of * (end_idx - start_idx), @@ -345,7 +345,7 @@ namespace ice (end_idx - start_idx) ); // Construct the rest wrapped around the buffer - ice::mem_construct_n_at( + ice::mem_default_construct_n_at( Memory{ .location = queue._data, .size = ice::size_of * wrapped_end_idx, @@ -389,7 +389,7 @@ namespace ice ice::queue::grow(queue); } - ice::ucount const item_idx = (queue._offset + queue._count) % queue._capacity; + ice::u32 const item_idx = (queue._offset + queue._count) % queue._capacity; if constexpr (Logic == ContainerLogic::Complex) { ice::mem_move_construct_at( @@ -414,7 +414,7 @@ namespace ice ice::queue::grow(queue); } - ice::ucount const item_idx = (queue._offset + queue._count) % queue._capacity; + ice::u32 const item_idx = (queue._offset + queue._count) % queue._capacity; if constexpr (Logic == ContainerLogic::Complex) { ice::mem_copy_construct_at( @@ -438,20 +438,20 @@ namespace ice requires std::copy_constructible inline void push_back(ice::Queue& queue, ice::Span items) noexcept { - ice::ucount const required_capacity = queue._count + ice::span::count(items); + ice::u32 const required_capacity = queue._count + items.size().u32(); if (required_capacity > queue._capacity) { ice::queue::grow(queue, required_capacity); } - ice::ucount const span_count = ice::span::count(items); - ice::ucount const start_idx = (queue._offset + queue._count) % queue._capacity; - ice::ucount const end_idx = ice::min(queue._capacity, start_idx + span_count); + ice::u32 const span_count = items.size().u32(); + ice::u32 const start_idx = (queue._offset + queue._count) % queue._capacity; + ice::u32 const end_idx = ice::min(queue._capacity, start_idx + span_count); // The space can we use before wrapping around the buffer. - ice::ucount const head_space = end_idx - start_idx; + ice::u32 const head_space = end_idx - start_idx; // The space after the wrapped buffer we still need to allocate. Can be 0. - ice::ucount const tail_space = span_count - head_space; + ice::u32 const tail_space = span_count - head_space; if constexpr (Logic == ContainerLogic::Complex) { @@ -461,7 +461,7 @@ namespace ice .size = ice::size_of * head_space, .alignment = ice::align_of }, - ice::span::data(items), + items.data(), head_space ); ice::mem_copy_construct_n_at( @@ -470,7 +470,7 @@ namespace ice .size = ice::size_of * tail_space, .alignment = ice::align_of }, - ice::span::data(items) + head_space, + items.data() + head_space, tail_space ); } @@ -483,7 +483,7 @@ namespace ice .alignment = ice::align_of }, Data{ - .location = ice::span::data(items), + .location = items.data(), .size = ice::size_of * head_space, .alignment = ice::align_of } @@ -495,14 +495,14 @@ namespace ice .alignment = ice::align_of }, Data{ - .location = ice::span::data(items) + head_space, + .location = items.data() + head_space, .size = ice::size_of * tail_space, .alignment = ice::align_of } ); } - queue._count += ice::span::count(items); + queue._count += items.size().u32(); } template @@ -569,7 +569,7 @@ namespace ice queue._offset = queue._capacity; } - ice::ucount const item_idx = queue._offset - 1; + ice::u32 const item_idx = queue._offset - 1; if constexpr (Logic == ContainerLogic::Complex) { ice::mem_copy_construct_at( @@ -594,24 +594,24 @@ namespace ice inline void push_front(ice::Queue& queue, ice::Span items) noexcept; template - inline auto take_front(ice::Queue& queue, ice::Span out_values) noexcept -> ice::ucount + inline auto take_front(ice::Queue& queue, ice::Span out_values) noexcept -> ice::u32 { - ice::ucount const taken_items = ice::min(ice::count(out_values), ice::count(queue)); + ice::u32 const taken_items = ice::min(out_values.size().u32(), ice::count(queue)); // (offset, end][0, remaining) - ice::ucount const first_part = ice::min(queue._offset + taken_items, queue._capacity); - ice::ucount const second_part = (queue._offset + taken_items) - first_part; - ice::ucount const first_part_count = first_part - queue._offset; + ice::u32 const first_part = ice::min(queue._offset + taken_items, queue._capacity); + ice::u32 const second_part = (queue._offset + taken_items) - first_part; + ice::u32 const first_part_count = first_part - queue._offset; if constexpr (Logic == ContainerLogic::Complex) { - ice::mem_move_n_to(ice::span::begin(out_values), queue._data + queue._offset, first_part_count); - ice::mem_move_n_to(ice::span::begin(out_values) + first_part_count, queue._data, second_part); + ice::mem_move_n_to(out_values.begin(), queue._data + queue._offset, first_part_count); + ice::mem_move_n_to(out_values.begin() + first_part_count, queue._data, second_part); } else { - ice::memcpy(ice::span::begin(out_values), queue._data + queue._offset, first_part_count * sizeof(Type)); - ice::memcpy(ice::span::begin(out_values) + first_part_count, queue._data, second_part * sizeof(Type)); + ice::memcpy(out_values.begin(), queue._data + queue._offset, first_part_count * sizeof(Type)); + ice::memcpy(out_values.begin() + first_part_count, queue._data, second_part * sizeof(Type)); } ice::queue::pop_front(queue, taken_items); @@ -619,7 +619,7 @@ namespace ice } template - inline void pop_front(ice::Queue& queue, ice::ucount count /*= 1*/) noexcept + inline void pop_front(ice::Queue& queue, ice::u32 count /*= 1*/) noexcept { if constexpr (Logic == ContainerLogic::Complex) { @@ -652,13 +652,13 @@ namespace ice template - inline auto count(ice::Queue const& queue) noexcept -> ice::ucount + inline auto count(ice::Queue const& queue) noexcept -> ice::u32 { return queue._count; } template - inline auto capacity(ice::Queue const& queue) noexcept -> ice::ucount + inline auto capacity(ice::Queue const& queue) noexcept -> ice::u32 { return queue._capacity; } @@ -701,8 +701,8 @@ namespace ice return; } - ice::ucount const first_part = ice::min(queue._offset + queue._count, queue._capacity); - ice::ucount const second_part = (queue._offset + queue._count) - first_part; + ice::u32 const first_part = ice::min(queue._offset + queue._count, queue._capacity); + ice::u32 const second_part = (queue._offset + queue._count) - first_part; for (ice::u32 idx = queue._offset; idx < first_part; ++idx) { @@ -723,8 +723,8 @@ namespace ice return; } - ice::ucount const first_part = ice::min(queue._offset + queue._count, queue._capacity); - ice::ucount const second_part = (queue._offset + queue._count) - first_part; + ice::u32 const first_part = ice::min(queue._offset + queue._count, queue._capacity); + ice::u32 const second_part = (queue._offset + queue._count) - first_part; if (second_part > 0) { diff --git a/source/code/core/collections/public/ice/container/queue.hxx b/source/code/core/collections/public/ice/container/queue.hxx index 7d8c4a1e..3d193a1b 100644 --- a/source/code/core/collections/public/ice/container/queue.hxx +++ b/source/code/core/collections/public/ice/container/queue.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -10,17 +10,17 @@ namespace ice::queue // TODO: Move to details (we don't need this, also makes no sense for this queue) template - inline void set_capacity(ice::Queue& queue, ice::ucount new_capacity) noexcept; + inline void set_capacity(ice::Queue& queue, ice::u32 new_capacity) noexcept; template - inline void reserve(ice::Queue& queue, ice::ucount min_capacity) noexcept; + inline void reserve(ice::Queue& queue, ice::u32 min_capacity) noexcept; template - inline void grow(ice::Queue& queue, ice::ucount min_capacity = 0) noexcept; + inline void grow(ice::Queue& queue, ice::u32 min_capacity = 0) noexcept; // TODO: Move to details (we don't need this, also makes no sense for this queue) template - inline void resize(ice::Queue& queue, ice::ucount new_count) noexcept; + inline void resize(ice::Queue& queue, ice::u32 new_count) noexcept; template inline void shrink(ice::Queue& queue) noexcept; @@ -45,7 +45,7 @@ namespace ice::queue inline void push_back(ice::Queue& queue, ice::Span items) noexcept; template - inline void pop_back(ice::Queue& queue, ice::ucount count = 1) noexcept; + inline void pop_back(ice::Queue& queue, ice::u32 count = 1) noexcept; template requires std::move_constructible @@ -64,7 +64,7 @@ namespace ice::queue inline void push_front(ice::Queue& queue, ice::Span items) noexcept; template - inline void pop_front(ice::Queue& queue, ice::ucount count = 1) noexcept; + inline void pop_front(ice::Queue& queue, ice::u32 count = 1) noexcept; template inline auto front(ice::Queue& queue) noexcept -> Type&; @@ -74,10 +74,10 @@ namespace ice::queue template - inline auto count(ice::Queue const& queue) noexcept -> ice::ucount; + inline auto count(ice::Queue const& queue) noexcept -> ice::u32; template - inline auto capacity(ice::Queue const& queue) noexcept -> ice::ucount; + inline auto capacity(ice::Queue const& queue) noexcept -> ice::u32; template inline auto size_bytes(ice::Queue const& queue) noexcept -> ice::usize; diff --git a/source/code/core/collections/public/ice/container/resizable_container.hxx b/source/code/core/collections/public/ice/container/resizable_container.hxx new file mode 100644 index 00000000..3b4d5c45 --- /dev/null +++ b/source/code/core/collections/public/ice/container/resizable_container.hxx @@ -0,0 +1,36 @@ +#pragma once +#include + +namespace ice::container +{ + + struct ResizableContainer + { + template + constexpr void reserve(this Self& self, ice::ncount min_capacity) noexcept + { + if (self.capacity() < min_capacity) + { + self.set_capacity(min_capacity); + } + } + + template + constexpr void grow(this Self& self, ice::ncount min_capacity = ice::ncount_none) noexcept + { + ice::ncount new_capacity = self.capacity() * 2 + 4; + if (new_capacity < min_capacity) + { + new_capacity = min_capacity; + } + self.set_capacity(new_capacity); + } + + template + constexpr void shrink(this Self& self) noexcept + { + self.set_capacity(self.size()); + } + }; + +} // namespace ice diff --git a/source/code/core/collections/public/ice/container_types.hxx b/source/code/core/collections/public/ice/container_types.hxx index 264245ed..f66c7d39 100644 --- a/source/code/core/collections/public/ice/container_types.hxx +++ b/source/code/core/collections/public/ice/container_types.hxx @@ -1,63 +1,19 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include +#include + #include +#include #include #include +#include namespace ice { - //! \brief A simple contaier storing items in contignous memory. - //! - //! \details Manages a memory block big enough to hold the items that it holds. - //! - //! \tparam Logic The logic used during memory operations for the given type. - //! This value cab be set by the user to enforce expected behavior for stored types. - template> - struct Array - { - static_assert( - Logic == ContainerLogic::Complex || ice::TrivialContainerLogicAllowed, - "Collection element type is not allowed with 'Trivial' logic!" - ); - - using ValueType = Type; - using Iterator = Type*; - using ReverSeIterator = std::reverse_iterator; - using ConstIterator = Type const*; - using ConstReverseIterator = std::reverse_iterator; - - ice::Allocator* _allocator; - ice::ucount _capacity; - ice::ucount _count; - Type* _data; - - inline explicit Array(ice::Allocator& alloc) noexcept; - inline Array(Array&& other) noexcept; - inline Array(Array const& other) noexcept - requires std::copy_constructible; - inline ~Array() noexcept; - - inline Array( - ice::Allocator& alloc, - ice::Span values - ) noexcept requires std::copy_constructible; - - inline auto operator=(Array&& other) noexcept -> Array&; - inline auto operator=(Array const& other) noexcept -> Array& - requires std::copy_constructible; - - inline auto operator[](ice::ucount idx) noexcept -> Type&; - inline auto operator[](ice::ucount idx) const noexcept -> Type const&; - - inline operator ice::Span() noexcept; - inline operator ice::Span() const noexcept; - }; - - //! \brief A double ended queue build on a circular buffer. //! //! \details Manages a memory block big enough to hold the items that it holds. @@ -75,9 +31,9 @@ namespace ice using ValueType = Type; ice::Allocator* _allocator; - ice::ucount _capacity; - ice::ucount _count; - ice::ucount _offset; + ice::u32 _capacity; + ice::u32 _count; + ice::u32 _offset; Type* _data; inline explicit Queue(ice::Allocator& alloc) noexcept; @@ -90,8 +46,8 @@ namespace ice inline auto operator=(Queue const& other) noexcept -> Queue& requires std::copy_constructible; - auto operator[](ice::ucount idx) noexcept -> Type&; - auto operator[](ice::ucount idx) const noexcept -> Type const&; + auto operator[](ice::u32 idx) noexcept -> Type&; + auto operator[](ice::u32 idx) const noexcept -> Type const&; }; @@ -114,7 +70,7 @@ namespace ice struct Entry { ice::u64 key; - ice::ucount next; + ice::u32 next; }; struct ConstIterator @@ -145,10 +101,10 @@ namespace ice }; ice::Allocator* _allocator; - ice::ucount _capacity; - ice::ucount _count; + ice::u32 _capacity; + ice::u32 _count; - ice::ucount* _hashes; + ice::u32* _hashes; Entry* _entries; Type* _data; @@ -174,10 +130,10 @@ namespace ice using Entry = typename ice::HashMap::Entry; using ValueType = Type; - ice::ucount _capacity; - ice::ucount _count; + ice::u32 _capacity; + ice::u32 _count; - ice::ucount const* _hashes; + ice::u32 const* _hashes; Entry const* _entries; Type const* _data; }; @@ -186,9 +142,9 @@ namespace ice template concept HashMapReadAccess = requires(Type t) { { typename Type::Entry() } -> std::convertible_to; - { t._capacity } -> std::convertible_to; - { t._count } -> std::convertible_to; - { t._hashes } -> std::convertible_to; + { t._capacity } -> std::convertible_to; + { t._count } -> std::convertible_to; + { t._hashes } -> std::convertible_to; { t._entries } -> std::convertible_to; { t._data } -> std::convertible_to; }; diff --git a/source/code/core/collections/public/ice/heap_string.hxx b/source/code/core/collections/public/ice/heap_string.hxx new file mode 100644 index 00000000..fcbb37bd --- /dev/null +++ b/source/code/core/collections/public/ice/heap_string.hxx @@ -0,0 +1,250 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include +#include +#include + +namespace ice +{ + + template requires ice::concepts::SupportedCharType + struct HeapString : ice::string::ResizableOperations + { + using CharType = CharT; + using ValueType = CharType; + using Iterator = CharType*; + using ReverseIterator = std::reverse_iterator; + using ConstIterator = CharType const*; + using ConstReverseIterator = std::reverse_iterator; + using SizeType = ice::ncount; + using StringType = ice::BasicString; + + ice::Allocator* _allocator; + ice::u32 _capacity; + ice::u32 _size; + ValueType* _data; + + inline explicit HeapString(ice::Allocator& allocator) noexcept; + inline HeapString(ice::Allocator& allocator, ice::BasicString string) noexcept; + inline ~HeapString() noexcept; + + inline HeapString(HeapString&& other) noexcept; + inline HeapString(HeapString const& other) noexcept; + + inline auto operator=(HeapString&& other) noexcept -> HeapString&; + inline auto operator=(HeapString const& other) noexcept -> HeapString&; + inline auto operator=(ice::BasicString str) noexcept -> HeapString&; + + inline operator ice::BasicString() const noexcept; + + template + inline auto data(this Self& self) noexcept -> ValueType* { return self._data; } + + inline auto size() const noexcept -> SizeType { return SizeType{ _size, sizeof(CharType) }; } + inline void resize(ice::ncount new_size) noexcept; + + inline auto capacity() const noexcept -> SizeType { return SizeType{ _capacity, sizeof(CharType) }; } + inline void set_capacity(ice::ncount new_capacity) noexcept; + + inline auto data_view() const noexcept -> ice::Data; + inline auto extract_memory() noexcept -> ice::Memory; + }; + + template requires ice::concepts::SupportedCharType + inline HeapString::HeapString(ice::Allocator& allocator) noexcept + : _allocator{ &allocator } + , _capacity{ 0 } + , _size{ 0 } + , _data{ nullptr } + { + } + + template requires ice::concepts::SupportedCharType + inline HeapString::HeapString(ice::Allocator& allocator, ice::BasicString value) noexcept + : _allocator{ &allocator } + , _capacity{ 0 } + , _size{ 0 } + , _data{ nullptr } + { + *this = value; + } + + template requires ice::concepts::SupportedCharType + inline HeapString::HeapString(HeapString&& other) noexcept + : _allocator{ other._allocator } + , _size{ ice::exchange(other._size, 0) } + , _capacity{ ice::exchange(other._capacity, 0) } + , _data{ ice::exchange(other._data, nullptr) } + { + } + + template requires ice::concepts::SupportedCharType + inline HeapString::HeapString(HeapString const& other) noexcept + : _allocator{ other._allocator } + , _capacity{ 0 } + , _size{ 0 } + , _data{ nullptr } + { + if (other._size > 0) + { + set_capacity(other.size() + 1); + + // TODO: We need actually very, VERY good tests for string manipulations... + ice::memcpy( + this->end(), + other.cbegin(), + other.size().bytes() + ); + + _size = other._size; + _data[_size] = CharType{ 0 }; + } + } + + template requires ice::concepts::SupportedCharType + inline HeapString::~HeapString() noexcept + { + _allocator->deallocate(this->memory_view()); + } + + template requires ice::concepts::SupportedCharType + inline auto HeapString::operator=(HeapString&& other) noexcept -> HeapString& + { + if (this != ice::addressof(other)) + { + set_capacity(0); + + _allocator = other._allocator; + _size = ice::exchange(other._size, 0); + _capacity = ice::exchange(other._capacity, 0); + _data = ice::exchange(other._data, nullptr); + } + return *this; + } + + template requires ice::concepts::SupportedCharType + inline auto HeapString::operator=(HeapString const& other) noexcept -> HeapString& + { + if (this != ice::addressof(other)) + { + this->clear(); + this->reserve(other.capacity()); + + if (other._size > 0) + { + ice::memcpy( + this->memory_view(), + other.data_view() + ); + } + + _size = other._size; + _data[_size] = CharType{ }; + } + return *this; + } + + template requires ice::concepts::SupportedCharType + inline auto HeapString::operator=(ice::BasicString str) noexcept -> HeapString& + { + auto const* const other_str_begin = str.begin(); + bool const part_of_this = other_str_begin >= this->begin() + && other_str_begin < this->end(); + ICE_ASSERT_CORE(part_of_this == false); + + if (!part_of_this) + { + set_capacity(str.size() + 1); + ice::memcpy( + this->memory_view(), + str.data_view() + ); + + _size = str.size().u32(); + _data[_size] = ValueType{ 0 }; + } + return *this; + } + + template requires ice::concepts::SupportedCharType + inline HeapString::operator ice::BasicString::CharType>() const noexcept + { + return ice::BasicString{ _data, _size }; + } + + template requires ice::concepts::SupportedCharType + inline void HeapString::resize(ice::ncount new_size) noexcept + { + if (new_size > 0 && new_size >= capacity()) + { + set_capacity(new_size + 1); + } + + _size = new_size.u32(); + if (_data != nullptr) + { + _data[_size] = CharType{ 0 }; + } + } + + template requires ice::concepts::SupportedCharType + inline void HeapString::set_capacity(ice::ncount new_capacity) noexcept + { + ice::u32 const new_capacity_u32 = new_capacity.u32(); + if (new_capacity_u32 == _capacity) + { + return; + } + + ValueType* new_data = nullptr; + if (new_capacity_u32 > 0) + { + ice::AllocResult new_buffer = _allocator->allocate(ice::meminfo_of * new_capacity); + + if (_size > 0) + { + ice::memcpy(new_buffer, this->data_view()); + } + + new_data = reinterpret_cast(new_buffer.memory); + } + + _allocator->deallocate(this->memory_view()); + _capacity = new_capacity_u32; + _data = new_data; + + if (new_capacity_u32 <= _size) + { + _size = ice::min(new_capacity_u32, new_capacity_u32 - 1); + } + + if (_data != nullptr) + { + _data[_size] = 0; + } + } + + template requires ice::concepts::SupportedCharType + inline auto HeapString::data_view() const noexcept -> ice::Data + { + return Data{ + .location = _data, + .size = size().bytes(), + .alignment = ice::align_of + }; + } + + template requires ice::concepts::SupportedCharType + inline auto HeapString::extract_memory() noexcept -> ice::Memory + { + _size = 0; // clear the size too + return { + ice::exchange(_data, nullptr), + ice::exchange(_capacity, 0), + ice::align_of + }; + } + +} // namespace ice diff --git a/source/code/core/collections/public/ice/heap_varstring.hxx b/source/code/core/collections/public/ice/heap_varstring.hxx new file mode 100644 index 00000000..b10a069c --- /dev/null +++ b/source/code/core/collections/public/ice/heap_varstring.hxx @@ -0,0 +1,161 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include +#include +#include + +namespace ice +{ + + template + struct HeapVarString : ice::string::ResizableOperations + { + static_assert(sizeof(CharT) == 1, "Wider characters are not supported yet!"); + + using TypeTag = VarStringTag; + using CharType = CharT; + using ValueType = CharType; + using Iterator = CharType*; + using ReverseIterator = std::reverse_iterator; + using ConstIterator = CharType const*; + using ConstReverseIterator = std::reverse_iterator; + using SizeType = ice::ncount; + using StringType = ice::BasicString; + + ice::Allocator* _allocator; + ValueType* _data; + + inline explicit HeapVarString(ice::Allocator& alloc) noexcept; + inline HeapVarString(ice::Allocator& allocator, ice::BasicString string) noexcept; + inline ~HeapVarString() noexcept; + + inline HeapVarString(HeapVarString&& other) noexcept; + inline HeapVarString(HeapVarString const& other) noexcept; + + constexpr auto data() const noexcept -> ValueType*; + constexpr auto size() const noexcept -> SizeType; + + inline auto data_view() const noexcept -> ice::Data; + + inline operator ice::BasicString() const noexcept; + inline operator ice::VarStringBase() const noexcept; + }; + + namespace varstring + { + + inline auto allocate_exact(ice::Allocator& alloc, ice::ncount size, ice::usize& out_bytes) noexcept -> char* + { + if (size == 0_B) + { + return nullptr; + } + + // Allocate enough for: bytes + size + '\0' + ice::usize const final_size = calc_required_size(size) + 1_B; + ice::Memory const result = alloc.allocate(final_size); + out_bytes = write_size(result.location, size); + return reinterpret_cast(result.location); + } + + inline auto create(ice::Allocator& alloc, ice::String str) noexcept -> char* + { + ice::ncount const str_size = str.size(); + + ice::usize bytes = 0_B; + char* const data = allocate_exact(alloc, str_size, bytes); + if (data != nullptr) + { + ice::memcpy(data + bytes.value, str.begin(), str_size.bytes()); + data[bytes.value + str_size.native()] = '\0'; + } + return data; + } + + } // namespace string::detail + + template + inline HeapVarString::HeapVarString(ice::Allocator& alloc) noexcept + : _allocator{ ice::addressof(alloc) } + , _data{ nullptr } + { + } + + template + inline HeapVarString::HeapVarString(ice::Allocator& alloc, ice::BasicString string) noexcept + : _allocator{ ice::addressof(alloc) } + , _data{ ice::varstring::create(alloc, string) } + { + } + + template + inline HeapVarString::HeapVarString(ice::HeapVarString&& other) noexcept + : _allocator{ other._allocator } + , _data{ ice::exchange(other._data, nullptr) } + { + } + + template + inline HeapVarString::HeapVarString(ice::HeapVarString const& other) noexcept + : HeapVarString{ other._allocator, ice::String{ other } } + { + } + + template + inline HeapVarString::~HeapVarString() noexcept + { + if (_data != nullptr) + { + _allocator->deallocate(_data); + } + } + + template + inline constexpr auto HeapVarString::data() const noexcept -> ValueType* + { + return ice::varstring::read_data(_data); + } + + template + inline constexpr auto HeapVarString::size() const noexcept -> SizeType + { + return ice::varstring::read_size(_data); + } + + template + inline auto HeapVarString::data_view() const noexcept -> ice::Data + { + ice::usize bytes = 0_B; + ice::ncount const size = ice::varstring::read_size(_data, bytes); + + return { + .location = _data, + .size = { size.bytes() + bytes}, + .alignment = ice::ualign::b_1 + }; + } + + template + inline HeapVarString::operator ice::BasicString::CharType>() const noexcept + { + ice::usize bytes = 0; + ice::ncount const size = ice::varstring::read_size(_data, bytes); + if (size > 0) + { + return { _data + bytes.value, size }; + } + else + { + return {}; + } + } + + template + inline HeapVarString::operator ice::VarStringBase::CharType>() const noexcept + { + return _data; + } + +} // namespace ice diff --git a/source/code/core/collections/public/ice/shard_container.hxx b/source/code/core/collections/public/ice/shard_container.hxx index 59e8c743..0896102f 100644 --- a/source/code/core/collections/public/ice/shard_container.hxx +++ b/source/code/core/collections/public/ice/shard_container.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include namespace ice { @@ -21,7 +21,7 @@ namespace ice inline auto operator=(ice::ShardContainer&& other) noexcept -> ice::ShardContainer&; inline auto operator=(ice::ShardContainer const& other) noexcept -> ice::ShardContainer&; - inline operator ice::Span() const noexcept { return ice::array::slice(_data); } + inline operator ice::Span() const noexcept { return _data; } ice::Array _data; }; @@ -129,33 +129,33 @@ namespace ice inline void reserve(ice::ShardContainer& container, ice::u32 new_capacity) noexcept { - ice::array::reserve(container._data, new_capacity); + container._data.reserve(new_capacity); } inline void resize(ice::ShardContainer& container, ice::u32 new_size) noexcept { - ice::array::resize(container._data, new_size); + container._data.resize(new_size); } inline void clear(ice::ShardContainer& container) noexcept { - ice::array::clear(container._data); + container._data.clear(); } inline void push_back(ice::ShardContainer& container, ice::Shard value) noexcept { - ice::array::push_back(container._data, value); + container._data.push_back(value); } inline void push_back(ice::ShardContainer& container, ice::Span values) noexcept { - ice::array::push_back(container._data, values); + container._data.push_back(values); } inline void remove_all_of(ice::ShardContainer& container, ice::ShardID value) noexcept { ice::Array& data = container._data; - ice::u32 count = ice::array::count(data); + ice::ncount count = data.size(); for (ice::u32 idx = 0; idx < count; ++idx) { @@ -166,33 +166,33 @@ namespace ice } } - ice::array::resize(data, count); + data.resize(count); } inline auto begin(ice::ShardContainer& container) noexcept -> ice::ShardContainer::Iterator { - return ice::array::begin(container._data); + return container._data.begin(); } inline auto end(ice::ShardContainer& container) noexcept -> ice::ShardContainer::Iterator { - return ice::array::end(container._data); + return container._data.end(); } inline auto empty(ice::ShardContainer const& container) noexcept -> bool { - return ice::array::empty(container._data); + return container._data.is_empty(); } inline auto size(ice::ShardContainer const& container) noexcept -> ice::u32 { - return ice::array::count(container._data); + return container._data.size().u32(); } inline auto capacity(ice::ShardContainer const& container) noexcept -> ice::u32 { - return ice::array::capacity(container._data); + return container._data.capacity().u32(); } inline auto count(ice::ShardContainer const& container, ice::ShardID expected_shard) noexcept -> ice::u32 @@ -212,8 +212,8 @@ namespace ice inline auto find_first_of(ice::ShardContainer const& container, ice::ShardID shard, ice::u32 offset) noexcept -> ice::Shard { - auto it = ice::array::begin(container._data); - auto const end = ice::array::end(container._data); + auto it = container._data.begin(); + auto const end = container._data.end(); if (offset != ~0) { @@ -238,8 +238,8 @@ namespace ice inline auto find_last_of(ice::ShardContainer const& container, ice::ShardID shard, ice::u32 offset) noexcept -> ice::Shard { - auto it = ice::array::rbegin(container._data); - auto const end = ice::array::rend(container._data); + auto it = container._data.rbegin(); + auto const end = container._data.rend(); if (offset != ~0) { @@ -299,7 +299,7 @@ namespace ice { if (shard == shard_type && ice::shard_inspect(shard, payload)) { - ice::array::push_back(payloads, payload); + payloads.push_back(payload); count += 1; } } @@ -331,8 +331,8 @@ namespace ice template inline bool inspect_first(ice::ShardContainer const& container, ice::ShardID shard_type, T(&payload)[Size]) noexcept { - auto it = ice::array::begin(container._data); - auto const end = ice::array::end(container._data); + auto it = container._data.begin(); + auto const end = container._data.end(); ice::u32 idx = 0; while (it != end && idx < Size) @@ -361,12 +361,12 @@ namespace ice inline auto begin(ice::ShardContainer const& container) noexcept -> ice::ShardContainer::ConstIterator { - return ice::array::begin(container._data); + return container._data.begin(); } inline auto end(ice::ShardContainer const& container) noexcept -> ice::ShardContainer::ConstIterator { - return ice::array::end(container._data); + return container._data.end(); } } diff --git a/source/code/core/collections/public/ice/sort.hxx b/source/code/core/collections/public/ice/sort.hxx index 1d904480..e3b42da0 100644 --- a/source/code/core/collections/public/ice/sort.hxx +++ b/source/code/core/collections/public/ice/sort.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -10,9 +10,9 @@ namespace ice { template - inline auto accumulate_over(ice::Span objects, Fn&& fn) noexcept -> ice::ucount + inline auto accumulate_over(ice::Span objects, Fn&& fn) noexcept -> ice::u32 { - ice::ucount result = 0; + ice::u32 result = 0; for (Type const& object : objects) { result += ice::forward(fn)(object); @@ -21,28 +21,28 @@ namespace ice } template requires (std::convertible_to) - constexpr auto lower_bound(ice::Span values, U const& value) noexcept -> ice::ucount; + constexpr auto lower_bound(ice::Span values, U const& value) noexcept -> ice::u32; template requires (std::convertible_to) - constexpr auto lower_bound(ice::Span values, U const& value, Comp&& comp) noexcept -> ice::ucount; + constexpr auto lower_bound(ice::Span values, U const& value, Comp&& comp) noexcept -> ice::u32; template requires (std::convertible_to) - constexpr auto upper_bound(ice::Span values, U const& value) noexcept -> ice::ucount; + constexpr auto upper_bound(ice::Span values, U const& value) noexcept -> ice::u32; template requires (std::convertible_to) - constexpr auto upper_bound(ice::Span values, U const& value, Comp&& comp) noexcept -> ice::ucount; + constexpr auto upper_bound(ice::Span values, U const& value, Comp&& comp) noexcept -> ice::u32; template requires (std::convertible_to) - constexpr bool binary_search(ice::Span values, U const& value, ice::ucount& out_index) noexcept; + constexpr bool binary_search(ice::Span values, U const& value, ice::u32& out_index) noexcept; template requires (std::convertible_to) - constexpr bool binary_search(ice::Span values, U const& value, Comp&& comp, ice::ucount& out_index) noexcept; + constexpr bool binary_search(ice::Span values, U const& value, Comp&& comp, ice::u32& out_index) noexcept; template requires (std::convertible_to) - constexpr bool search(ice::Span values, U const& value, ice::ucount& out_index) noexcept; + constexpr bool search(ice::Span values, U const& value, ice::u32& out_index) noexcept; template - constexpr bool search(ice::Span values, U const& value, Comp&& comp, ice::ucount& out_index) noexcept; + constexpr bool search(ice::Span values, U const& value, Comp&& comp, ice::u32& out_index) noexcept; template inline void sort(ice::Span span) noexcept; @@ -65,57 +65,57 @@ namespace ice template requires (std::convertible_to) - constexpr auto lower_bound(ice::Span values, U const& value) noexcept -> ice::ucount + constexpr auto lower_bound(ice::Span values, U const& value) noexcept -> ice::u32 { - return static_cast(std::lower_bound(ice::span::begin(values), ice::span::end(values), value) - ice::span::begin(values)); + return static_cast(std::lower_bound(values.begin(), values.end(), value) - values.begin()); } template requires (std::convertible_to) - constexpr auto lower_bound(ice::Span values, U const& value, Comp&& comp) noexcept -> ice::ucount + constexpr auto lower_bound(ice::Span values, U const& value, Comp&& comp) noexcept -> ice::u32 { - return static_cast(std::lower_bound(ice::span::begin(values), ice::span::end(values), value, ice::forward(comp)) - ice::span::begin(values)); + return static_cast(std::lower_bound(values.begin(), values.end(), value, ice::forward(comp)) - values.begin()); } template requires (std::convertible_to) - constexpr auto upper_bound(ice::Span values, U const& value) noexcept -> ice::ucount + constexpr auto upper_bound(ice::Span values, U const& value) noexcept -> ice::u32 { - return static_cast(std::upper_bound(ice::span::begin(values), ice::span::end(values), value) - ice::span::begin(values)); + return static_cast(std::upper_bound(values.begin(), values.end(), value) - values.begin()); } template requires (std::convertible_to) - constexpr auto upper_bound(ice::Span values, U const& value, Comp&& comp) noexcept -> ice::ucount + constexpr auto upper_bound(ice::Span values, U const& value, Comp&& comp) noexcept -> ice::u32 { - return static_cast(std::upper_bound(ice::span::begin(values), ice::span::end(values), value, ice::forward(comp)) - ice::span::begin(values)); + return static_cast(std::upper_bound(values.begin(), values.end(), value, ice::forward(comp)) - values.begin()); } template requires (std::convertible_to) - constexpr bool binary_search(ice::Span values, U const& predicate, ice::ucount& out_index) noexcept + constexpr bool binary_search(ice::Span values, U const& predicate, ice::u32& out_index) noexcept { out_index = ice::lower_bound(values, predicate); - return (ice::count(values) != out_index) && (values[out_index] == predicate); + return (values.size() != out_index) && (values[out_index] == predicate); } template requires (std::convertible_to) - constexpr bool binary_search(ice::Span values, U const& predicate, Comp&& comp, ice::ucount& out_index) noexcept + constexpr bool binary_search(ice::Span values, U const& predicate, Comp&& comp, ice::u32& out_index) noexcept { out_index = ice::lower_bound(values, predicate, ice::forward(comp)); - return (ice::count(values) != out_index) && (values[out_index] == predicate); + return (values.size() != out_index) && (values[out_index] == predicate); } template requires (std::convertible_to) - constexpr bool search(ice::Span values, U const& value, ice::ucount& out_index) noexcept + constexpr bool search(ice::Span values, U const& value, ice::u32& out_index) noexcept { return search(values, value, [](auto const& l, auto const& r) noexcept { return l == r; }, out_index); } template - constexpr bool search(ice::Span values, U const& value, Comp&& comp, ice::ucount& out_index) noexcept + constexpr bool search(ice::Span values, U const& value, Comp&& comp, ice::u32& out_index) noexcept { - for (ice::u32 idx = 0; idx < ice::span::count(values); ++idx) + for (ice::nindex idx = 0; idx < values.size(); ++idx) { if (ice::forward(comp)(values[idx], value)) { - out_index = idx; + out_index = idx.u32(); return true; } } @@ -123,9 +123,9 @@ namespace ice } template - constexpr bool search_with(ice::Span values, Comp&& comp, ice::ucount& out_index, U const&... params) noexcept + constexpr bool search_with(ice::Span values, Comp&& comp, ice::u32& out_index, U const&... params) noexcept { - for (ice::u32 idx = 0; idx < ice::span::count(values); ++idx) + for (ice::u32 idx = 0; idx < values.size(); ++idx) { if (ice::forward(comp)(values[idx], idx, params...)) { @@ -274,7 +274,7 @@ namespace ice template inline void sort(ice::Span span, Pred&& pred) noexcept { - std::sort(ice::span::begin(span), ice::span::end(span), ice::forward(pred)); + std::sort(span.begin(), span.end(), ice::forward(pred)); } template @@ -300,7 +300,7 @@ namespace ice inline void sort_indices(ice::Span keys, ice::Span indices, Pred&& pred) noexcept { ice::i32 const first_index = 0; - ice::i32 const last_index = ice::count(keys) - 1; + ice::i32 const last_index = keys.size().u32() - 1; ice::detail::qsort_indices(keys, indices, std::forward(pred), first_index, last_index); } diff --git a/source/code/core/collections/public/ice/span.hxx b/source/code/core/collections/public/ice/span.hxx index 938454ce..5f4549a4 100644 --- a/source/code/core/collections/public/ice/span.hxx +++ b/source/code/core/collections/public/ice/span.hxx @@ -1,375 +1,151 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once -#include #include #include #include -#include // TODO: Introduce our own static array object. +#include +#include namespace ice { //! \brief A view into an array of objects laid out in contiguous memory. template - struct Span + struct Span : public ice::container::ContiguousContainer { using ValueType = Type; + using ConstContainerValueType = Type; using Iterator = Type*; using ReverseIterator = std::reverse_iterator; using ConstIterator = Type const*; using ConstReverseIterator = std::reverse_iterator; + using SizeType = ice::ncount; + using ContainerTag = ice::concepts::ContiguousContainerTag; - ice::ucount _count; - Type* _data; + SizeType::base_type _count; + ValueType* _data; constexpr Span() noexcept; constexpr Span(ice::Span&& other) noexcept = default; constexpr Span(ice::Span const& other) noexcept = default; - constexpr Span(Type* location, ice::ucount count) noexcept; + constexpr Span(Type* location, ice::ncount count) noexcept; constexpr Span(Type* from, Type* to) noexcept; - template + template constexpr Span(Type(&location)[Size]) noexcept; constexpr auto operator=(ice::Span&& other) noexcept -> ice::Span& = default; constexpr auto operator=(ice::Span const& other) noexcept -> ice::Span& = default; - constexpr auto operator[](ice::ucount idx) const noexcept -> Type&; + // API Requirements Of: Contiguous Container + template + constexpr auto data(this Self& self) noexcept -> ice::container::ValuePtr { return self._data; } + constexpr auto size(this Span const& self) noexcept -> ice::ncount { return { self._count, sizeof(ValueType) }; } + + // API Requirements Of: Data and Memory + constexpr auto data_view(this Span const& self) noexcept -> ice::Data; + constexpr auto memory_view(this Span const& self) noexcept -> ice::Memory + requires(not std::is_const_v); + + // Implicit type conversions constexpr operator ice::Span() noexcept { return { _data, _count }; } constexpr operator ice::Span() const noexcept { return { _data, _count }; } }; - template Span(T(&)[Size]) noexcept -> Span; template Span(ice::Span&&) noexcept -> Span; template Span(ice::Span const&) noexcept -> Span; template typename Container> Span(Container const&) noexcept -> Span; + template Span(T(&)[Size]) noexcept -> Span; - namespace span - { - - template - constexpr bool empty(ice::Span span) noexcept; - - template - constexpr bool any(ice::Span span) noexcept; - - template - constexpr auto data(ice::Span span) noexcept -> Type*; - - template - constexpr auto data_view(ice::Span span) noexcept -> ice::Data; - - template - constexpr auto count(ice::Span span) noexcept -> ice::ucount; - - template - constexpr auto size_bytes(ice::Span span) noexcept -> ice::usize; - - template - constexpr auto alignment(ice::Span span) noexcept -> ice::ualign; - - template - constexpr auto front(ice::Span span) noexcept -> Type&; - - template - constexpr auto back(ice::Span span) noexcept -> Type&; - - template - constexpr auto head(ice::Span span, ice::ucount count) noexcept -> ice::Span; - - template - constexpr auto tail(ice::Span span, ice::ucount from_idx) noexcept -> ice::Span; - - template - constexpr auto subspan(ice::Span span, ice::ucount from_idx, ice::ucount count = ice::ucount_max) noexcept -> ice::Span; - - template - constexpr auto subspan(ice::Span span, ice::ref32 ref) noexcept -> ice::Span; - - template - constexpr auto begin(ice::Span span) noexcept -> typename ice::Span::Iterator; - - template - constexpr auto end(ice::Span span) noexcept -> typename ice::Span::Iterator; - - template - constexpr auto rbegin(ice::Span span) noexcept -> typename ice::Span::ReverseIterator; - - template - constexpr auto rend(ice::Span span) noexcept -> typename ice::Span::ReverseIterator; - - template - constexpr auto begin(ice::Span span) noexcept -> typename ice::Span::ConstIterator; - - template - constexpr auto end(ice::Span span) noexcept -> typename ice::Span::ConstIterator; - - template - constexpr auto rbegin(ice::Span span) noexcept -> typename ice::Span::ConstReverseIterator; - - template - constexpr auto rend(ice::Span span) noexcept -> typename ice::Span::ConstReverseIterator; - - - template - constexpr auto from_std(std::array const& std_array) noexcept -> ice::Span; - - template - constexpr auto memory(ice::Span span) noexcept -> ice::Memory; - - } // namespace span - - namespace data - { - - template - requires (std::is_trivially_copyable_v && !std::is_pointer_v) - inline auto read_span(ice::Data source, ice::ucount count, ice::Span& out_value) noexcept -> ice::Data - { - ICE_ASSERT_CORE(source.alignment >= ice::align_of); - out_value._count = count; - out_value._data = reinterpret_cast(source.location); - - ice::usize const consumed_size = ice::size_of *count; - source.location = ice::span::data(out_value) + count; - source.size = ice::usize::subtract(source.size, consumed_size); - source.alignment = ice::align_of; - return source; - } - - } // namespace data + template + static constexpr auto make_span(std::array& std_array) noexcept -> Span; + template + static constexpr auto make_span(std::array const& std_array) noexcept -> Span; template constexpr Span::Span() noexcept : _count{ 0 } , _data{ nullptr } - { - } + { } template - constexpr Span::Span(Type* location, ice::ucount count) noexcept - : _count{ count } + constexpr Span::Span(Type* location, ice::ncount count) noexcept + : _count{ count.native() } , _data{ location } - { - } + { } template constexpr Span::Span(Type* from, Type* to) noexcept - : _count{ static_cast(to - from) } + : _count{ static_cast(to - from) } , _data{ from } - { - } + { } template - template + template constexpr Span::Span(Type(&location)[Size]) noexcept : _count{ Size } , _data{ location } + { } + + template + inline constexpr auto Span::data_view(this Span const& self) noexcept -> ice::Data { + return ice::Data{ + .location = self.data(), + .size = self.size(), + .alignment = ice::align_of + }; } template - constexpr auto Span::operator[](ice::ucount idx) const noexcept -> Type& + inline constexpr auto Span::memory_view(this Span const& self) noexcept -> ice::Memory + requires(not std::is_const_v) { - // TODO: ASSERT - return _data[idx]; + return ice::Data{ + .location = self.data(), + .size = self.size(), + .alignment = ice::align_of + }; } - namespace span + template + inline constexpr auto make_span(std::array& std_array) noexcept -> Span { + return Span{ std_array.data(), std_array.size() }; + } - template - constexpr bool empty(ice::Span span) noexcept - { - return span._count == 0; - } - - template - constexpr bool any(ice::Span span) noexcept - { - return span._count != 0; - } - - template - constexpr auto data(ice::Span span) noexcept -> Type* - { - return span._data; - } - - template - constexpr auto data_view(ice::Span span) noexcept -> ice::Data - { - return Data{ - .location = ice::span::data(span), - .size = ice::span::size_bytes(span), - .alignment = ice::span::alignment(span) - }; - } - - template - constexpr auto count(ice::Span span) noexcept -> ice::ucount - { - return span._count; - } - - template - constexpr auto size_bytes(ice::Span span) noexcept -> ice::usize - { - return ice::size_of * ice::span::count(span); - } - - template - constexpr auto alignment(ice::Span span) noexcept -> ice::ualign - { - return ice::align_of; - } - - template - constexpr auto front(ice::Span span) noexcept -> Type& - { - return span._data[0]; - } - - template - constexpr auto back(ice::Span span) noexcept -> Type& - { - return span._data[0]; - } - - template - constexpr auto head(ice::Span span, ice::ucount count) noexcept -> ice::Span - { - ice::ucount const new_count = ice::min(count, span._count); - return { span._data, new_count }; - } - - template - constexpr auto tail(ice::Span span, ice::ucount from_idx) noexcept -> ice::Span - { - ice::ucount const from_start = ice::min(from_idx, span._count); - return { span._data + from_start, span._count - from_start }; - } - - template - constexpr auto subspan(ice::Span span, ice::ucount from_idx, ice::ucount count) noexcept -> ice::Span - { - ice::ucount const from_start = ice::min(from_idx, span._count); - ice::ucount const new_count = ice::min(span._count - from_start, count); - return { span._data + from_start, new_count }; - } - - template - constexpr auto subspan(ice::Span span, ice::ref32 ref) noexcept -> ice::Span - { - return ice::span::subspan(span, ref.offset, ref.size); - } - - template - constexpr auto begin(ice::Span span) noexcept -> typename ice::Span::Iterator - { - return span._data; - } - - template - constexpr auto end(ice::Span span) noexcept -> typename ice::Span::Iterator - { - return span._data + span._count; - } - - template - constexpr auto rbegin(ice::Span span) noexcept -> typename ice::Span::ReverseIterator - { - return typename ice::Span::ReverseIterator{ span._data + span._count }; - } - - template - constexpr auto rend(ice::Span span) noexcept -> typename ice::Span::ReverseIterator - { - return typename ice::Span::ReverseIterator{ span._data }; - } - - template - constexpr auto begin(ice::Span span) noexcept -> typename ice::Span::ConstIterator - { - return span._data; - } - - template - constexpr auto end(ice::Span span) noexcept -> typename ice::Span::ConstIterator - { - return span._data + span._count; - } - - template - constexpr auto rbegin(ice::Span span) noexcept -> typename ice::Span::ConstReverseIterator - { - return typename ice::Span::ConstReverseIterator{ span._data + span._count }; - } - - template - constexpr auto rend(ice::Span span) noexcept -> typename ice::Span::ConstReverseIterator - { - return typename ice::Span::ConstReverseIterator{ span._data }; - } - - - template - constexpr auto from_std(std::array& std_array) noexcept -> ice::Span - { - return ice::Span{ std_array.data(), ice::ucount(std_array.size()) }; - } - - template - constexpr auto from_std_const(std::array const& std_array) noexcept -> ice::Span - { - return ice::Span{ std_array.data(), ice::ucount(std_array.size()) }; - } - - // TODO: Move to another location or rename? Not sure this is properly named - template - constexpr auto memory(ice::Span span) noexcept -> ice::Memory - { - return ice::Memory{ - .location = ice::span::begin(span), - .size = ice::span::size_bytes(span), - .alignment = ice::span::alignment(span) - }; - } + template + inline constexpr auto make_span(std::array const& std_array) noexcept -> Span + { + return Span{ std_array.data(), std_array.size() }; + } - template - constexpr auto from_memory(ice::Memory const& mem, ice::ucount count, ice::usize offset) noexcept -> ice::Span - { - static ice::meminfo minfo = ice::meminfo_of; + static_assert(ice::TrivialContainerLogicAllowed>); - void* const ptr = ice::ptr_add(mem.location, offset); - ICE_ASSERT_CORE(ice::is_aligned(ptr, minfo.alignment)); - ICE_ASSERT_CORE(ice::ptr_add(mem.location, mem.size) >= ice::ptr_add(ptr, minfo.size * count)); - return ice::Span{ reinterpret_cast(ptr), count }; - } + // TODO: Move to a data reader type + namespace data + { - // TODO: Move to another location or rename? Not sure this is properly named - template - constexpr auto from_data(ice::Data const& mem, ice::ucount count, ice::usize offset) noexcept -> ice::Span + template + requires (std::is_trivially_copyable_v && !std::is_pointer_v) + inline auto read_span( + ice::Data source, + ice::ncount count, + ice::Span& out_value + ) noexcept -> ice::Data { - static ice::meminfo constexpr minfo = ice::meminfo_of; + ICE_ASSERT_CORE(source.alignment >= ice::align_of); + out_value._count = count; + out_value._data = reinterpret_cast(source.location); - void const* const ptr = ice::ptr_add(mem.location, offset); - ICE_ASSERT_CORE(ice::is_aligned(ptr, minfo.alignment)); - ICE_ASSERT_CORE(ice::ptr_add(mem.location, mem.size) >= ice::ptr_add(ptr, minfo.size * count)); - return { reinterpret_cast(ptr), count }; + source.location = out_value.data() + count; + source.size = ice::usize::subtract(source.size, out_value.size()); + source.alignment = ice::align_of; + return source; } - } // namespace span - - using ice::span::count; - using ice::span::data_view; - - using ice::span::begin; - using ice::span::end; - - - static_assert(ice::TrivialContainerLogicAllowed>); + } // namespace data } // namespace ice diff --git a/source/code/core/collections/public/ice/static_string.hxx b/source/code/core/collections/public/ice/static_string.hxx new file mode 100644 index 00000000..e82e746d --- /dev/null +++ b/source/code/core/collections/public/ice/static_string.hxx @@ -0,0 +1,187 @@ +/// Copyright 2022 - 2026, Dandielo +/// SPDX-License-Identifier: MIT +#pragma once +#include +#include +#include + +namespace ice +{ + + template requires ice::concepts::SupportedCharType + struct StaticString : ice::string::MutableOperations + { + using CharType = CharT; + using ValueType = CharType; + using Iterator = CharType*; + using ReverseIterator = std::reverse_iterator; + using ConstIterator = CharType const*; + using ConstReverseIterator = std::reverse_iterator; + using SizeType = ice::ncount; + using StringType = ice::BasicString; + + SizeType::base_type _size; + ValueType _data[Capacity]; + + constexpr StaticString() noexcept; + template + constexpr StaticString(CharType const(&str_array)[Size]) noexcept; + constexpr StaticString(BasicString string) noexcept; + + constexpr auto operator=(StaticString const& other) noexcept -> StaticString&; + constexpr auto operator=(BasicString str) noexcept -> StaticString&; + + constexpr operator ice::BasicString() const noexcept; + + // ReadOnly+ Operations + template + constexpr auto data(this Self& self) noexcept { return self._data; } + constexpr auto size() const noexcept -> SizeType { return SizeType{ _size, sizeof(CharType) }; } + + // Mutable operations + constexpr void resize(ice::ncount new_size) noexcept; + constexpr auto capacity() const noexcept -> SizeType { return SizeType{ Capacity, sizeof(CharType) }; } + + // Data info + constexpr auto data_view() const noexcept -> ice::Data; + }; + + template requires ice::concepts::SupportedCharType + constexpr StaticString::StaticString() noexcept + : _size{ 0 } + , _data{ } + { + } + + template requires ice::concepts::SupportedCharType + template + constexpr StaticString::StaticString(CharType const(&str_array)[Size]) noexcept + : StaticString{ ice::BasicString{ str_array, Size } } + { + } + + template requires ice::concepts::SupportedCharType + constexpr StaticString::StaticString(ice::BasicString str) noexcept + : _size{ ice::min(Capacity - 1, str.size().u32()) } + , _data{ } + { + if (std::is_constant_evaluated()) + { + for (ice::u32 idx = 0; idx < _size; ++idx) + { + _data[idx] = str[idx]; + } + } + else if (str.not_empty()) + { + ice::memcpy(this->memory_view(), str.data_view()); + } + _data[_size] = ValueType{ 0 }; + } + + //template requires ice::concepts::SupportedCharType + //template + //constexpr StaticString::StaticString(StaticString const& other) noexcept + // : _size{ ice::min(Capacity - 1, ice::string::size(other)) } + // , _data{ } + //{ + // if (std::is_constant_evaluated()) + // { + // for (ice::ucount idx = 0; idx < _size; ++idx) + // { + // _data[idx] = other[idx]; + // } + // } + // else + // { + // ice::memcpy(ice::string::memory(*this), ice::string::data_view(other)); + // } + // _data[_size] = ValueType{ 0 }; + //} + + //template requires ice::concepts::SupportedCharType + //template + //constexpr auto StaticString::operator=(StaticString const& other) noexcept -> StaticString& + //{ + // if (this != &other) + // { + // ice::string::clear(*this); + + // if (other._size > 0) + // { + // ice::memcpy( + // ice::string::memory(*this), + // ice::string::data_view(other) + // ); + // } + + // _size = ice::min(Capacity - 1, other._size); + // _data[_size] = CharType{ }; + // } + // return *this; + //} + + template requires ice::concepts::SupportedCharType + constexpr auto StaticString::operator=(ice::BasicString other) noexcept -> StaticString& + { + CharType const* const other_str_begin = other.begin(); + bool const part_of_this = other_str_begin >= this->begin() + && other_str_begin < this->end(); + + if (!part_of_this) + { + this->clear(); + ice::memcpy(this->memory_view(), other.data_view()); + this->resize(ice::min(Capacity - 1, other.size())); + } + return *this; + } + + template requires ice::concepts::SupportedCharType + constexpr StaticString::operator ice::BasicString::CharType>() const noexcept + { + return ice::BasicString{ _data, _size }; + } + + template requires ice::concepts::SupportedCharType + constexpr void StaticString::resize(ice::ncount new_size) noexcept + { + _size = ice::min(Capacity - 1, new_size.u32()); + _data[_size] = CharType{ 0 }; + } + + //template + //constexpr bool operator==(ice::StaticString const& left, CharType const* right) noexcept + //{ + // return ice::BasicString{ left } == ice::BasicString{ right }; + //} + + //template + //constexpr bool operator==(ice::StaticString const& left, ice::BasicString right) noexcept + //{ + // return ice::BasicString{ left } == right; + //} + + //template + //constexpr bool operator==(ice::BasicString left, ice::StaticString const& right) noexcept + //{ + // return left == ice::BasicString{ right }; + //} + + template requires ice::concepts::SupportedCharType + constexpr auto StaticString::data_view() const noexcept -> ice::Data + { + return Data{ + .location = _data, + .size = size().bytes(), + .alignment = ice::align_of + }; + } + + template + constexpr auto stringid(ice::StaticString value) noexcept -> ice::StringID + { + return ice::stringid(value._data, value._size); + } + +} // namespace ice diff --git a/source/code/core/collections/public/ice/string.hxx b/source/code/core/collections/public/ice/string.hxx new file mode 100644 index 00000000..04b77832 --- /dev/null +++ b/source/code/core/collections/public/ice/string.hxx @@ -0,0 +1,120 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include +#include +#include + +namespace ice +{ + + template requires ice::concepts::SupportedCharType + struct BasicString : ice::string::ReadOnlyOperations + { + using CharType = CharT; + using ValueType = CharType const; + using ConstIterator = ValueType*; + using ConstReverseIterator = std::reverse_iterator; + using Iterator = ConstIterator; + using ReverseIterator = ConstReverseIterator; + using SizeType = ice::ncount; + using StringType = ice::BasicString; + + ValueType* _data = nullptr; + SizeType::base_type _count = 0; + + constexpr BasicString() noexcept = default; + + constexpr BasicString(BasicString&& other) noexcept = default; + constexpr BasicString(BasicString const& other) noexcept = default; + + constexpr auto operator=(BasicString&& other) noexcept -> BasicString& = default; + constexpr auto operator=(BasicString const& other) noexcept -> BasicString& = default; + + constexpr BasicString(ValueType* ptr_array_nt) noexcept + : _data{ ptr_array_nt } + , _count{ ice::string::detail::strptr_size(ptr_array_nt) } + { } + + constexpr BasicString(ValueType* ptr_array, ice::ncount count) noexcept + : _data{ ptr_array } + , _count{ count.native() } + { } + + constexpr BasicString(ValueType* ptr_array_begin, ValueType* ptr_array_end) noexcept + : _data{ ptr_array_begin } + , _count{ static_cast(ptr_array_end - ptr_array_begin) } + { } + + template + constexpr BasicString(ValueType(&char_array)[Size]) noexcept + : _data{ char_array } + , _count{ Size } + { } + + constexpr BasicString(std::basic_string_view string_view) noexcept + : _data{ string_view.data() } + , _count{ string_view.size() } + { } + + constexpr auto data() const noexcept -> ValueType* { return _data; } + constexpr auto size() const noexcept -> SizeType { return SizeType{ _count, sizeof(CharType) }; } + + constexpr auto data_view() const noexcept -> ice::Data; + + constexpr operator std::basic_string_view() const noexcept { return { _data, _count }; } + }; + + static_assert(ice::concepts::StringType>); + + + constexpr auto operator""_str(char const* buffer, size_t size) noexcept -> ice::BasicString + { + return ice::BasicString{ buffer, size }; + } + + template requires ice::concepts::SupportedCharType + constexpr auto BasicString::data_view() const noexcept -> ice::Data + { + return Data{ + .location = _data, + .size = size().bytes(), + .alignment = ice::align_of + }; + } + + using String = ice::BasicString; + using WString = ice::BasicString; + + template requires ice::concepts::RODataObject + constexpr auto string_from_data(T ro_data, ice::nindex offset, ice::ncount size) noexcept -> ice::BasicString + { + return ice::String{ + reinterpret_cast(ro_data.location) + offset, + ice::min(ro_data.size.value, size) + }; + } + + template requires ice::concepts::RODataObject + constexpr auto string_from_data(T ro_data) noexcept -> ice::BasicString + { + return ice::string_from_data(ro_data, 0, ro_data.size.value); + } + + constexpr auto hash(ice::String value) noexcept -> ice::u64 + { + return ice::hash(std::string_view{ value }); + } + + constexpr auto hash32(ice::String value) noexcept -> ice::u32 + { + return ice::hash32(std::string_view{ value }); + } + + constexpr auto stringid(ice::String value) noexcept -> ice::StringID + { + return ice::stringid(value.data(), value.size().u64()); + } + +} // namespace ice diff --git a/source/code/core/collections/public/ice/string/editable_operations.hxx b/source/code/core/collections/public/ice/string/editable_operations.hxx new file mode 100644 index 00000000..f2957a7d --- /dev/null +++ b/source/code/core/collections/public/ice/string/editable_operations.hxx @@ -0,0 +1,136 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include + +namespace ice::string +{ + + using ice::concepts::MutableStringType; + + struct MutableOperations : ice::string::ReadOnlyOperations + { + template + inline void clear(this Self& self) noexcept + { + self.resize(0); + } + + template + inline void push_back(this Self& self, typename Self::CharType character) noexcept + { + ice::ncount new_size = self.size() + 1; + ice::ncount const capacity = self.capacity(); + + // Handle resizing if supported + if constexpr (ice::concepts::ResizableStringType) + { + if (new_size >= capacity) + { + self.grow(new_size); + } + } + else + { + ICE_ASSERT_CORE(new_size < capacity); + new_size = ice::min(new_size, capacity - 1); + } + + + self.resize(new_size); + self.data()[new_size - 1] = character; + } + + template + inline void push_back(this Self& self, typename Self::CharType const* cstr) noexcept + { + return self.push_back(ice::BasicString{ cstr }); + } + + template + inline void push_back(this Self& self, ice::StringType auto const& other) noexcept + { + if (other.not_empty()) + { + ice::ncount new_size = self.size() + other.size(); + ice::ncount const capacity = self.capacity(); + + // Handle resizing if supported + if constexpr (ice::concepts::ResizableStringType) + { + if (new_size + 1 >= capacity) + { + self.grow(new_size + 1); + } + } + else + { + ICE_ASSERT_CORE(new_size < capacity); + new_size = ice::min(new_size, capacity - 1); + } + + ice::memcpy( + self.end(), + other.cbegin(), + other.size().bytes() + ); + + self.resize(new_size); + } + } + + template + inline void pop_back(this Self& self, ice::ncount count = 1) noexcept + { + if (self.data() != nullptr) + { + ice::ncount const current_size = self.size(); + self.resize(current_size - ice::min(current_size, count)); + } + } + + // Iterators + + template + constexpr auto begin(this Self& self) noexcept -> typename Self::Iterator + { + return self.data(); + } + + template + constexpr auto end(this Self& self) noexcept -> typename Self::Iterator + { + return self.data() + self.size(); + } + + template + constexpr auto rbegin(this Self& self) noexcept -> typename Self::ReverseIterator + { + return typename Self::ReverseIterator{ self.data() + self.size() }; + } + + template + constexpr auto rend(this Self& self) noexcept -> typename Self::ReverseIterator + { + return typename Self::ReverseIterator{ self.data() }; + } + + // Operators + + template + constexpr auto operator[](this Self& self, ice::nindex index) noexcept -> typename Self::ValueType& + { + return self.data()[index.native()]; + } + + // Data Helpers + + template + constexpr auto memory_view(this Self& self) noexcept -> ice::Memory + { + return Memory{ .location = self.data(), .size = self.capacity(), .alignment = ice::align_of }; + } + }; + +} // namespace ice::string diff --git a/source/code/core/collections/public/ice/string/heap_string.hxx b/source/code/core/collections/public/ice/string/heap_string.hxx deleted file mode 100644 index c089734e..00000000 --- a/source/code/core/collections/public/ice/string/heap_string.hxx +++ /dev/null @@ -1,128 +0,0 @@ -/// Copyright 2022 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - -#pragma once -#include -#include - -namespace ice::string -{ - - template - inline void set_capacity(ice::HeapString& str, ice::ucount new_capacity) noexcept; - - template - inline void reserve(ice::HeapString& str, ice::ucount min_capacity) noexcept; - - template - inline void grow(ice::HeapString& str, ice::ucount min_capacity = 0) noexcept; - - template - inline void resize(ice::HeapString& str, ice::ucount new_size) noexcept; - - template - inline void shrink(ice::HeapString& str) noexcept; - - template - inline void clear(ice::HeapString& str) noexcept; - - template - inline void push_back(ice::HeapString& str, CharType character) noexcept; - - template - inline void push_back(ice::HeapString& str, CharType const* cstr) noexcept; - - template - inline void push_back(ice::HeapString& str, ice::HeapString const& other) noexcept; - - template - inline void push_back(ice::HeapString& str, ice::BasicString cstr) noexcept; - - template - inline void pop_back(ice::HeapString& str, ice::ucount count = 1) noexcept; - - template - inline auto begin(ice::HeapString& str) noexcept -> typename ice::HeapString::Iterator; - - template - inline auto end(ice::HeapString& str) noexcept -> typename ice::HeapString::Iterator; - - template - inline auto rbegin(ice::HeapString& str) noexcept -> typename ice::HeapString::ReverseIterator; - - template - inline auto rend(ice::HeapString& str) noexcept -> typename ice::HeapString::ReverseIterator; - - - template - inline auto size(ice::HeapString const& str) noexcept -> ice::ucount; - - template - inline auto capacity(ice::HeapString const& str) noexcept -> ice::ucount; - - template - inline bool empty(ice::HeapString const& str) noexcept; - - template - inline bool any(ice::HeapString const& str) noexcept; - - template - inline auto begin(ice::HeapString const& str) noexcept -> typename ice::HeapString::ConstIterator; - - template - inline auto end(ice::HeapString const& str) noexcept -> typename ice::HeapString::ConstIterator; - - template - inline auto rbegin(ice::HeapString const& str) noexcept -> typename ice::HeapString::ConstReverseIterator; - - template - inline auto rend(ice::HeapString const& str) noexcept -> typename ice::HeapString::ConstReverseIterator; - - template - inline auto front(ice::HeapString const& str) noexcept -> typename ice::HeapString::ValueType; - - template - inline auto back(ice::HeapString const& str) noexcept -> typename ice::HeapString::ValueType; - - template - inline auto substr(ice::HeapString const& str, ice::ucount pos, ice::ucount len = ice::String_NPos) noexcept -> ice::BasicString; - - template - inline auto substr_clone(ice::HeapString const& str, ice::ucount pos, ice::ucount len = ice::String_NPos) noexcept -> ice::HeapString; - - template - inline auto find_first_of(ice::HeapString const& str, CharType character_value) noexcept -> ice::ucount; - - template - inline auto find_first_of(ice::HeapString const& str, ice::BasicString character_values) noexcept -> ice::ucount; - - template - inline auto find_last_of(ice::HeapString const& str, CharType character_value) noexcept -> ice::ucount; - - template - inline auto find_last_of(ice::HeapString const& str, ice::BasicString character_values) noexcept -> ice::ucount; - - - template - inline auto data_view(ice::HeapString const& str) noexcept -> ice::Data; - - template - inline auto memory(ice::HeapString& str) noexcept -> ice::Memory; - - //! \return Extracts the memory allocated by the heap string. - //! \note The 'size' member contains the 'capacity' of the heap string. - template - inline auto extract_memory(ice::HeapString& str) noexcept -> ice::Memory; - -} // namespace ice::string - -namespace ice -{ - - using ice::string::size; - using ice::string::begin; - using ice::string::end; - -} // namespace ice - -#include "impl/heap_string.inl" diff --git a/source/code/core/collections/public/ice/string/heap_var_string.hxx b/source/code/core/collections/public/ice/string/heap_var_string.hxx deleted file mode 100644 index 620d3155..00000000 --- a/source/code/core/collections/public/ice/string/heap_var_string.hxx +++ /dev/null @@ -1,46 +0,0 @@ -/// Copyright 2024 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - -#pragma once -#include -#include - -namespace ice::string -{ - - template - inline void clear(ice::HeapVarString& str) noexcept; - - template - inline auto begin(ice::HeapVarString& str) noexcept -> typename ice::HeapVarString::Iterator; - - template - inline auto end(ice::HeapVarString& str) noexcept -> typename ice::HeapVarString::Iterator; - - template - inline auto cbegin(ice::HeapVarString const& str) noexcept -> typename ice::HeapVarString::ConstIterator; - - template - inline auto cend(ice::HeapVarString const& str) noexcept -> typename ice::HeapVarString::ConstIterator; - - template - inline auto rbegin(ice::HeapVarString& str) noexcept -> typename ice::HeapVarString::ReverseIterator; - - template - inline auto rend(ice::HeapVarString& str) noexcept -> typename ice::HeapVarString::ReverseIterator; - - template - inline auto deserialize(ice::HeapVarString& str, ice::Data data) noexcept -> ice::Data; - -} // namespace ice::string - -namespace ice -{ - - // using ice::string::size; - // using ice::string::begin; - // using ice::string::end; - -} // namespace ice - -#include "impl/heap_var_string.inl" diff --git a/source/code/core/collections/public/ice/string/impl/heap_string.inl b/source/code/core/collections/public/ice/string/impl/heap_string.inl deleted file mode 100644 index 85dd5b4c..00000000 --- a/source/code/core/collections/public/ice/string/impl/heap_string.inl +++ /dev/null @@ -1,474 +0,0 @@ -/// Copyright 2022 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - - -namespace ice -{ - - template - inline HeapString::HeapString(ice::Allocator& allocator) noexcept - : _allocator{ &allocator } - , _capacity{ 0 } - , _size{ 0 } - , _data{ nullptr } - { - } - - template - inline HeapString::HeapString(ice::Allocator& allocator, ice::BasicString value) noexcept - : _allocator{ &allocator } - , _capacity{ 0 } - , _size{ 0 } - , _data{ nullptr } - { - *this = value; - } - - template - inline HeapString::HeapString(HeapString&& other) noexcept - : _allocator{ other._allocator } - , _size{ ice::exchange(other._size, 0) } - , _capacity{ ice::exchange(other._capacity, 0) } - , _data{ ice::exchange(other._data, nullptr) } - { - } - - template - inline HeapString::HeapString(HeapString const& other) noexcept - : _allocator{ other._allocator } - , _capacity{ 0 } - , _size{ 0 } - , _data{ nullptr } - { - if (other._size > 0) - { - ice::string::set_capacity(*this, other._size + 1); - - // TODO: We need actually very, VERY good tests for string manipulations... - ice::memcpy( - ice::string::end(*this), - ice::string::begin(other), - ice::size_of *ice::string::size(other) - ); - - _size = other._size; - _data[_size] = CharType{ 0 }; - } - } - - template - inline HeapString::~HeapString() noexcept - { - _allocator->deallocate(ice::string::memory(*this)); - } - - template - inline auto HeapString::operator=(HeapString&& other) noexcept -> HeapString& - { - if (this != &other) - { - ice::string::set_capacity(*this, 0); - - _allocator = other._allocator; - _size = ice::exchange(other._size, 0); - _capacity = ice::exchange(other._capacity, 0); - _data = ice::exchange(other._data, nullptr); - } - return *this; - } - - template - inline auto HeapString::operator=(HeapString const& other) noexcept -> HeapString& - { - if (this != &other) - { - ice::string::clear(*this); - ice::string::reserve(*this, other._capacity); - - if (other._size > 0) - { - ice::memcpy( - ice::string::memory(*this), - ice::string::data_view(other) - ); - } - - _size = other._size; - _data[_size] = CharType{ }; - } - return *this; - } - - template - inline auto HeapString::operator=(ice::BasicString str) noexcept -> HeapString& - { - auto const* const other_str_begin = ice::string::begin(str); - bool const part_of_this = other_str_begin >= ice::string::begin(*this) - && other_str_begin < ice::string::end(*this); - ICE_ASSERT_CORE(part_of_this == false); - - if (!part_of_this) - { - ice::string::set_capacity( - *this, - ice::string::size(str) + 1 - ); - - ice::memcpy( - ice::string::memory(*this), - ice::string::data_view(str) - ); - - _size = ice::string::size(str); - _data[_size] = ValueType{ 0 }; - } - return *this; - } - - template - inline bool operator==(ice::HeapString const& left, CharType const* right) noexcept - { - return ice::BasicString{ left } == ice::BasicString{ right }; - } - - template - inline bool operator==(ice::HeapString const& left, ice::BasicString right) noexcept - { - return ice::BasicString{ left } == right; - } - - template - inline bool operator==(ice::BasicString left, ice::HeapString const& right) noexcept - { - return left == ice::BasicString{ right }; - } - - template - inline auto HeapString::operator[](ice::ucount index) noexcept -> CharType& - { - return _data[index]; - } - - template - inline auto HeapString::operator[](ice::ucount index) const noexcept -> CharType const& - { - return _data[index]; - } - - template - inline HeapString::operator ice::BasicString() const noexcept - { - return { _data, _size }; - } - - namespace string - { - - template - inline void set_capacity(ice::HeapString& str, ice::ucount new_capacity) noexcept - { - using ValueType = typename HeapString::ValueType; - - if (new_capacity == str._capacity) - { - return; - } - - ValueType* new_data = nullptr; - if (new_capacity > 0) - { - ice::AllocResult new_buffer = str._allocator->allocate(ice::meminfo_of * new_capacity); - - if (str._size > 0) - { - ice::memcpy(new_buffer, ice::string::data_view(str)); - } - - new_data = reinterpret_cast(new_buffer.memory); - } - - str._allocator->deallocate(ice::string::memory(str)); - str._capacity = new_capacity; - str._data = new_data; - - if (new_capacity <= str._size) - { - str._size = ice::min(new_capacity, new_capacity - 1); - } - - if (str._data != nullptr) - { - str._data[str._size] = 0; - } - } - - template - inline void reserve(ice::HeapString& str, ice::ucount min_capacity) noexcept - { - if (min_capacity > str._capacity) - { - ice::string::set_capacity(str, min_capacity); - } - } - - template - inline void grow(ice::HeapString& str, ice::ucount min_capacity) noexcept - { - ice::ucount const new_capacity = ice::max(str._capacity * 2 + 8, min_capacity); - ice::string::set_capacity(str, new_capacity); - } - - template - inline void resize(ice::HeapString& str, ice::ucount new_size) noexcept - { - if (new_size > 0 && new_size >= str._capacity) - { - ice::string::set_capacity(str, new_size + 1); - } - - str._size = new_size; - if (str._data != nullptr) - { - str._data[str._size] = CharType{ 0 }; - } - } - - template - inline void shrink(ice::HeapString& str) noexcept - { - ice::string::set_capacity(str, str._size + 1); - } - - template - inline void clear(ice::HeapString& str) noexcept - { - ice::string::resize(str, 0); - } - - template - inline void push_back(ice::HeapString& str, CharType character) noexcept - { - if (str._size + 1 >= str._capacity) - { - ice::string::grow(str); - } - - str._data[str._size] = character; - str._size += 1; - str._data[str._size] = CharType{ 0 }; - } - - template - inline void push_back(ice::HeapString& str, CharType const* cstr) noexcept - { - return ice::string::push_back(str, ice::BasicString{ cstr }); - } - - template - inline void push_back(ice::HeapString& str, ice::HeapString const& other) noexcept - { - return ice::string::push_back(str, other.operator ice::BasicString()); - } - - template - inline void push_back(ice::HeapString& str, ice::BasicString other) noexcept - { - if (ice::string::empty(other) == false) - { - uint32_t const new_size = str._size + ice::string::size(other); - if (new_size + 1 >= str._capacity) - { - ice::string::grow(str, new_size + 1); - } - - ice::memcpy( - ice::string::end(str), - ice::string::begin(other), - ice::size_of * ice::string::size(other) - ); - str._size = new_size; - str._data[str._size] = 0; - } - } - - template - inline void pop_back(ice::HeapString& str, ice::ucount count) noexcept - { - if (str._data != nullptr) - { - str._size -= ice::min(str._size, count); - str._data[str._size] = CharType{ 0 }; - } - } - - template - inline auto begin(ice::HeapString& str) noexcept -> typename ice::HeapString::Iterator - { - return str._data; - } - - template - inline auto end(ice::HeapString& str) noexcept -> typename ice::HeapString::Iterator - { - return str._data + str._size; - } - - template - inline auto rbegin(ice::HeapString& str) noexcept -> typename ice::HeapString::ReverseIterator - { - return typename ice::HeapString::ReverseIterator{ str._data + str._size }; - } - - template - inline auto rend(ice::HeapString& str) noexcept -> typename ice::HeapString::ReverseIterator - { - return typename ice::HeapString::ReverseIterator{ str._data }; - } - - - template - inline auto size(ice::HeapString const& str) noexcept -> ice::ucount - { - return str._size; - } - - template - inline auto capacity(ice::HeapString const& str) noexcept -> ice::ucount - { - return str._capacity; - } - - template - inline bool empty(ice::HeapString const& str) noexcept - { - return str._size == 0; - } - - template - inline bool any(ice::HeapString const& str) noexcept - { - return str._size != 0; - } - - template - inline auto begin(ice::HeapString const& str) noexcept -> typename ice::HeapString::ConstIterator - { - return str._data; - } - - template - inline auto end(ice::HeapString const& str) noexcept -> typename ice::HeapString::ConstIterator - { - return str._data + str._size; - } - - template - inline auto rbegin(ice::HeapString const& str) noexcept -> typename ice::HeapString::ConstReverseIterator - { - return typename ice::HeapString::ConstReverseIterator{ str._data + str._size }; - } - - template - inline auto rend(ice::HeapString const& str) noexcept -> typename ice::HeapString::ConstReverseIterator - { - return typename ice::HeapString::ConstReverseIterator{ str._data }; - } - - template - inline auto front(ice::HeapString const& str) noexcept -> typename ice::HeapString::ValueType - { - return str._data[0]; - } - - template - inline auto back(ice::HeapString const& str) noexcept -> typename ice::HeapString::ValueType - { - return str._data[str._size - 1]; - } - - template - inline auto substr(ice::HeapString const& str, ice::ucount pos, ice::ucount len) noexcept -> ice::BasicString - { - return ice::string::substr(ice::BasicString{ str }, pos, len); - } - - template - inline auto substr_clone(ice::HeapString const& str, ice::ucount pos, ice::ucount len) noexcept -> ice::HeapString - { - if (pos >= str._size) - { - return ice::HeapString{ *str._allocator }; - } - - ice::ucount pos_end = str._size; - if (len != ice::String_NPos) - { - pos_end = ice::min(pos_end, pos + len); - } - - return ice::HeapString{ - *str._allocator, - ice::BasicString{ str._data + pos, str._data + pos_end } - }; - } - - template - inline auto find_first_of(ice::HeapString const& str, CharType character_value) noexcept -> uint32_t - { - return ice::string::find_first_of(ice::BasicString{ str }, character_value); - } - - template - inline auto find_first_of(ice::HeapString const& str, ice::BasicString character_values) noexcept -> uint32_t - { - return ice::string::find_first_of(ice::BasicString{ str }, character_values); - } - - template - inline auto find_last_of(ice::HeapString const& str, CharType character_value) noexcept -> uint32_t - { - return ice::string::find_last_of(ice::BasicString{ str }, character_value); - } - - template - inline auto find_last_of(ice::HeapString const& str, ice::BasicString character_values) noexcept -> uint32_t - { - return ice::string::find_last_of(ice::BasicString{ str }, character_values); - } - - - template - inline auto data_view(ice::HeapString const& str) noexcept -> ice::Data - { - return ice::Data{ - .location = str._data, - .size = ice::size_of * str._size, - .alignment = ice::align_of - }; - } - - template - inline auto memory(ice::HeapString& str) noexcept -> ice::Memory - { - return ice::Memory{ - .location = str._data, - .size = ice::size_of * str._capacity, - .alignment = ice::align_of - }; - } - - template - inline auto extract_memory(ice::HeapString& str) noexcept -> ice::Memory - { - ice::exchange(str._size, 0); - - return ice::Memory{ - .location = ice::exchange(str._data, nullptr), - .size = ice::size_of * ice::exchange(str._capacity, 0), - .alignment = ice::align_of - }; - } - - } // namespace string - -} // namespace ice diff --git a/source/code/core/collections/public/ice/string/impl/heap_var_string.inl b/source/code/core/collections/public/ice/string/impl/heap_var_string.inl deleted file mode 100644 index dda767c7..00000000 --- a/source/code/core/collections/public/ice/string/impl/heap_var_string.inl +++ /dev/null @@ -1,190 +0,0 @@ -/// Copyright 2024 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - -namespace ice -{ - - namespace string::detail - { - - inline auto allocate_varstring_exact(ice::Allocator& alloc, ice::ucount size, ice::ucount& out_size_bytes) noexcept -> char* - { - if (size == 0) - { - return nullptr; - } - - // Allocate enough for: bytes + size + '\0' - ice::ucount const final_size = ice::string::detail::calc_varstring_required_size(size) + 1; - ice::Memory const result = alloc.allocate(ice::usize{ final_size }); - out_size_bytes = write_varstring_size(result.location, size); - return reinterpret_cast(result.location); - } - - inline auto create_varstring(ice::Allocator& alloc, ice::String str) noexcept -> char* - { - ice::ucount const str_size = ice::string::size(str); - - ice::ucount bytes = 0; - char* data = ice::string::detail::allocate_varstring_exact(alloc, str_size, bytes); - if (data != nullptr) - { - ice::memcpy(data + bytes, ice::string::begin(str), str_size); - data[bytes + str_size] = '\0'; - } - return data; - } - - } // namespace string::detail - - template - inline HeapVarString::HeapVarString(ice::Allocator& alloc) noexcept - : _allocator{ ice::addressof(alloc) } - , _data{ nullptr } - { - } - - template - inline HeapVarString::HeapVarString(ice::Allocator& alloc, ice::BasicString string) noexcept - : _allocator{ ice::addressof(alloc) } - , _data{ ice::string::detail::create_varstring(alloc, string) } - { - } - - template - inline HeapVarString::HeapVarString(ice::HeapVarString&& other) noexcept - : _allocator{ other._allocator } - , _data{ ice::exchange(other._data, nullptr) } - { - } - - template - inline HeapVarString::HeapVarString(ice::HeapVarString const& other) noexcept - : HeapVarString{ other._allocator, ice::String{ other } } - { - } - - template - inline HeapVarString::~HeapVarString() noexcept - { - if (_data != nullptr) - { - _allocator->deallocate(_data); - } - } - - template - inline auto HeapVarString::operator=(ice::BasicString str) noexcept -> HeapVarString& - { - if (_data != nullptr) - { - _allocator->deallocate(_data); - } - - _data = ice::string::detail::create_varstring(*_allocator, str); - return *this; - } - - template - inline bool operator==(ice::HeapVarString const& left, CharType const* right) noexcept - { - return ice::BasicString{ left } == ice::BasicString{ right }; - } - - template - inline bool operator==(ice::HeapVarString const& left, ice::BasicString right) noexcept - { - return ice::BasicString{ left } == right; - } - - template - inline bool operator==(ice::BasicString left, ice::HeapVarString const& right) noexcept - { - return left == ice::BasicString{ right }; - } - - template - inline HeapVarString::operator ice::BasicString() const noexcept - { - ice::ucount bytes = 0; - ice::ucount const size = ice::string::detail::read_varstring_size(_data, bytes); - if (size > 0) - { - return { _data + bytes, size }; - } - else - { - return {}; - } - } - - template - inline HeapVarString::operator ice::VarStringBase() const noexcept - { - return _data; - } - - namespace string - { - - template - inline void clear(ice::HeapVarString& str) noexcept - { - str._allocator->deallocate(ice::exchange(str._data, nullptr)); - } - - template - inline auto begin(ice::HeapVarString& str) noexcept -> typename ice::HeapVarString::Iterator - { - return ice::string::detail::data_varstring(str._data); - } - - template - inline auto end(ice::HeapVarString& str) noexcept -> typename ice::HeapVarString::Iterator - { - ice::ucount bytes; - ice::ucount const size = ice::string::detail::read_varstring_size(str._data, bytes); - return str._data + bytes + size; - } - - template - inline auto cbegin(ice::HeapVarString& str) noexcept -> typename ice::HeapVarString::ConstIterator - { - return ice::string::detail::data_varstring(str._data); - } - - template - inline auto cend(ice::HeapVarString& str) noexcept -> typename ice::HeapVarString::ConstIterator - { - ice::ucount bytes; - ice::ucount const size = ice::string::detail::read_varstring_size(str._data, bytes); - return str._data + bytes + size; - } - - template - auto deserialize(ice::HeapVarString& str, ice::Data data) noexcept -> ice::Data - { - ICE_ASSERT_CORE(data.size >= 2_B); // 1 byte for size + 1 for a single character - ice::string::clear(str); // Clear the current contents - - ice::ucount bytes; - ice::ucount const size = ice::string::detail::read_varstring_size( - reinterpret_cast(data.location), bytes - ); - if (size > 0) - { - char* const new_str = ice::string::detail::allocate_varstring_exact(*str._allocator, size, bytes); - if (new_str != nullptr) - { - ice::memcpy(new_str + bytes, ice::ptr_add(data.location, ice::usize{ bytes }), size); - new_str[bytes + size] = '\0'; - } - str._data = new_str; // Assign the new allocated data - } - - return ice::ptr_add(data, { bytes + size }); - } - - } // namespace string - -} // namespace ice diff --git a/source/code/core/collections/public/ice/string/impl/static_string.inl b/source/code/core/collections/public/ice/string/impl/static_string.inl deleted file mode 100644 index a91d9276..00000000 --- a/source/code/core/collections/public/ice/string/impl/static_string.inl +++ /dev/null @@ -1,381 +0,0 @@ -/// Copyright 2022 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - - -namespace ice -{ - - template - constexpr StaticString::StaticString() noexcept - : _size{ 0 } - , _data{ } - { - } - - template - template - constexpr StaticString::StaticString(CharType const(&str_arr)[ArraySize]) noexcept - : StaticString{ ice::BasicString{ str_arr } } - { - } - - template - constexpr StaticString::StaticString(ice::BasicString str) noexcept - : _size{ ice::min(Capacity - 1, ice::string::size(str)) } - , _data{ } - { - if (std::is_constant_evaluated()) - { - for (ice::ucount idx = 0; idx < _size; ++idx) - { - _data[idx] = str[idx]; - } - _data[_size] = ValueType{ 0 }; - } - else if (ice::string::any(str)) - { - ice::memcpy(ice::string::memory(*this), ice::string::data_view(str)); - _data[_size] = ValueType{ 0 }; - } - } - - template - template - constexpr StaticString::StaticString(StaticString const& other) noexcept - : _size{ ice::min(Capacity - 1, ice::string::size(other)) } - , _data{ } - { - if (std::is_constant_evaluated()) - { - for (ice::ucount idx = 0; idx < _size; ++idx) - { - _data[idx] = other[idx]; - } - } - else - { - ice::memcpy(ice::string::memory(*this), ice::string::data_view(other)); - } - _data[_size] = ValueType{ 0 }; - } - - template - template - constexpr auto StaticString::operator=(StaticString const& other) noexcept -> StaticString& - { - if (this != &other) - { - ice::string::clear(*this); - - if (other._size > 0) - { - ice::memcpy( - ice::string::memory(*this), - ice::string::data_view(other) - ); - } - - _size = ice::min(Capacity - 1, other._size); - _data[_size] = CharType{ }; - } - return *this; - } - - template - constexpr auto StaticString::operator=(ice::BasicString other) noexcept -> StaticString& - { - auto const* const other_str_begin = ice::string::begin(other); - bool const part_of_this = other_str_begin >= ice::string::begin(*this) - && other_str_begin < ice::string::end(*this); - - if (!part_of_this) - { - ice::string::clear(*this); - - ice::memcpy( - ice::string::memory(*this), - ice::string::data_view(other) - ); - - _size = ice::min(Capacity - 1, ice::string::size(other)); - _data[_size] = ValueType{ 0 }; - } - return *this; - } - - template - constexpr StaticString::operator ice::BasicString() const noexcept - { - return { _data, _size }; - } - - template - constexpr bool operator==(ice::StaticString const& left, CharType const* right) noexcept - { - return ice::BasicString{ left } == ice::BasicString{ right }; - } - - template - constexpr bool operator==(ice::StaticString const& left, ice::BasicString right) noexcept - { - return ice::BasicString{ left } == right; - } - - template - constexpr bool operator==(ice::BasicString left, ice::StaticString const& right) noexcept - { - return left == ice::BasicString{ right }; - } - - namespace string - { - - template - constexpr void resize(ice::StaticString& str, ice::ucount new_size) noexcept - { - // #todo assert(new_size < Capacity) - str._size = ice::min(Capacity - 1, new_size); - str._data[str._size] = CharType{ 0 }; - } - - template - constexpr void clear(ice::StaticString& str) noexcept - { - ice::string::resize(str, 0); - } - - template - constexpr void push_back(ice::StaticString& str, CharType character) noexcept - { - // #todo assert(new_size < Capacity) - if (str._size + 1 < Capacity) - { - str._data[str._size] = character; - str._size += 1; - str._data[str._size] = CharType{ 0 }; - } - } - - template - constexpr void push_back(ice::StaticString& str, CharType const* cstr) noexcept - { - return ice::string::push_back(str, ice::BasicString{ cstr }); - } - - template - constexpr void push_back(ice::StaticString& str, ice::BasicString other) noexcept - { - if (ice::string::empty(other) == false) - { - // #todo assert(new_size < Capacity) - ice::ucount const new_size = ice::min(Capacity - 1, ice::string::size(str) + ice::string::size(other)); - ice::ucount const copy_size = new_size - ice::string::size(str); - - if (copy_size > 0) - { - ice::memcpy( - ice::string::end(str), - ice::string::begin(other), - ice::size_of * copy_size - ); - str._size = new_size; - str._data[str._size] = 0; - } - } - } - - template - constexpr void push_back(ice::StaticString& str, ice::StaticString other) noexcept - { - push_back(str, ice::String{ other }); - } - - template - constexpr void pop_back(ice::StaticString& str, ice::ucount count) noexcept - { - str._size -= ice::min(count, str._size); - str._data[str._size] = CharType{ 0 }; - } - - template - constexpr auto begin(ice::StaticString& str) noexcept -> typename ice::StaticString::Iterator - { - return str._data; - } - - template - constexpr auto end(ice::StaticString& str) noexcept -> typename ice::StaticString::Iterator - { - return str._data + str._size; - } - - template - constexpr auto rbegin(ice::StaticString& str) noexcept -> typename ice::StaticString::ReverseIterator - { - return typename ice::HeapString::ReverseIterator{ str._data + str._size }; - } - - template - constexpr auto rend(ice::StaticString& str) noexcept -> typename ice::StaticString::ReverseIterator - { - return typename ice::HeapString::ReverseIterator{ str._data }; - } - - - template - constexpr auto size(ice::StaticString const& str) noexcept -> ice::ucount - { - return str._size; - } - - template - constexpr auto data(ice::StaticString const& str) noexcept -> typename ice::StaticString::ValueType const* - { - return str._data; - } - - template - constexpr auto capacity(ice::StaticString const& str) noexcept -> ice::ucount - { - return Capacity; - } - - template - constexpr bool empty(ice::StaticString const& str) noexcept - { - return str._size == 0; - } - - template - constexpr auto begin(ice::StaticString const& str) noexcept -> typename ice::StaticString::ConstIterator - { - return str._data; - } - - template - constexpr auto end(ice::StaticString const& str) noexcept -> typename ice::StaticString::ConstIterator - { - return str._data + str._size; - } - - template - constexpr auto rbegin(ice::StaticString const& str) noexcept -> typename ice::StaticString::ConstReverseIterator - { - return typename ice::HeapString::ConstReverseIterator{ str._data + str._size }; - } - - template - constexpr auto rend(ice::StaticString const& str) noexcept -> typename ice::StaticString::ConstReverseIterator - { - return typename ice::HeapString::ConstReverseIterator{ str._data }; - } - - template - constexpr auto front(ice::StaticString const& str) noexcept -> typename ice::StaticString::ValueType - { - return str._data[0]; - } - - template - constexpr auto back(ice::StaticString const& str) noexcept -> typename ice::StaticString::ValueType - { - return str._data[str._size - 1]; - } - - template - constexpr auto substr(ice::StaticString const& str, ice::ucount pos, ice::ucount len) noexcept -> ice::BasicString - { - return ice::string::substr(ice::BasicString{ str }, pos, len); - } - - template - constexpr auto substr_clone(ice::StaticString const& str, ice::ucount pos, ice::ucount len) noexcept -> ice::StaticString - { - if (pos >= str._size) - { - return ice::StaticString{ }; - } - - ice::ucount pos_end = str._size; - if (len != ice::String_NPos) - { - pos_end = ice::min(pos_end, pos + len); - } - - return ice::StaticString{ - ice::BasicString{ str._data + pos, str._data + pos_end } - }; - } - - template - constexpr auto find_first_of(ice::StaticString const& str, CharType character_value) noexcept -> ice::ucount - { - return ice::string::find_first_of(ice::BasicString{ str }, character_value); - } - - template - constexpr auto find_first_of(ice::StaticString const& str, ice::BasicString character_values) noexcept -> ice::ucount - { - return ice::string::find_first_of(ice::BasicString{ str }, character_values); - } - - template - constexpr auto find_last_of(ice::StaticString const& str, CharType character_value) noexcept -> ice::ucount - { - return ice::string::find_last_of(ice::BasicString{ str }, character_value); - } - - template - constexpr auto find_last_of(ice::StaticString const& str, ice::BasicString character_values) noexcept -> ice::ucount - { - return ice::string::find_last_of(ice::BasicString{ str }, character_values); - } - - template - constexpr auto find_first_not_of(ice::StaticString const& str, CharType character_value) noexcept -> ice::ucount - { - return ice::string::find_first_not_of(ice::BasicString{ str }, character_value); - } - - template - constexpr auto find_first_not_of(ice::StaticString const& str, ice::BasicString character_values) noexcept -> ice::ucount - { - return ice::string::find_first_not_of(ice::BasicString{ str }, character_values); - } - - template - constexpr auto find_last_not_of(ice::StaticString const& str, CharType character_value) noexcept -> ice::ucount - { - return ice::string::find_last_not_of(ice::BasicString{ str }, character_value); - } - - template - constexpr auto find_last_not_of(ice::StaticString const& str, ice::BasicString character_values) noexcept -> ice::ucount - { - return ice::string::find_last_not_of(ice::BasicString{ str }, character_values); - } - - - template - constexpr auto data_view(ice::StaticString const& str) noexcept -> ice::Data - { - return ice::Data{ - .location = str._data, - .size = ice::size_of * str._size, - .alignment = ice::align_of - }; - } - - template - constexpr auto memory(ice::StaticString& str) noexcept -> ice::Memory - { - return ice::Memory{ - .location = str._data, - .size = ice::size_of * Capacity, - .alignment = ice::align_of - }; - } - - } // namespace string - -} // namespace ice diff --git a/source/code/core/collections/public/ice/string/impl/string.inl b/source/code/core/collections/public/ice/string/impl/string.inl deleted file mode 100644 index 4aa17b5e..00000000 --- a/source/code/core/collections/public/ice/string/impl/string.inl +++ /dev/null @@ -1,403 +0,0 @@ -/// Copyright 2022 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - - -namespace ice -{ - - constexpr auto operator""_str(char const* buffer, size_t size) noexcept -> ice::BasicString - { - return ice::BasicString{ buffer, ice::ucount(size) }; - } - - namespace string::detail - { - - template - constexpr auto strptr_size(CharType const* str) noexcept -> ice::ucount - { - ice::ucount result = 0; - if (str != nullptr) - { - CharType const* it = str; - while (*it != CharType{ 0 }) - { - it += 1; - } - - result = static_cast(it - str); - } - return result; - } - - } // namespace string::detail - - template - constexpr BasicString::BasicString(CharType const* str_ptr) noexcept - : BasicString{ str_ptr, ice::string::detail::strptr_size(str_ptr) } - { - } - - template - constexpr BasicString::BasicString(CharType const* str_beg, CharType const* str_end) noexcept - : BasicString{ str_beg, static_cast(str_end - str_beg) } - { - } - - template - constexpr BasicString::BasicString(CharType const* str_ptr, ice::ucount size) noexcept - : _data{ str_ptr } - , _size{ size } - { - } - - template - template - constexpr BasicString::BasicString(CharType const(&str_arr)[Size]) noexcept - : _data{ str_arr } - , _size{ Size } - { - } - - template - constexpr BasicString::BasicString(std::basic_string_view sv) noexcept - : _data{ sv.data() } - , _size{ ice::ucount(sv.size()) } - { - } - - template - constexpr auto BasicString::operator[](ice::ucount index) const noexcept -> CharType const& - { - return _data[index]; - } - - template - constexpr bool BasicString::operator==(BasicString other) const noexcept - { - if (_size == other._size) - { - if (_size == 0) - { - return true; - } - - ice::ucount idx = 0; - while (idx < _size && _data[idx] == other._data[idx]) - { - idx += 1; - } - return idx == _size; - } - return false; - } - - template - constexpr BasicString::operator std::basic_string_view() const noexcept - { - return { _data, _size }; - } - - namespace string - { - - template - constexpr auto size(ice::BasicString str) noexcept -> ice::ucount - { - return str._size; - } - - template - constexpr auto capacity(ice::BasicString str) noexcept -> ice::ucount - { - return ice::string::size(str); - } - - template - constexpr bool empty(ice::BasicString str) noexcept - { - return str._size == 0; - } - - template - constexpr bool any(ice::BasicString str) noexcept - { - return str._size != 0; - } - - template - constexpr auto begin(ice::BasicString str) noexcept -> typename ice::BasicString::ConstIterator - { - return str._data; - } - - template - constexpr auto end(ice::BasicString str) noexcept -> typename ice::BasicString::ConstIterator - { - return str._data + str._size; - } - - template - constexpr auto rbegin(ice::BasicString str) noexcept -> typename ice::BasicString::ConstReverseIterator - { - return typename ice::BasicString::ConstReverseIterator{ str._data + str._size }; - } - - template - constexpr auto rend(ice::BasicString str) noexcept -> typename ice::BasicString::ConstReverseIterator - { - return typename ice::BasicString::ConstReverseIterator{ str._data }; - } - - template - constexpr auto front(ice::BasicString str) noexcept -> typename ice::BasicString::ValueType - { - return str[0]; - } - - template - constexpr auto back(ice::BasicString str) noexcept -> typename ice::BasicString::ValueType - { - return str[str._size - 1]; - } - - template - constexpr auto substr(ice::BasicString str, ice::ucount pos, ice::ucount len) noexcept -> ice::BasicString - { - if (pos >= str._size) - { - return { }; - } - - if (len == ice::String_NPos) - { - return { str._data + pos, str._size - pos }; - } - else - { - return { str._data + pos, std::min(len, str._size - pos) }; - } - } - - template - constexpr auto substr(ice::BasicString str, ice::ref32 ref) noexcept -> ice::BasicString - { - return ice::string::substr(str, ref.offset, ref.size); - } - - template - constexpr auto starts_with(ice::BasicString str, ice::concepts::StringType auto prefix) noexcept - { - return ice::string::substr(str, 0, prefix._size) == prefix; - } - - - template - constexpr auto find_first_of( - ice::BasicString str, - CharType character_value, - ice::ucount start_idx - ) noexcept -> ice::ucount - { - auto const* it = ice::string::begin(str) + start_idx; - auto const* const beg = it; - auto const* const end = ice::string::end(str); - - while (it < end && *it != character_value) - { - it += 1; - } - - return it >= end ? ice::String_NPos : start_idx + ice::ucount(it - beg); - } - - template - constexpr auto find_first_of( - ice::BasicString str, - ice::BasicString character_values, - ice::ucount start_idx - ) noexcept -> ice::ucount - { - auto const* it = ice::string::begin(str) + start_idx; - auto const* const beg = it; - auto const* const it_end = ice::string::end(str); - - while (it < it_end && ice::string::find_first_of(character_values, *it) == ice::String_NPos) - { - it += 1; - } - - return it >= it_end ? ice::String_NPos : start_idx + ice::ucount(it - beg); - } - - template - constexpr auto find_last_of( - ice::BasicString str, - CharType character_value, - ice::ucount start_idx - ) noexcept -> ice::ucount - { - auto it = ice::string::rbegin(str); - auto const it_end = ice::string::rend(str); - - while (it != it_end && start_idx > 0) - { - it += 1; - start_idx -= 1; - } - - while (it != it_end && *it != character_value) - { - it += 1; - } - - return it == it_end ? ice::String_NPos : ice::ucount(it_end - it) - 1; - } - - template - constexpr auto find_last_of( - ice::BasicString str, - ice::BasicString character_values, - ice::ucount start_idx - ) noexcept -> ice::ucount - { - auto it = ice::string::rbegin(str); - auto const it_end = ice::string::rend(str); - - while (it != it_end && start_idx > 0) - { - it += 1; - start_idx -= 1; - } - - while (it != it_end && ice::string::find_first_of(character_values, *it) == ice::String_NPos) - { - it += 1; - } - - return it == it_end ? ice::String_NPos : ice::ucount(it_end - it) - 1; - } - - template - constexpr auto find_first_not_of( - ice::BasicString str, - CharType character_value, - ice::ucount start_idx - ) noexcept -> ice::ucount - { - auto const* it = ice::string::begin(str) + start_idx; - auto const* const beg = it; - auto const* const end = ice::string::end(str); - - while (it < end && *it == character_value) - { - it += 1; - } - - return it >= end ? ice::String_NPos : start_idx + ice::ucount(it - beg); - } - - template - constexpr auto find_first_not_of( - ice::BasicString str, - ice::BasicString character_values, - ice::ucount start_idx - ) noexcept -> ice::ucount - { - auto const* it = ice::string::begin(str) + start_idx; - auto const* const beg = it; - auto const* const it_end = ice::string::end(str); - - while (it < it_end && ice::string::find_first_of(character_values, *it) != ice::String_NPos) - { - it += 1; - } - - return it >= it_end ? ice::String_NPos : start_idx + ice::ucount(it - beg); - } - - template - constexpr auto find_last_not_of( - ice::BasicString str, - CharType character_value, - ice::ucount start_idx - ) noexcept -> ice::ucount - { - auto it = ice::string::rbegin(str); - auto const end = ice::string::rend(str); - - while (it != end && start_idx > 0) - { - it += 1; - start_idx -= 1; - } - - while (it != end && *it == character_value) - { - it += 1; - } - - return it == end ? ice::String_NPos : ice::ucount(end - it) - 1; - } - - template - constexpr auto find_last_not_of( - ice::BasicString str, - ice::BasicString character_values, - ice::ucount start_idx - ) noexcept -> ice::ucount - { - auto it = ice::string::rbegin(str); - auto const it_end = ice::string::rend(str); - - while (it != it_end && start_idx > 0) - { - it += 1; - start_idx -= 1; - } - - while (it != it_end && ice::string::find_first_of(character_values, *it) != ice::String_NPos) - { - it += 1; - } - - return it == it_end ? ice::String_NPos : ice::ucount(it_end - it) - 1; - } - - - template requires ice::concepts::RODataObject - constexpr auto from_data(T ro_data) noexcept -> ice::BasicString - { - return ice::string::from_data(ro_data, 0_B, static_cast(ro_data.size.value)); - } - - template requires ice::concepts::RODataObject - constexpr auto from_data(T ro_data, ice::usize offset, ice::ucount size) noexcept -> ice::String - { - return ice::String{ - reinterpret_cast(ro_data.location) + offset.value, - ice::min(static_cast(ro_data.size.value), size) - }; - } - - template - constexpr auto data_view(ice::BasicString str) noexcept -> typename ice::Data - { - return ice::Data{ - .location = str._data, - .size = ice::size_of * str._size, - .alignment = ice::align_of - }; - } - - template - constexpr auto meminfo(ice::BasicString str) noexcept -> ice::meminfo - { - return ice::meminfo{ - ice::meminfo_of * ice::string::size(str) - }; - } - - } // namespace string - -} // namespace ice diff --git a/source/code/core/collections/public/ice/string/impl/var_string.inl b/source/code/core/collections/public/ice/string/impl/var_string.inl deleted file mode 100644 index c57ad0be..00000000 --- a/source/code/core/collections/public/ice/string/impl/var_string.inl +++ /dev/null @@ -1,197 +0,0 @@ -/// Copyright 2024 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - - -namespace ice -{ - - namespace string::detail - { - - inline auto calc_varstring_required_size(ice::ucount size) noexcept -> ice::ucount - { - ice::ucount bytes = 0; - while(size > 0x7f) - { - size >>= 7; - bytes += 1; - } - return (bytes + 1) + size; - } - - inline auto read_varstring_size(char const* data, ice::ucount& out_bytes) noexcept -> ice::ucount - { - ice::ucount result = 0; - if (data != nullptr) - { - ice::u8 const* var_byte = reinterpret_cast(data); - out_bytes = 1; - while(*var_byte & 0x80) - { - result += *var_byte; - result <<= 7; - var_byte += 1; - out_bytes += 1; - } - result += *var_byte; - } - return result; - } - - inline auto read_varstring_size(char const* data) noexcept -> ice::ucount - { - ice::ucount bytes; // Unused - return read_varstring_size(data, bytes); - } - - template - inline auto data_varstring(CharType const* data) noexcept -> CharType const* - { - ice::ucount bytes = 0; - if (data == nullptr || read_varstring_size(data, bytes) == 0) - { - return nullptr; - } - return data + bytes; - } - - inline auto write_varstring_size(void* data, ice::ucount size) noexcept -> ice::ucount - { - ice::ucount bytes = 0; - ice::u8* var_byte = reinterpret_cast(data); - while (size > 0x7f) - { - var_byte[bytes] = (size & 0x7f) | 0x80; - size >>= 7; - bytes += 1; - } - var_byte[bytes] = size & 0x7f; - return bytes + 1; - } - - } // namespace detail - - template - inline VarStringBase::VarStringBase() noexcept - : _data{ nullptr } - { } - - template - inline VarStringBase::VarStringBase(CharType const* str_ptr) noexcept - : _data{ str_ptr } - { - } - - template - inline auto VarStringBase::operator[](ice::ucount idx) noexcept -> CharType& - { - ice::ucount bytes = 0; - ice::ucount const size = read_varstring_size(_data, bytes); - ICE_ASSERT_CORE(size > idx); - return (_data + bytes + idx); - } - - template - inline auto VarStringBase::operator[](ice::ucount idx) const noexcept -> CharType const& - { - ice::ucount bytes = 0; - ice::ucount const size = read_varstring_size(_data, bytes); - ICE_ASSERT_CORE(size > idx); - return (_data + bytes + idx); - } - - template - inline VarStringBase::operator ice::BasicString() const noexcept - { - ice::u32 bytes = 0; - ice::ucount const size = ice::string::detail::read_varstring_size(_data, bytes); - return { _data + bytes, size }; - } - - namespace string - { - - inline auto size(ice::string::VarStringType auto const& str) noexcept -> ice::ucount - { - return ice::string::detail::read_varstring_size(str._data); - } - - inline auto capacity(ice::string::VarStringType auto const& str) noexcept -> ice::ucount - { - return ice::string::size(str); - } - - inline bool empty(ice::string::VarStringType auto const& str) noexcept - { - return str._data == nullptr || str._data[0] == '\0'; - } - - template - inline auto begin(StringType const& str) noexcept -> typename StringType::ConstIterator - { - return ice::string::detail::data_varstring(str._data); - } - - template - inline auto end(StringType const& str) noexcept -> typename StringType::ConstIterator - { - ice::ucount bytes = 0; - ice::ucount const size = ice::string::detail::read_varstring_size(str._data, bytes); - return str._data + bytes + size; - } - - inline auto data_view(ice::string::VarStringType auto const& str) noexcept -> ice::Data - { - ice::ucount bytes = 0; - ice::ucount const size = ice::string::detail::read_varstring_size(str._data, bytes); - - return { - .location = str._data, - .size = { size + bytes }, - .alignment = ice::ualign::b_1 - }; - } - - auto serialize(ice::string::VarStringType auto const& str, ice::Memory target) noexcept -> ice::Memory - { - ice::ucount const size = ice::string::size(str); - ICE_ASSERT_CORE( - ice::string::detail::calc_varstring_required_size(size) <= target.size.value - ); - - ice::ucount const sizebytes = ice::string::detail::write_varstring_size(target.location, size); - target.location = ice::ptr_add(target.location, ice::usize{ sizebytes }); - target.size.value -= sizebytes; - - ice::memcpy(target.location, str._data + sizebytes, size); - target.location = ice::ptr_add(target.location, ice::usize{ size }); - target.size.value -= size; - target.alignment = ice::ualign::b_1; - return target; - } - - } // namespace string - - namespace data - { - - template - inline auto read_varstring(ice::Data data, ice::VarStringBase& out_str) noexcept -> ice::Data - { - ICE_ASSERT_CORE(data.size >= 2_B); // 1 byte for size + 1 for a single character - - char const* const rawstr = reinterpret_cast(data.location); - - ice::ucount bytes; - ice::ucount const size = ice::string::detail::read_varstring_size(rawstr, bytes); - if (size > 0) - { - out_str._data = rawstr; - } - - return ice::ptr_add(data, { bytes + size }); - } - - } // namespace data - -} // namespace ice diff --git a/source/code/core/collections/public/ice/string/readonly_operations.hxx b/source/code/core/collections/public/ice/string/readonly_operations.hxx new file mode 100644 index 00000000..4e77c521 --- /dev/null +++ b/source/code/core/collections/public/ice/string/readonly_operations.hxx @@ -0,0 +1,334 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include +#include + +namespace ice::string +{ + + using ice::concepts::StringType; + + struct ReadOnlyOperations + { + template + constexpr bool is_empty(this Self const& self) noexcept + { + return self.size() == 0; + } + + template + constexpr bool not_empty(this Self const& self) noexcept + { + return self.size() > 0; + } + + template + inline auto front(this Self const& self) noexcept -> typename Self::CharType + { + return self.data()[0]; + } + + template + inline auto back(this Self const& self) noexcept -> typename Self::CharType + { + return self.data()[self.size() - 1]; + } + + template + constexpr auto substr( + this Self const& self, ice::nindex pos, ice::ncount len = {} + ) noexcept -> typename Self::StringType + { + ice::ncount const size = self.size(); + if (pos >= size) + { + return { }; + } + + if (len == ice::ncount_none) + { + return { self.data() + pos, size - pos }; + } + else + { + return { self.data() + pos, std::min(len, size - pos) }; + } + } + + template + constexpr auto substr( + this Self const& self, ice::ref32 ref + ) noexcept -> typename Self::StringType + { + return self.substr(ref.offset, ref.size); + } + + template + constexpr auto starts_with(this Self const& self, StringType auto prefix) noexcept + { + return self.substr(0, prefix.size()) == prefix; + } + + template + constexpr auto find_first_of( + this Self const& self, + typename Self::CharType character_value, + ice::nindex start = 0 + ) noexcept -> ice::nindex + { + auto const* it = self.cbegin() + start; + auto const* const beg = it; + auto const* const end = self.cend(); + + while (it < end && *it != character_value) + { + it += 1; + } + + return it >= end ? ice::nindex{} : ice::nindex{ start + (it - beg) }; + } + + template + constexpr auto find_first_of( + this Self const& self, + typename Self::StringType character_values, + ice::nindex start = 0 + ) noexcept -> ice::nindex + { + auto const* it = self.cbegin() + start; + auto const* const beg = it; + auto const* const it_end = self.cend(); + + while (it < it_end && character_values.find_first_of(*it) == nindex_none) + { + it += 1; + } + + return it >= it_end ? ice::nindex{} : ice::nindex{ start + (it - beg) }; + } + + template + constexpr auto find_last_of( + this Self const& self, + typename Self::CharType character_value, + ice::nindex start = 0 + ) noexcept -> ice::nindex + { + auto it = self.crbegin(); + auto const it_end = self.crend(); + + while (it != it_end && start > 0) + { + it += 1; + start -= 1; + } + + while (it != it_end && *it != character_value) + { + it += 1; + } + + return it == it_end ? ice::nindex{} : ice::nindex{ u64((it_end - it) - 1) }; + } + + template + constexpr auto find_last_of( + this Self const& self, + typename Self::StringType character_values, + ice::nindex start = 0 + ) noexcept -> ice::nindex + { + auto it = self.crbegin(); + auto const it_end = self.crend(); + + while (it != it_end && start > 0) + { + it += 1; + start -= 1; + } + + while (it != it_end && character_values.find_first_of(*it) == nindex_none) + { + it += 1; + } + + return it == it_end ? ice::nindex{} : ice::nindex{ u64((it_end - it) - 1) }; + } + + template + constexpr auto find_first_not_of( + this Self const& self, + typename Self::CharType character_value, + ice::nindex start_idx = 0 + ) noexcept -> ice::nindex + { + auto const* it = self.cbegin() + start_idx; + auto const* const beg = it; + auto const* const end = self.cend(); + + while (it < end && *it == character_value) + { + it += 1; + } + + return it >= end ? ice::nindex{} : start_idx + ice::nindex{ u64(it - beg) }; + } + + template + constexpr auto find_first_not_of( + this Self const& self, + typename Self::StringType character_values, + ice::nindex start_idx = 0 + ) noexcept -> ice::nindex + { + auto const* it = self.cbegin() + start_idx; + auto const* const beg = it; + auto const* const it_end = self.cend(); + + while (it < it_end && character_values.find_first_of(*it) != ice::nindex_none) + { + it += 1; + } + + return it >= it_end ? ice::nindex{} : start_idx + ice::nindex{ u64(it - beg) }; + } + + template + constexpr auto find_last_not_of( + this Self const& self, + typename Self::CharType character_value, + ice::nindex start_idx = 0 + ) noexcept -> ice::nindex + { + auto it = self.crbegin(); + auto const end = self.crend(); + + while (it != end && start_idx > 0) + { + it += 1; + start_idx -= 1; + } + + while (it != end && *it == character_value) + { + it += 1; + } + + return it == end ? ice::nindex{} : ice::nindex{ u64((end - it) - 1) }; + } + + template + constexpr auto find_last_not_of( + this Self const& self, + typename Self::StringType character_values, + ice::nindex start_idx = 0 + ) noexcept -> ice::nindex + { + auto it = self.crbegin(); + auto const it_end = self.crend(); + + while (it != it_end && start_idx > 0) + { + it += 1; + start_idx -= 1; + } + + while (it != it_end && character_values.find_first_of(*it) != ice::nindex_none) + { + it += 1; + } + + return it == it_end ? ice::nindex{} : ice::nindex{ (it_end - it) - 1 }; + } + + // Iterators + + template + constexpr auto cbegin(this Self const& self) noexcept -> typename Self::ConstIterator + { + return self.data(); + } + + template + constexpr auto cend(this Self const& self) noexcept -> typename Self::ConstIterator + { + return self.data() + self.size(); + } + + template + constexpr auto crbegin(this Self const& self) noexcept -> typename Self::ConstReverseIterator + { + return typename Self::ConstReverseIterator{ self.data() + self.size() }; + } + + template + constexpr auto crend(this Self const& self) noexcept -> typename Self::ConstReverseIterator + { + return typename Self::ConstReverseIterator{ self.data() }; + } + + template + constexpr auto begin(this Self const& self) noexcept -> typename Self::ConstIterator + { + return self.cbegin(); + } + + template + constexpr auto end(this Self const& self) noexcept -> typename Self::ConstIterator + { + return self.cend(); + } + + template + constexpr auto rbegin(this Self const& self) noexcept -> typename Self::ConstReverseIterator + { + return self.crbegin(); + } + + template + constexpr auto rend(this Self const& self) noexcept -> typename Self::ConstReverseIterator + { + return self.crend(); + } + + // Operators + + template + constexpr auto operator[](this Self const& self, ice::nindex index) noexcept -> typename Self::ValueType + { + return self.data()[index]; + } + + template + constexpr bool operator==(this Self const& self, typename Self::StringType const& other) noexcept + { + ice::ncount const size = self.size(); + if (size == other.size()) + { + typename Self::ValueType const* self_data = self.data(); + typename Self::ValueType const* other_data = other.data(); + + ice::nindex::base_type idx = 0; + while (idx < size && self_data[idx] == other_data[idx]) + { + idx += 1; + } + return idx == size; + } + return false; + } + + // Data Helpers + + template + constexpr auto meminfo(this Self const& self) noexcept -> ice::meminfo + { + return ice::meminfo{ + ice::meminfo_of * self.size().native() + }; + } + }; + +} // namespace ice::string diff --git a/source/code/core/collections/public/ice/string/resizable_operations.hxx b/source/code/core/collections/public/ice/string/resizable_operations.hxx new file mode 100644 index 00000000..25fc10e4 --- /dev/null +++ b/source/code/core/collections/public/ice/string/resizable_operations.hxx @@ -0,0 +1,39 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include + +namespace ice::string +{ + + using ice::concepts::ResizableStringType; + + struct ResizableOperations : ice::string::MutableOperations + { + // Capacity and Size Helpers + + template + inline void shrink(this Self& self) noexcept + { + self.set_capacity(self.size() + 1); + } + + template + inline void reserve(this Self& self, ice::ncount min_capacity) noexcept + { + if (min_capacity > self.capacity()) + { + self.set_capacity(min_capacity); + } + } + + template + inline void grow(this Self& self, ice::ncount min_capacity = ncount_none) noexcept + { + ice::ncount const new_capacity = ice::max(self.capacity() * 2 + 8, min_capacity); + self.set_capacity(new_capacity); + } + }; + +} // namespace ice::string diff --git a/source/code/core/collections/public/ice/string/static_string.hxx b/source/code/core/collections/public/ice/string/static_string.hxx deleted file mode 100644 index 2f86c590..00000000 --- a/source/code/core/collections/public/ice/string/static_string.hxx +++ /dev/null @@ -1,129 +0,0 @@ -/// Copyright 2022 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - -#pragma once -#include -#include - -namespace ice::string -{ - - template - constexpr void set_capacity(ice::StaticString& str, ice::ucount new_capacity) noexcept = delete; - - template - constexpr void reserve(ice::StaticString& str, ice::ucount min_capacity) noexcept = delete; - - template - constexpr void grow(ice::StaticString& str, ice::ucount min_capacity) noexcept = delete; - - template - constexpr void resize(ice::StaticString& str, ice::ucount new_size) noexcept; - - template - constexpr void shrink(ice::StaticString& str) noexcept = delete; - - template - constexpr void clear(ice::StaticString& str) noexcept; - - template - constexpr void push_back(ice::StaticString& str, CharType character) noexcept; - - template - constexpr void push_back(ice::StaticString& str, CharType const* cstr) noexcept; - - template - constexpr void push_back(ice::StaticString& str, ice::BasicString cstr) noexcept; - - template - constexpr void pop_back(ice::StaticString& str, ice::ucount count) noexcept; - - template - constexpr auto begin(ice::StaticString& str) noexcept -> typename ice::StaticString::Iterator; - - template - constexpr auto end(ice::StaticString& str) noexcept -> typename ice::StaticString::Iterator; - - template - constexpr auto rbegin(ice::StaticString& str) noexcept -> typename ice::StaticString::ReverseIterator; - - template - constexpr auto rend(ice::StaticString& str) noexcept -> typename ice::StaticString::ReverseIterator; - - - template - constexpr auto size(ice::StaticString const& str) noexcept -> ice::ucount; - - template - constexpr auto capacity(ice::StaticString const& str) noexcept -> ice::ucount; - - template - constexpr bool empty(ice::StaticString const& str) noexcept; - - template - constexpr auto begin(ice::StaticString const& str) noexcept -> typename ice::StaticString::ConstIterator; - - template - constexpr auto end(ice::StaticString const& str) noexcept -> typename ice::StaticString::ConstIterator; - - template - constexpr auto rbegin(ice::StaticString const& str) noexcept -> typename ice::StaticString::ConstReverseIterator; - - template - constexpr auto rend(ice::StaticString const& str) noexcept -> typename ice::StaticString::ConstReverseIterator; - - template - constexpr auto front(ice::StaticString const& str) noexcept -> typename ice::StaticString::ValueType; - - template - constexpr auto back(ice::StaticString const& str) noexcept -> typename ice::StaticString::ValueType; - - template - constexpr auto substr(ice::StaticString const& str, ice::ucount pos, ice::ucount len = ice::String_NPos) noexcept -> ice::BasicString; - - template - constexpr auto substr_clone(ice::StaticString const& str, ice::ucount pos, ice::ucount len = ice::String_NPos) noexcept -> ice::StaticString; - - template - constexpr auto find_first_of(ice::StaticString const& str, CharType character_value) noexcept -> ice::ucount; - - template - constexpr auto find_first_of(ice::StaticString const& str, ice::BasicString character_values) noexcept -> ice::ucount; - - template - constexpr auto find_last_of(ice::StaticString const& str, CharType character_value) noexcept -> ice::ucount; - - template - constexpr auto find_last_of(ice::StaticString const& str, ice::BasicString character_values) noexcept -> ice::ucount; - - template - constexpr auto find_first_not_of(ice::StaticString const& str, CharType character_value) noexcept -> ice::ucount; - - template - constexpr auto find_first_not_of(ice::StaticString const& str, ice::BasicString character_values) noexcept -> ice::ucount; - - template - constexpr auto find_last_not_of(ice::StaticString const& str, CharType character_value) noexcept -> ice::ucount; - - template - constexpr auto find_last_not_of(ice::StaticString const& str, ice::BasicString character_values) noexcept -> ice::ucount; - - - template - constexpr auto data_view(ice::StaticString const& str) noexcept -> ice::Data; - - template - constexpr auto memory(ice::StaticString& str) noexcept -> ice::Memory; - -} // namespace ice::string - -namespace ice -{ - - using ice::string::size; - using ice::string::begin; - using ice::string::end; - -} // namespace ice - -#include "impl/static_string.inl" diff --git a/source/code/core/collections/public/ice/string/string.hxx b/source/code/core/collections/public/ice/string/string.hxx deleted file mode 100644 index 92fd0852..00000000 --- a/source/code/core/collections/public/ice/string/string.hxx +++ /dev/null @@ -1,129 +0,0 @@ -/// Copyright 2022 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - -#pragma once -#include - -namespace ice::string -{ - - template - constexpr auto size(ice::BasicString str) noexcept -> ice::ucount; - - template - constexpr auto capacity(ice::BasicString str) noexcept -> ice::ucount; - - template - constexpr bool empty(ice::BasicString str) noexcept; - - template - constexpr bool any(ice::BasicString str) noexcept; - - template - constexpr auto begin(ice::BasicString a) noexcept -> typename ice::BasicString::ConstIterator; - - template - constexpr auto end(ice::BasicString str) noexcept -> typename ice::BasicString::ConstIterator; - - template - constexpr auto rbegin(ice::BasicString a) noexcept -> typename ice::BasicString::ConstReverseIterator; - - template - constexpr auto rend(ice::BasicString str) noexcept -> typename ice::BasicString::ConstReverseIterator; - - template - constexpr auto front(ice::BasicString str) noexcept -> typename ice::BasicString::ValueType; - - template - constexpr auto back(ice::BasicString str) noexcept -> typename ice::BasicString::ValueType; - - template - constexpr auto substr(ice::BasicString str, ice::ucount pos, ice::ucount len = ice::String_NPos) noexcept -> ice::BasicString; - - template - constexpr auto substr(ice::BasicString str, ice::ref32 ref) noexcept -> ice::BasicString; - - template - constexpr auto starts_with(ice::BasicString str, ice::concepts::StringType auto prefix) noexcept; - - template - constexpr auto find_first_of( - ice::BasicString str, - CharType character_value, - ice::ucount start_idx = 0 - ) noexcept -> ice::ucount; - - template - constexpr auto find_first_of( - ice::BasicString str, - ice::BasicString character_values, - ice::ucount start_idx = 0 - ) noexcept -> ice::ucount; - - template - constexpr auto find_last_of( - ice::BasicString str, - CharType character_value, - ice::ucount start_idx = 0 - ) noexcept -> ice::ucount; - - template - constexpr auto find_last_of( - ice::BasicString str, - ice::BasicString character_values, - ice::ucount start_idx = 0 - ) noexcept -> ice::ucount; - - template - constexpr auto find_first_not_of( - ice::BasicString str, - CharType character_value, - ice::ucount start_idx = 0 - ) noexcept -> ice::ucount; - - template - constexpr auto find_first_not_of( - ice::BasicString str, - ice::BasicString character_values, - ice::ucount start_idx = 0 - ) noexcept -> ice::ucount; - - template - constexpr auto find_last_not_of( - ice::BasicString str, - CharType character_value, - ice::ucount start_idx = 0 - ) noexcept -> ice::ucount; - - template - constexpr auto find_last_not_of( - ice::BasicString str, - ice::BasicString character_values, - ice::ucount start_idx = 0 - ) noexcept -> ice::ucount; - - - template requires ice::concepts::RODataObject - constexpr auto from_data(T ro_data) noexcept -> ice::BasicString; - - template requires ice::concepts::RODataObject - constexpr auto from_data(T ro_data, ice::usize offset, ice::ucount size) noexcept -> ice::String; - - template - constexpr auto data_view(ice::BasicString str) noexcept -> typename ice::Data; - - template - constexpr auto meminfo(ice::BasicString str) noexcept -> ice::meminfo; - -} // namespace ice::string - -namespace ice -{ - - using ice::string::size; - using ice::string::begin; - using ice::string::end; - -} // namespace ice - -#include "impl/string.inl" diff --git a/source/code/core/collections/public/ice/string/string_concepts.hxx b/source/code/core/collections/public/ice/string/string_concepts.hxx new file mode 100644 index 00000000..b9ee83e9 --- /dev/null +++ b/source/code/core/collections/public/ice/string/string_concepts.hxx @@ -0,0 +1,77 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include +#include + +namespace ice::concepts +{ + + template + concept SupportedCharType = std::is_same_v + //|| std::is_same_v + || std::is_same_v; + + template + concept SupportedSizeType = std::is_same_v; + + template + concept StringType = SupportedCharType + && SupportedSizeType + && requires(T const& t) + { + typename T::StringType; + typename T::ValueType; + typename T::ConstIterator; + typename T::ConstReverseIterator; + { t.data() } -> std::convertible_to; + { t.size() } -> std::convertible_to; + }; + + template + concept MutableStringType = StringType + && requires(T& t, typename T::SizeType size_value) + { + { t.data() } -> std::convertible_to; + { t.capacity() } -> std::convertible_to; + { t.resize(size_value) } -> std::convertible_to; + }; + + template + concept ResizableStringType = MutableStringType + && requires(T& t, typename T::SizeType capacity_value) + { + { t.set_capacity(capacity_value) } -> std::convertible_to; + }; + +} // namespace ice::concepts + +namespace ice::string::detail +{ + + template + constexpr auto strptr_size(CharType const* str) noexcept -> ice::ncount::base_type + { + ice::ncount::base_type result{}; + if (str != nullptr) + { + CharType const* it = str; + while (*it != CharType{ 0 }) + { + it += 1; + } + + result = static_cast(it - str); + } + return result; + } + +} // namespace string::detail + +namespace ice +{ + + using ice::concepts::StringType; + +} // namespace ice diff --git a/source/code/core/collections/public/ice/string/var_string.hxx b/source/code/core/collections/public/ice/string/var_string.hxx deleted file mode 100644 index da4d1dc5..00000000 --- a/source/code/core/collections/public/ice/string/var_string.hxx +++ /dev/null @@ -1,126 +0,0 @@ -/// Copyright 2022 - 2025, Dandielo -/// SPDX-License-Identifier: MIT - -#pragma once -#include -#include - -namespace ice::string -{ - - template - concept VarStringType = requires(T t) { - typename T::ConstIterator; - std::is_same_v; - { t._data } -> std::convertible_to; - }; - - template - inline void set_capacity(ice::HeapVarString& str, ice::ucount new_capacity) noexcept; - - template - inline void reserve(ice::HeapVarString& str, ice::ucount min_capacity) noexcept; - - template - inline void grow(ice::HeapVarString& str, ice::ucount min_capacity = 0) noexcept; - - template - inline void resize(ice::HeapVarString& str, ice::ucount new_size) noexcept; - - template - inline void shrink(ice::HeapVarString& str) noexcept; - - template - inline void clear(ice::HeapVarString& str) noexcept; - - template - inline void push_back(ice::HeapVarString& str, CharType character) noexcept; - - template - inline void push_back(ice::HeapVarString& str, CharType const* cstr) noexcept; - - template - inline void push_back(ice::HeapVarString& str, ice::HeapVarString const& other) noexcept; - - template - inline void push_back(ice::HeapVarString& str, ice::BasicString cstr) noexcept; - - template - inline void pop_back(ice::HeapVarString& str, ice::ucount count = 1) noexcept; - - - inline auto size(ice::string::VarStringType auto const& str) noexcept -> ice::ucount; - - inline auto capacity(ice::string::VarStringType auto const& str) noexcept -> ice::ucount; - - inline bool empty(ice::string::VarStringType auto const& str) noexcept; - - template - inline auto begin(StringType const& str) noexcept -> typename StringType::ConstIterator; - - template - inline auto end(StringType const& str) noexcept -> typename StringType::ConstIterator; - - template - inline auto rbegin(ice::VarStringBase const& str) noexcept -> typename ice::VarStringBase::ConstReverseIterator; - - template - inline auto rend(ice::VarStringBase const& str) noexcept -> typename ice::VarStringBase::ConstReverseIterator; - - template - inline auto front(ice::VarStringBase const& str) noexcept -> typename ice::VarStringBase::ValueType; - - template - inline auto back(ice::VarStringBase const& str) noexcept -> typename ice::VarStringBase::ValueType; - - template - inline auto substr(ice::VarStringBase const& str, ice::ucount pos, ice::ucount len = ice::String_NPos) noexcept -> ice::BasicString; - - template - inline auto substr_clone(ice::VarStringBase const& str, ice::ucount pos, ice::ucount len = ice::String_NPos) noexcept -> ice::VarStringBase; - - template - inline auto find_first_of(ice::VarStringBase const& str, CharType character_value) noexcept -> ice::ucount; - - template - inline auto find_first_of(ice::VarStringBase const& str, ice::BasicString character_values) noexcept -> ice::ucount; - - template - inline auto find_last_of(ice::VarStringBase const& str, CharType character_value) noexcept -> ice::ucount; - - template - inline auto find_last_of(ice::VarStringBase const& str, ice::BasicString character_values) noexcept -> ice::ucount; - - - inline auto data_view(ice::string::VarStringType auto const& str) noexcept -> ice::Data; - - template - inline auto memory(ice::VarStringBase& str) noexcept -> ice::Memory; - - //! \return Extracts the memory allocated by the heap string. - //! \note The 'size' member contains the 'capacity' of the heap string. - template - inline auto extract_memory(ice::VarStringBase& str) noexcept -> ice::Memory; - - inline auto serialize(ice::string::VarStringType auto const& str, ice::Memory target) noexcept -> ice::Memory; - -} // namespace ice::string - -namespace ice::data -{ - - template - inline auto read_varstring(ice::Data data, ice::VarStringBase& out_str) noexcept -> ice::Data; - -} // namespace ice::data - -namespace ice -{ - - using ice::string::size; - using ice::string::begin; - using ice::string::end; - -} // namespace ice - -#include "impl/var_string.inl" diff --git a/source/code/core/collections/public/ice/string_types.hxx b/source/code/core/collections/public/ice/string_types.hxx index 50985f20..f92fb75a 100644 --- a/source/code/core/collections/public/ice/string_types.hxx +++ b/source/code/core/collections/public/ice/string_types.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -8,229 +8,7 @@ #include #include -namespace ice -{ - - //! \brief Null position used by string iterator types. - static constexpr ice::ucount String_NPos = ice::ucount_max; - - //! \brief Constant string type. - template - struct BasicString - { - using SizeType = ice::ucount; - using ValueType = CharType const; - using ConstIterator = CharType const*; - using ConstReverseIterator = std::reverse_iterator; - - SizeType _size = 0; - ValueType* _data = nullptr; - - constexpr BasicString() noexcept = default; - constexpr BasicString(BasicString&& other) noexcept = default; - constexpr BasicString(BasicString const& other) noexcept = default; - - constexpr BasicString(CharType const* str_ptr) noexcept; - constexpr BasicString(CharType const* str_beg, CharType const* str_end) noexcept; - constexpr BasicString(CharType const* str_ptr, ice::ucount size) noexcept; - template - constexpr BasicString(CharType const(&str_arr)[Size]) noexcept; - constexpr BasicString(std::basic_string_view other) noexcept; - - constexpr auto operator=(BasicString&& other) noexcept -> BasicString& = default; - constexpr auto operator=(BasicString const& other) noexcept -> BasicString& = default; - - constexpr auto operator[](ice::ucount index) const noexcept -> CharType const&; - - constexpr bool operator==(BasicString other) const noexcept; - - constexpr operator std::basic_string_view() const noexcept; - }; - - constexpr auto operator""_str(char const* buffer, size_t size) noexcept -> ice::BasicString; - - //! \brief Constant string type. - using String = ice::BasicString; - using WString = ice::BasicString; - - - using VarStringTag = struct _tagVarString; - - template - struct VarStringBase - { - using TypeTag = VarStringTag; - using ValueType = CharType const; - using ConstIterator = CharType const*; - using ConstReverseIterator = std::reverse_iterator; - - ValueType* _data; - - inline VarStringBase() noexcept; - inline ~VarStringBase() noexcept = default; - - inline explicit VarStringBase(CharType const* data) noexcept; - - inline auto operator[](ice::ucount idx) noexcept -> CharType&; - inline auto operator[](ice::ucount idx) const noexcept -> CharType const&; - - inline operator ice::BasicString() const noexcept; - }; - - using VarString = VarStringBase; - using VarWString = VarStringBase; - - - //! \brief A heap allocated string object. - //! - //! \note Depending on the use case an allocator not related to system heap may be provided. - //! This is still a valid use case. - template - struct HeapString - { - using SizeType = ice::ucount; - using ValueType = CharType; - using Iterator = CharType*; - using ReverseIterator = std::reverse_iterator; - using ConstIterator = CharType const*; - using ConstReverseIterator = std::reverse_iterator; - - ice::Allocator* _allocator; - SizeType _capacity; - SizeType _size; - ValueType* _data; - - inline explicit HeapString(ice::Allocator& allocator) noexcept; - inline HeapString(ice::Allocator& allocator, ice::BasicString string) noexcept; - inline ~HeapString() noexcept; - - inline HeapString(HeapString&& other) noexcept; - inline HeapString(HeapString const& other) noexcept; - - inline auto operator=(HeapString&& other) noexcept -> HeapString&; - inline auto operator=(HeapString const& other) noexcept -> HeapString&; - inline auto operator=(ice::BasicString str) noexcept -> HeapString&; - - inline auto operator[](ice::ucount index) noexcept -> CharType&; - inline auto operator[](ice::ucount index) const noexcept -> CharType const&; - - inline operator ice::BasicString() const noexcept; - }; - - //! \brief A static capacity string object. - //! - //! \note Because the capacity is static some string operations are not implemented or may behave differently. - //! For example, assining a string of length 20 to a static static string of capacity 12, will drop the last 8 characers. - template - struct StaticString - { - using SizeType = ice::ucount; - using ValueType = CharType; - using Iterator = CharType*; - using ReverSeIterator = std::reverse_iterator; - using ConstIterator = CharType const*; - using ConstReverseIterator = std::reverse_iterator; - - static constexpr SizeType Constant_Capacity = Capacity; - - SizeType _size; - ValueType _data[Constant_Capacity]; - - constexpr StaticString() noexcept; - constexpr ~StaticString() noexcept = default; - - constexpr StaticString(ice::BasicString str) noexcept; - - template - constexpr StaticString(CharType const (&str_arr)[ArraySize]) noexcept; - - template - constexpr StaticString(ice::StaticString const& other) noexcept; - - template - constexpr auto operator=(ice::StaticString const& other) noexcept -> StaticString&; - constexpr auto operator=(ice::BasicString str) noexcept -> StaticString&; - - constexpr auto operator[](ice::ucount idx) noexcept -> CharType&; - constexpr auto operator[](ice::ucount idx) const noexcept -> CharType const&; - - constexpr operator ice::BasicString() const noexcept; - }; - - - template - struct HeapVarString - { - using TypeTag = VarStringTag; - using ValueType = CharType; - using Iterator = CharType*; - using ReverSeIterator = std::reverse_iterator; - using ConstIterator = CharType const*; - using ConstReverseIterator = std::reverse_iterator; - - ice::Allocator* _allocator; - ValueType* _data; - - inline explicit HeapVarString(ice::Allocator& alloc) noexcept; - inline HeapVarString(ice::Allocator& allocator, ice::BasicString string) noexcept; - inline ~HeapVarString() noexcept; - - inline HeapVarString(HeapVarString&& other) noexcept; - inline HeapVarString(HeapVarString const& other) noexcept; - - inline auto operator=(HeapVarString&& other) noexcept -> HeapVarString&; - inline auto operator=(HeapVarString const& other) noexcept -> HeapVarString&; - inline auto operator=(ice::BasicString str) noexcept -> HeapVarString&; - - template - inline auto operator=(ice::StaticString const& other) noexcept -> HeapVarString&; - - inline auto operator[](ice::ucount idx) noexcept -> CharType&; - inline auto operator[](ice::ucount idx) const noexcept -> CharType const&; - - inline operator ice::BasicString() const noexcept; - inline operator ice::VarStringBase() const noexcept; - }; - - static_assert(ice::TrivialContainerLogicAllowed); - static_assert(ice::TrivialContainerLogicAllowed); - -} // namespace ice - -namespace ice -{ - - constexpr auto hash(ice::String value) noexcept -> ice::u64 - { - return ice::hash(std::string_view{ value._data, value._size }); - } - - constexpr auto hash32(ice::String value) noexcept -> ice::u32 - { - return ice::hash32(std::string_view{ value._data, value._size }); - } - - constexpr auto stringid(ice::String value) noexcept -> ice::StringID - { - return ice::stringid(value._data, value._size); - } - - template - constexpr auto stringid(ice::StaticString value) noexcept -> ice::StringID - { - return ice::stringid(value._data, value._size); - } - -} // namespace ice - -namespace ice::concepts -{ - - template - concept StringType = std::is_same_v, Type> - || std::is_same_v, Type> - && requires(Type t) { - { t._size } -> std::convertible_to; - }; - -} // namespace ice::concepts +#include +#include +#include +#include diff --git a/source/code/core/collections/public/ice/types/ncount.hxx b/source/code/core/collections/public/ice/types/ncount.hxx new file mode 100644 index 00000000..1dd78548 --- /dev/null +++ b/source/code/core/collections/public/ice/types/ncount.hxx @@ -0,0 +1,73 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include +#include + +namespace ice +{ + + struct ncount_invalid_t; + + struct ncount : public ice::nvalue + { + using nvalue::base_type; + using nvalue::base_signed_type; + using ice::nvalue::operator==; + + // support for allocation sizes + constexpr auto bytes(this ncount self) noexcept -> ice::usize; + + constexpr ncount() noexcept = default; + constexpr ncount(nvalue value) noexcept; + constexpr ncount(base_type value) noexcept; + constexpr ncount(base_type value, base_type width) noexcept; + + // special operators + constexpr bool operator==(this ncount self, ncount_invalid_t) noexcept; + + // implicit type conversions + constexpr operator ice::usize(this ncount self) noexcept { return self.bytes(); } + }; + + struct ncount_invalid_t : ncount {}; + + inline constexpr auto ncount::bytes(this ncount self) noexcept -> ice::usize + { + return { static_cast(self._value) * self._width }; + } + + inline constexpr ncount::ncount(nvalue value) noexcept + : nvalue{ value } + { } + + inline constexpr ncount::ncount(base_type value) noexcept + : nvalue{ 1, static_cast(value) } + { } + + inline constexpr ncount::ncount(base_type value, base_type width) noexcept + : nvalue{ width, static_cast(value) } + { } + + inline constexpr bool ncount::operator==(this ncount self, ncount_invalid_t) noexcept + { + return self._width == 0; + } + + static constexpr ice::ncount ncount_max{ ice::detail::nvalue_max_value() }; + static constexpr ice::ncount ncount_min{ ice::detail::nvalue_min_value() }; + static constexpr ice::ncount_invalid_t ncount_none{ }; + + constexpr auto operator""_count(unsigned long long value) noexcept -> ice::ncount + { + return ice::ncount{ value }; + } + + static constexpr ice::meminfo Test_Meminfo = ice::meminfo_of; + static_assert(Test_Meminfo.size == ice::size_of); + + static constexpr ice::meminfo Test_Meminfo_3 = Test_Meminfo * 3_count; + static_assert(Test_Meminfo_3.size == ice::size_of * 3); + +} // namespace ice diff --git a/source/code/core/collections/public/ice/types/nindex.hxx b/source/code/core/collections/public/ice/types/nindex.hxx new file mode 100644 index 00000000..e87d1354 --- /dev/null +++ b/source/code/core/collections/public/ice/types/nindex.hxx @@ -0,0 +1,63 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include + +namespace ice +{ + + struct nindex_invalid_t; + + struct nindex : public ice::nvalue + { + using nvalue::base_type; + using nvalue::base_signed_type; + using ice::nvalue::operator==; + + // support for allocation sizes + constexpr auto offset(this nindex self) noexcept -> ice::usize; + + constexpr nindex() noexcept = default; + constexpr nindex(nvalue value) noexcept; + constexpr nindex(base_type value) noexcept; + constexpr nindex(base_type value, base_type width) noexcept; + + // special operators + constexpr bool operator==(this ncount self, nindex_invalid_t) noexcept; + }; + + struct nindex_invalid_t : nindex {}; + + inline constexpr auto nindex::offset(this nindex self) noexcept -> ice::usize + { + return { static_cast(self._value) * self._width }; + } + + inline constexpr nindex::nindex(nvalue value) noexcept + : nvalue{ value } + { } + + inline constexpr nindex::nindex(base_type value) noexcept + : nvalue{ 1, static_cast(value) } + { } + + inline constexpr nindex::nindex(base_type value, base_type width) noexcept + : nvalue{ width, static_cast(value) } + { } + + inline constexpr bool nindex::operator==(this ncount self, nindex_invalid_t) noexcept + { + return self._width == 0; + } + + static constexpr ice::nindex nindex_max{ ice::detail::nvalue_max_value() }; + static constexpr ice::nindex nindex_min{ ice::detail::nvalue_min_value() }; + static constexpr ice::nindex_invalid_t nindex_none{ }; + + constexpr auto operator""_index(unsigned long long value) noexcept -> ice::nindex + { + return ice::nindex{ value }; + } + +} // namespace ice diff --git a/source/code/core/collections/public/ice/types/nvalue.hxx b/source/code/core/collections/public/ice/types/nvalue.hxx new file mode 100644 index 00000000..ea03a1b2 --- /dev/null +++ b/source/code/core/collections/public/ice/types/nvalue.hxx @@ -0,0 +1,313 @@ +/// Copyright 2026 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include + +namespace ice +{ + + struct nvalue; + + namespace detail + { + + using nvalue_base_utype = ice::usize::base_type; + using nvalue_base_stype = ice::isize::base_type; + + // utilities + + consteval auto nvalue_min_value() noexcept -> ice::detail::nvalue_base_utype; + consteval auto nvalue_max_value() noexcept -> ice::detail::nvalue_base_utype; + + // Sanity Checks + + static_assert(sizeof(ice::detail::nvalue_base_utype) == sizeof(size_t)); + static_assert(sizeof(ice::detail::nvalue_base_stype) == sizeof(size_t)); + + } // namespace detail + + struct ncount; + struct nindex; + + namespace concepts + { + + template + concept NValueCompatibleType = (std::is_arithmetic_v and not std::is_floating_point_v) + or std::is_same_v + or std::is_same_v + or std::is_same_v; + + } // namespace concepts + +#if ISP_ARCH_BITS == 64 +#define ICE_NVALUE_VALUE_MAX 0x0000'7fff'ffff'ffff +#define ICE_NVALUE_VALUE_FIELD_BITS : 48 +#define ICE_NVALUE_WIDTH_FIELD_BITS : 16 + + static_assert(sizeof(ice::detail::nvalue_base_utype) == 8); + static_assert(sizeof(ice::detail::nvalue_base_stype) == 8); +#elif ISP_ARCH_BITS == 32 +#define ICE_NVALUE_VALUE_MAX 0xffff'ffff +#define ICE_NVALUE_VALUE_FIELD_BITS +#define ICE_NVALUE_WIDTH_FIELD_BITS + + static_assert(sizeof(ice::detail::nvalue_base_utype) == 4); + static_assert(sizeof(ice::detail::nvalue_base_stype) == 4); +#else +# error Unhandled architecture! +#endif + + consteval auto detail::nvalue_min_value() noexcept -> ice::detail::nvalue_base_utype + { + return 0; + } + + consteval auto detail::nvalue_max_value() noexcept -> ice::detail::nvalue_base_utype + { + return ICE_NVALUE_VALUE_MAX; + } + + struct nvalue + { + using base_type = ice::detail::nvalue_base_utype; + using base_signed_type = ice::detail::nvalue_base_stype; + + // NOTE: The '_width' needs to be defined BEFORE value. So the high-bits (that are accessed less frequently) contain + // the '_width' field and the low-bits contain the '_value' field. + // This is to ensure that the compiler does not need to shift the '_value' part every time an operation is done. + ice::detail::nvalue_base_utype _width ICE_NVALUE_WIDTH_FIELD_BITS; + ice::detail::nvalue_base_stype _value ICE_NVALUE_VALUE_FIELD_BITS; + + // Checks if the value is valid. (_width != 0) + template + constexpr bool is_valid(this Self self) noexcept { return static_cast(self._width); } + + template + constexpr auto value_or(this Self self, ice::concepts::NValueCompatibleType auto fallback) noexcept + { + return self.is_valid() ? static_cast>(self.native()) : fallback; + } + + template + constexpr auto min_value_or( + this Self self, + ice::concepts::NValueCompatibleType auto other, + ice::concepts::NValueCompatibleType auto fallback + ) noexcept + { + using ResultType = std::remove_reference_t; + + ResultType const second_value = static_cast(other); + return self.is_valid() ? ice::min(static_cast(self.native()), second_value) : fallback; + } + + // NOTE: In most cases we will use '_width' as a validation field instead of actually using it's value. + // I may come in handy for some operations (ncount -> usize) but it's purpose is to define a concrete 'invalid' state. + constexpr auto native() const noexcept { return static_cast(_value * (_width != 0)); } + constexpr auto u8() const noexcept { return static_cast(native()); } + constexpr auto u16() const noexcept { return static_cast(native()); } + constexpr auto u32() const noexcept { return static_cast(native()); } + constexpr auto u64() const noexcept { return static_cast(native()); } + + // Allow 'nvalue' types collaps to the 'base_type' + constexpr operator base_type(this nvalue self) noexcept { return self.native(); } + + // Equality is has two cases: + // > when deriving from 'nvalue': + // - both sides need to be either invalid or valid and have the same '_value'. + // - the '_width' can be different. + // > when comparing to a regular number: + // - the 'nvalue' needs to be valid and the number has the the same value as '_value' + template + constexpr bool operator==(this Self self, ice::concepts::NValueCompatibleType auto other) noexcept; + + template + constexpr auto operator<=>( + this Self self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> std::strong_ordering; + + // Increments + template + constexpr auto operator++(this Self& self) noexcept -> Self&; + + template + constexpr auto operator++(this Self& self, int) noexcept -> Self; + + template + constexpr auto operator--(this Self& self) noexcept -> Self&; + + template + constexpr auto operator--(this Self& self, int) noexcept -> Self; + + // Arithmetics + template + constexpr auto operator+(this Self self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self; + + template + constexpr auto operator-(this Self self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self; + + template + constexpr auto operator*(this Self self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self; + + template + constexpr auto operator/(this Self self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self; + + template + constexpr auto operator+=(this Self& self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self&; + + template + constexpr auto operator-=(this Self& self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self&; + + template + constexpr auto operator*=(this Self& self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self&; + + template + constexpr auto operator/=(this Self& self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self&; + }; + + template + inline constexpr bool nvalue::operator==( + this Self self, ice::concepts::NValueCompatibleType auto other + ) noexcept + { + if constexpr (std::is_base_of_v) + { +#if 0 // The naive approach (contains jump instructions even after optimization) + return self.is_valid() == other.is_valid() && (self.is_valid() == false || self.native() == other.native()); +#else // The mathematical approach (jump instructions are not present, branch predictor is happy) + return static_cast((self._width * other._width) * (self._value == other._value) + ((self._width + other._width) == 0)); +#endif + } + else + { + return self.native() == other; + } + } + + // (nvalue{W, V} == nvalue{W, V}); + static_assert(nvalue{0, 0} == nvalue{0, 0}, "Invalid values are equal to each other"); + static_assert(nvalue{0, 1} == nvalue{0, 1}, "Invalid values are equal to each other ('_value' is not '0')"); + static_assert(nvalue{1, 0} == nvalue{1, 0}, "Valid values are equal if '_value' is the same."); + static_assert(nvalue{1, 4} == nvalue{2, 4}, "Valid values are equal if '_value' is the same. ('_width' differs)"); + static_assert(nvalue{1, 0} != nvalue{0, 0}, "Valid values are not equal to invalid values. ('_value' is '0' in both)"); + static_assert(nvalue{1, 0} != nvalue{1, 1}, "Valid values are not equal if '_value' differs ('_width' is '1' in both)"); + static_assert(nvalue{1, 1} != nvalue{2, 2}, "Valid values are not equal if '_value' differs ('_width' and '_value' differs)"); + + template + inline constexpr auto nvalue::operator<=>( + this Self self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> std::strong_ordering + { + if constexpr (std::is_base_of_v) + { + return self.native() <=> other.native(); + } + else + { + return self.native() <=> static_cast(other); + } + } + + // Increments + template + constexpr auto nvalue::operator++(this Self& self) noexcept -> Self& + { + self._value += 1; + return self; + } + + template + constexpr auto nvalue::operator++(this Self& self, int) noexcept -> Self + { + const Self old = self; + self._value += 1; + return old; + } + + template + constexpr auto nvalue::operator--(this Self& self) noexcept -> Self& + { + self._value -= 1; + return self; + } + + template + constexpr auto nvalue::operator--(this Self& self, int) noexcept -> Self + { + const Self old = self; + self._value -= 1; + return old; + } + + // Arithmetics + template + inline constexpr auto nvalue::operator+( + this Self self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> Self + { + return Self{ ice::nvalue{ self._width, self._value + static_cast(other) } }; + } + + template + inline constexpr auto nvalue::operator-( + this Self self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> Self + { + return Self{ ice::nvalue{ self._width, self._value - static_cast(other) } }; + } + + template + inline constexpr auto nvalue::operator*( + this Self self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> Self + { + return Self{ ice::nvalue{ self._width, self._value * static_cast(other) } }; + } + + template + inline constexpr auto nvalue::operator/( + this Self self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> Self + { + return Self{ ice::nvalue{ self._width, self._value / static_cast(other) } }; + } + + template + inline constexpr auto nvalue::operator+=( + this Self& self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> Self& + { + self._value += static_cast(other); + return self; + } + + template + inline constexpr auto nvalue::operator-=( + this Self& self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> Self& + { + self._value -= static_cast(other); + return self; + } + + template + inline constexpr auto nvalue::operator*=( + this Self& self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> Self& + { + self._value *= static_cast(other); + return self; + } + + template + inline constexpr auto nvalue::operator/=( + this Self& self, ice::concepts::NValueCompatibleType auto other + ) noexcept -> Self& + { + self._value /= static_cast(other); + return self; + } + +} // namespace ice diff --git a/source/code/core/collections/public/ice/varstring.hxx b/source/code/core/collections/public/ice/varstring.hxx new file mode 100644 index 00000000..fb3a4026 --- /dev/null +++ b/source/code/core/collections/public/ice/varstring.hxx @@ -0,0 +1,145 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include +#include +#include + +namespace ice +{ + + using VarStringTag = struct _tagVarString; + + template + struct VarStringBase : ice::string::ReadOnlyOperations + { + static_assert(sizeof(CharT) == 1, "Wider characters are not supported yet!"); + + using CharType = CharT; + using ValueType = CharType const; + using ConstIterator = ValueType*; + using ConstReverseIterator = std::reverse_iterator; + using Iterator = ConstIterator; + using ReverseIterator = ConstReverseIterator; + using SizeType = ice::ncount; + using StringType = ice::BasicString; + using TypeTag = VarStringTag; + + ValueType* _data; + + inline VarStringBase() noexcept; + inline ~VarStringBase() noexcept = default; + + inline explicit VarStringBase(CharType const* data) noexcept; + + constexpr auto data() const noexcept -> ValueType*; + constexpr auto size() const noexcept -> SizeType; + + inline operator ice::BasicString() const noexcept; + }; + + using VarString = VarStringBase; + //using VarWString = VarStringBase; + + namespace varstring + { + + inline auto calc_required_size(ice::ncount size) noexcept -> ice::usize + { + ice::ncount::base_type temp = size.native(); + ice::usize bytes = 0_B; + while (size > 0x7f) + { + temp >>= 7; + bytes += 1_B; + } + return size.bytes() + bytes + 1_B; + } + + inline auto read_size(char const* data, ice::usize& out_bytes) noexcept -> ice::ncount + { + ice::ncount::base_type result = 0; + if (data != nullptr) + { + ice::u8 const* var_byte = reinterpret_cast(data); + out_bytes = 1_B; + while (*var_byte & 0x80) + { + result += *var_byte; + result <<= 7; + var_byte += 1; + out_bytes += 1_B; + } + result += *var_byte; + } + return ice::ncount{ result, sizeof(char) }; + } + + inline auto read_size(char const* data) noexcept -> ice::ncount + { + ice::usize bytes; + return read_size(data, bytes); + } + + template + inline auto read_data(CharType* data) noexcept -> CharType* + { + ice::usize bytes = 0_B; + if (data == nullptr || read_size(data, bytes) == 0) + { + return nullptr; + } + return data + bytes.value; + } + + inline auto write_size(void* data, ice::ncount size) noexcept -> ice::ncount + { + ice::ncount::base_type temp = size; + ice::nindex byte = 0; + ice::u8* const var_byte = reinterpret_cast(data); + while (size > 0x7f) + { + var_byte[byte] = (size & 0x7f) | 0x80; + temp >>= 7; + byte += 1; + } + var_byte[byte] = size & 0x7f; + return byte + 1; + } + + } // namespace varstring + + template + inline VarStringBase::VarStringBase() noexcept + : _data{ nullptr } + { + } + + template + inline VarStringBase::VarStringBase(CharT const* str_ptr) noexcept + : _data{ str_ptr } + { + } + + template + inline constexpr auto VarStringBase::data() const noexcept -> ValueType* + { + return ice::varstring::read_data(_data); + } + + template + inline constexpr auto VarStringBase::size() const noexcept -> SizeType + { + return ice::varstring::read_size(_data); + } + + template + inline VarStringBase::operator ice::BasicString::CharType>() const noexcept + { + ice::usize bytes = 0; + ice::ncount const size = ice::varstring::read_size(_data, bytes); + return { _data + bytes.value, size }; + } + +} // namespace ice diff --git a/source/code/core/collections/tests/test_array.cxx b/source/code/core/collections/tests/test_array.cxx index 901f63a8..6fc82bd4 100644 --- a/source/code/core/collections/tests/test_array.cxx +++ b/source/code/core/collections/tests/test_array.cxx @@ -1,8 +1,8 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include -#include +#include #include #include #include "util_tracking_object.hxx" @@ -14,32 +14,32 @@ SCENARIO("collections 'ice/container/array.hxx'", "[collection][array][complex]" GIVEN("an empty Array object") { - CHECK(ice::array::empty(objects)); - CHECK(ice::array::any(objects) == false); - CHECK(ice::array::capacity(objects) == 0); - CHECK(ice::array::count(objects) == 0); + CHECK(objects.is_empty()); + CHECK(objects.not_empty() == false); + CHECK(objects.capacity() == 0); + CHECK(objects.size() == 0); // We force a capacity of 1, so we ensure a reallocation in later. - ice::array::set_capacity(objects, 1); + objects.set_capacity(1); WHEN("adding a new object") { - ice::array::push_back(objects, Test_TrackingObject{ }); + objects.push_back(Test_TrackingObject{ }); - REQUIRE(ice::array::capacity(objects) >= 1); - REQUIRE(ice::array::count(objects) == 1); + REQUIRE(objects.capacity() >= 1); + REQUIRE(objects.size() == 1); THEN("constructors are called") { - Test_TrackingObject& obj = ice::array::front(objects); + Test_TrackingObject& obj = objects.first(); CHECK(obj == Test_ObjectEvents{ .test_ctor_move = 1 }); AND_WHEN("we remove the object the destructor is called") { - ice::ucount dtor_val = 0; + ice::u32 dtor_val = 0; obj.data.test_dtor = &dtor_val; - ice::array::pop_back(objects, 1); + objects.pop_back(); CHECK(dtor_val == 1); } @@ -47,24 +47,24 @@ SCENARIO("collections 'ice/container/array.hxx'", "[collection][array][complex]" AND_WHEN("resizing the array") { - Test_TrackingObject& obj = ice::array::front(objects); + Test_TrackingObject& obj = objects.first(); ice::u32 dtor_val = 0; obj.data.test_dtor = &dtor_val; - ice::array::resize(objects, 10); + objects.resize(10); // The old object was moved to a new location (move ctor + dtor) CHECK(dtor_val == 1); - CHECK(ice::array::any(objects)); - CHECK(ice::array::empty(objects) == false); - CHECK(ice::array::capacity(objects) >= 10); - CHECK(ice::array::count(objects) == 10); + CHECK(objects.not_empty()); + CHECK(objects.is_empty() == false); + CHECK(objects.capacity() >= 10); + CHECK(objects.size() == 10); THEN("constructors are called") { - Test_TrackingObject& obj_front = ice::array::front(objects); - Test_TrackingObject& obj_back = ice::array::back(objects); + Test_TrackingObject& obj_front = objects.first(); + Test_TrackingObject& obj_back = objects.last(); CHECK(obj_front == Test_ObjectEvents{ .test_ctor_move = 1 }); CHECK(obj_back == Test_ObjectEvents{ .test_ctor = 1 }); @@ -73,12 +73,12 @@ SCENARIO("collections 'ice/container/array.hxx'", "[collection][array][complex]" AND_THEN("we can copy and push back the same elements") { ice::Array array_copy = objects; - ice::array::push_back(objects, array_copy); + objects.push_back(array_copy); - CHECK(ice::array::capacity(objects) >= 20); - CHECK(ice::array::any(objects)); - CHECK(ice::array::empty(objects) == false); - CHECK(ice::array::count(objects) == 20); + CHECK(objects.capacity() >= 20); + CHECK(objects.not_empty()); + CHECK(objects.is_empty() == false); + CHECK(objects.size() == 20); ice::u32 copied_objects = 0; ice::u32 moved_objects = 0; @@ -98,13 +98,13 @@ SCENARIO("collections 'ice/container/array.hxx'", "[collection][array][complex]" object.data.test_dtor = &dtor_val; } - ice::array::clear(objects); + objects.clear(); CHECK(dtor_val == 20); - CHECK(ice::array::capacity(objects) > 0); - CHECK(ice::array::empty(objects)); - CHECK(ice::array::any(objects) == false); - CHECK(ice::array::count(objects) == 0); + CHECK(objects.capacity() > 0); + CHECK(objects.is_empty()); + CHECK(objects.not_empty() == false); + CHECK(objects.size() == 0); } } @@ -127,10 +127,10 @@ SCENARIO("collections 'ice/container/array.hxx'", "[collection][array][complex]" ice::Array moved_objects = ice::move(objects); CHECK(dtor_val == 0); - CHECK(ice::array::capacity(objects) == 0); - CHECK(ice::array::empty(objects)); - CHECK(ice::array::any(objects) == false); - CHECK(ice::array::count(objects) == 0); + CHECK(objects.capacity() == 0); + CHECK(objects.is_empty()); + CHECK(objects.not_empty() == false); + CHECK(objects.size() == 0); total_events = Test_ObjectEvents{ }; for (Test_TrackingObject const& object : moved_objects) @@ -155,42 +155,42 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod GIVEN("an empty 'plain-old-data' Array") { - REQUIRE(ice::array::empty(objects)); - REQUIRE(ice::array::capacity(objects) == 0); + REQUIRE(objects.is_empty()); + REQUIRE(objects.capacity() == 0); WHEN("one element is pushed") { - ice::array::push_back(objects, test_value_1); + objects.push_back(test_value_1); - CHECK(ice::array::count(objects) == 1); - CHECK(ice::array::any(objects) == true); - CHECK(ice::array::front(objects) == test_value_1); - CHECK(ice::array::back(objects) == test_value_1); + CHECK(objects.size() == 1); + CHECK(objects.not_empty() == true); + CHECK(objects.first() == test_value_1); + CHECK(objects.last() == test_value_1); THEN("one element is poped") { - ice::array::pop_back(objects); + objects.pop_back(); - CHECK(ice::array::count(objects) == 0); - CHECK(ice::array::any(objects) == false); - CHECK(ice::array::empty(objects) == true); + CHECK(objects.size() == 0); + CHECK(objects.not_empty() == false); + CHECK(objects.is_empty() == true); THEN("array is shrunk") { - ice::array::shrink(objects); + objects.shrink(); - REQUIRE(ice::array::count(objects) == 0); - REQUIRE(ice::array::capacity(objects) == 0); + REQUIRE(objects.size() == 0); + REQUIRE(objects.capacity() == 0); } } THEN("10 elements are poped") { - ice::array::pop_back(objects, 10); + objects.pop_back(10); - CHECK(ice::array::count(objects) == 0); - CHECK(ice::array::any(objects) == false); - CHECK(ice::array::empty(objects) == true); + CHECK(objects.size() == 0); + CHECK(objects.not_empty() == false); + CHECK(objects.is_empty() == true); } } @@ -198,46 +198,46 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod { for (ice::i32 i = 0; i < 100; ++i) { - ice::array::push_back(objects, test_value_2 + i); + objects.push_back(test_value_2 + i); } - CHECK(ice::array::count(objects) == 100); - CHECK(ice::array::capacity(objects) >= 100); - CHECK(ice::array::any(objects) == true); - CHECK(ice::array::empty(objects) == false); + CHECK(objects.size() == 100); + CHECK(objects.capacity() >= 100); + CHECK(objects.not_empty() == true); + CHECK(objects.is_empty() == false); - CHECK(ice::array::front(objects) == test_value_2); - CHECK(ice::array::back(objects) == test_value_2 + 99); + CHECK(objects.first() == test_value_2); + CHECK(objects.last() == test_value_2 + 99); THEN("50 elements are poped") { - ice::array::pop_back(objects, 50); + objects.pop_back(50); - CHECK(ice::array::any(objects) == true); - CHECK(ice::array::empty(objects) == false); - REQUIRE(ice::array::count(objects) == 50); + CHECK(objects.not_empty() == true); + CHECK(objects.is_empty() == false); + REQUIRE(objects.size() == 50); THEN("array is shrunk") { - ice::array::shrink(objects); + objects.shrink(); - CHECK(ice::array::any(objects) == true); - CHECK(ice::array::empty(objects) == false); - REQUIRE(ice::array::count(objects) == 50); - REQUIRE(ice::array::capacity(objects) == 50); + CHECK(objects.not_empty() == true); + CHECK(objects.is_empty() == false); + REQUIRE(objects.size() == 50); + REQUIRE(objects.capacity() == 50); } } THEN("array is cleared") { - ice::u32 const saved_capacity = ice::array::capacity(objects); + ice::ncount const saved_capacity = objects.capacity(); - ice::array::clear(objects); + objects.clear(); - CHECK(ice::array::any(objects) == false); - CHECK(ice::array::empty(objects) == true); - REQUIRE(ice::array::count(objects) == 0); - REQUIRE(ice::array::capacity(objects) == saved_capacity); + CHECK(objects.not_empty() == false); + CHECK(objects.is_empty() == true); + REQUIRE(objects.size() == 0); + REQUIRE(objects.capacity() == saved_capacity); } THEN("we can iterate over them") @@ -248,7 +248,7 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod elements_seen += 1; } - CHECK(elements_seen == ice::array::count(objects)); + CHECK(elements_seen == objects.size()); } THEN("we can iterate over a span") @@ -259,7 +259,7 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod elements_seen += 1; } - CHECK(elements_seen == ice::array::count(objects)); + CHECK(elements_seen == objects.size()); } THEN("we can iterate over a const span") @@ -270,20 +270,20 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod elements_seen += 1; } - CHECK(elements_seen == ice::array::count(objects)); + CHECK(elements_seen == objects.size()); } THEN("we can move them") { ice::Array moved_array = ice::move(objects); - CHECK(ice::array::count(moved_array) == 100); + CHECK(moved_array.size() == 100); THEN("we can add new items") { - ice::array::push_back(objects, 100); + objects.push_back(100); - CHECK(ice::array::count(objects) == 1); + CHECK(objects.size() == 1); REQUIRE(objects[0] == 100); } } @@ -295,13 +295,13 @@ SCENARIO("collections 'ice/container/array.hxx' (POD)", "[collection][array][pod moved_array = ice::move(objects); - CHECK(ice::array::count(moved_array) == 100); + CHECK(moved_array.size() == 100); THEN("we can add new items") { - ice::array::push_back(objects, 100); + objects.push_back(100); - CHECK(ice::array::count(objects) == 1); + CHECK(objects.size() == 1); REQUIRE(objects[0] == 100); THEN("we can move again") diff --git a/source/code/core/collections/tests/test_data_memory.cxx b/source/code/core/collections/tests/test_data_memory.cxx index 1a05a97c..2e252b9c 100644 --- a/source/code/core/collections/tests/test_data_memory.cxx +++ b/source/code/core/collections/tests/test_data_memory.cxx @@ -46,10 +46,10 @@ SCENARIO("ice :: Data") ice::Span values_span = values; - data = ice::data_view(values_span); + data = values_span.data_view(); - CHECK(data.location == ice::span::data(values_span)); - CHECK(data.size == ice::span::size_bytes(values_span)); - CHECK(data.alignment == ice::span::alignment(values_span)); + CHECK(data.location == values_span.data()); + CHECK(data.size == values_span.size()); + CHECK(data.alignment == ice::align_of::ValueType>); } } diff --git a/source/code/core/collections/tests/test_hashmap.cxx b/source/code/core/collections/tests/test_hashmap.cxx index 1790b749..753f4530 100644 --- a/source/code/core/collections/tests/test_hashmap.cxx +++ b/source/code/core/collections/tests/test_hashmap.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -33,7 +33,7 @@ SCENARIO("collections 'ice/container/hashmap.hxx'", "[collection][hash][complex] AND_THEN("replacing the object will call destructor") { - ice::ucount dtor_count = 0; + ice::u32 dtor_count = 0; obj->data.test_dtor = &dtor_count; ice::hashmap::set(test_hash, 0, Test_TrackingObject{ 69 }); @@ -75,7 +75,7 @@ SCENARIO("collections 'ice/container/hashmap.hxx'", "[collection][hash][complex] AND_THEN("replacing the objects will call destructors") { - ice::ucount dtor_count = 0; + ice::u32 dtor_count = 0; for (Test_TrackingObject& obj : ice::hashmap::values(test_hash)) { obj.data.test_dtor = &dtor_count; diff --git a/source/code/core/collections/tests/test_heap_string.cxx b/source/code/core/collections/tests/test_heap_string.cxx index d661e73c..b44a0310 100644 --- a/source/code/core/collections/tests/test_heap_string.cxx +++ b/source/code/core/collections/tests/test_heap_string.cxx @@ -1,11 +1,13 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include -#include -#include +#include +#include #include +constexpr char const test[] = "Dandielo"; + SCENARIO("ice :: HeapString") { static constexpr ice::String test_string_value{ "test_string" }; @@ -17,29 +19,29 @@ SCENARIO("ice :: HeapString") ice::HeapString test_string{ alloc }; // Reserve some capacity for tests - ice::string::reserve(test_string, 10); + test_string.reserve(10); - CHECK(ice::string::size(test_string) == 0); - CHECK(ice::string::capacity(test_string) == 10); - CHECK(ice::string::empty(test_string) == true); + CHECK(test_string.size() == 0); + CHECK(test_string.capacity() == 10); + CHECK(test_string.is_empty()); THEN("Assigning a value") { test_string = test_string_value; - ice::ucount const saved_size = ice::string::size(test_string); - ice::ucount const saved_capacity = ice::string::capacity(test_string); + ice::ncount const saved_size = test_string.size(); + ice::ncount const saved_capacity = test_string.capacity(); - CHECK(ice::string::size(test_string) == ice::string::size(test_string_value)); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == test_string_value.size()); + CHECK(test_string.not_empty()); WHEN("Clearing the string") { - ice::string::clear(test_string); + test_string.clear(); - CHECK(ice::string::size(test_string) == 0); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == true); + CHECK(test_string.size() == 0); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.is_empty()); REQUIRE(test_string == ""); } @@ -48,35 +50,35 @@ SCENARIO("ice :: HeapString") { GIVEN("The value is zero") { - ice::string::resize(test_string, 0); + test_string.resize(0); - CHECK(ice::string::size(test_string) == 0); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == true); + CHECK(test_string.size() == 0); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.is_empty()); REQUIRE(test_string == ""); } GIVEN("A smaller value") { - ice::string::resize(test_string, 4); + test_string.resize(4); - CHECK(ice::string::size(test_string) == 4); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 4); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.not_empty()); REQUIRE(test_string == "test"); } GIVEN("A larger value") { - ice::string::resize(test_string, 100); + test_string.resize(100); - CHECK(ice::string::size(test_string) == 100); - CHECK(ice::string::capacity(test_string) > saved_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 100); + CHECK(test_string.capacity() > saved_capacity); + CHECK(test_string.not_empty()); - REQUIRE(ice::string::substr(test_string, 0, saved_size) == test_string_value); + REQUIRE(test_string.substr(0, saved_size) == test_string_value); } } @@ -84,22 +86,22 @@ SCENARIO("ice :: HeapString") { GIVEN("No minimal capacity") { - ice::string::grow(test_string); + test_string.grow(); - CHECK(ice::string::size(test_string) == saved_size); - CHECK(ice::string::capacity(test_string) > saved_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == saved_size); + CHECK(test_string.capacity() > saved_capacity); + CHECK(test_string.not_empty()); REQUIRE(test_string == test_string_value); } GIVEN("A minimal capacity") { - ice::string::grow(test_string, 100); + test_string.grow(100); - CHECK(ice::string::size(test_string) == saved_size); - CHECK(ice::string::capacity(test_string) >= 100); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == saved_size); + CHECK(test_string.capacity() >= 100); + CHECK(test_string.not_empty()); REQUIRE(test_string == test_string_value); } @@ -109,34 +111,34 @@ SCENARIO("ice :: HeapString") { GIVEN("The value is zero") { - ice::string::set_capacity(test_string, 0); + test_string.set_capacity(0); - CHECK(ice::string::size(test_string) == 0); - CHECK(ice::string::capacity(test_string) == 0); - CHECK(ice::string::empty(test_string) == true); + CHECK(test_string.size() == 0); + CHECK(test_string.capacity() == 0); + CHECK(test_string.is_empty()); REQUIRE(test_string == ""); } GIVEN("A smaller value") { - ice::string::set_capacity(test_string, 2); + test_string.set_capacity(2); - CHECK(ice::string::size(test_string) == 1); - CHECK(ice::string::capacity(test_string) == 2); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 1); + CHECK(test_string.capacity() == 2); + CHECK(test_string.not_empty()); - ice::string::resize(test_string, 1); + test_string.resize(1); REQUIRE(test_string == "t"); } GIVEN("A larger value") { - ice::string::set_capacity(test_string, 100); + test_string.set_capacity(100); - CHECK(ice::string::size(test_string) == saved_size); - CHECK(ice::string::capacity(test_string) == 100); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == saved_size); + CHECK(test_string.capacity() == 100); + CHECK(test_string.not_empty()); REQUIRE(test_string == test_string_value); } @@ -146,33 +148,33 @@ SCENARIO("ice :: HeapString") { GIVEN("The value is zero") { - ice::string::reserve(test_string, 0); + test_string.reserve(0); - CHECK(ice::string::size(test_string) == saved_size); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == saved_size); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.not_empty()); REQUIRE(test_string == test_string_value); } GIVEN("A smaller value") { - ice::string::reserve(test_string, 2); + test_string.reserve(2); - CHECK(ice::string::size(test_string) == saved_size); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == saved_size); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.not_empty()); REQUIRE(test_string == test_string_value); } GIVEN("A larger value") { - ice::string::reserve(test_string, 100); + test_string.reserve(100); - CHECK(ice::string::size(test_string) == saved_size); - CHECK(ice::string::capacity(test_string) >= 100); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == saved_size); + CHECK(test_string.capacity() >= 100); + CHECK(test_string.not_empty()); REQUIRE(test_string == test_string_value); } @@ -180,12 +182,12 @@ SCENARIO("ice :: HeapString") WHEN("Triming string memory") { - ice::string::shrink(test_string); + test_string.shrink(); - CHECK(ice::string::size(test_string) == saved_size); - CHECK(ice::string::capacity(test_string) <= saved_capacity); - CHECK(ice::string::capacity(test_string) == 12); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == saved_size); + CHECK(test_string.capacity() <= saved_capacity); + CHECK(test_string.capacity() == 12); + CHECK(test_string.not_empty()); REQUIRE(test_string == test_string_value); } @@ -193,41 +195,41 @@ SCENARIO("ice :: HeapString") THEN("Modyfing the string") { - auto saved_capacity = ice::string::capacity(test_string); + ice::ncount const saved_capacity = test_string.capacity(); WHEN("Appending a character") { - ice::string::push_back(test_string, 'a'); + test_string.push_back('a'); - CHECK(ice::string::size(test_string) == 1); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 1); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.not_empty()); } THEN("Appending a string") { - ice::string::push_back(test_string, "string"); + test_string.push_back("string"); - CHECK(ice::string::size(test_string) == 6); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 6); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.not_empty()); } - ice::string::resize(test_string, 100); + test_string.resize(100); // Fill the new string with space characters. - std::memset(ice::string::begin(test_string), ' ', ice::string::size(test_string)); + std::memset(test_string.begin(), ' ', test_string.size()); ice::HeapString test_copy{ test_string }; // We cannot push back ourselfs, as this will remove the old buffer before it even gets copied - ice::string::push_back(test_string, test_copy); + test_string.push_back(test_copy); THEN("Resizing the string and appending itself") { - CHECK(ice::string::size(test_string) == 200); - CHECK(ice::string::capacity(test_string) >= 201); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 200); + CHECK(test_string.capacity() >= 201); + CHECK(test_string.not_empty()); } //THEN("Poping a single character") @@ -258,32 +260,32 @@ SCENARIO("ice :: HeapString") THEN("we can iterate over it") { - auto it = ice::string::begin(str); - auto const it_end = ice::string::end(str); + auto it = str.begin(); + auto const it_end = str.end(); - ice::ucount character_count = 0; + ice::ncount character_count = 0; while (it != it_end) { it += 1; character_count += 1; } - CHECK(character_count == ice::string::size(test_string_value)); + CHECK(character_count == test_string_value.size()); } THEN("we can reverse iterate over it") { - auto it = ice::string::rbegin(str); - auto const it_end = ice::string::rend(str); + auto it = str.rbegin(); + auto const it_end = str.rend(); - ice::ucount character_count = 0; + ice::ncount character_count = 0; while (it != it_end) { it += 1; character_count += 1; } - CHECK(character_count == ice::string::size(test_string_value)); + CHECK(character_count == test_string_value.size()); } } } diff --git a/source/code/core/collections/tests/test_queue.cxx b/source/code/core/collections/tests/test_queue.cxx index 7d33dabe..4df2ceb1 100644 --- a/source/code/core/collections/tests/test_queue.cxx +++ b/source/code/core/collections/tests/test_queue.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -23,9 +23,9 @@ SCENARIO("collections 'ice/container/queue.hxx'", "[collection][queue][complex]" { queue::resize(test_queue, 5); - ice::ucount dtor_count = 0; + ice::u32 dtor_count = 0; Test_ObjectEvents events{}; - for (ice::ucount idx = 0; idx < queue::count(test_queue); ++idx) + for (ice::u32 idx = 0; idx < queue::count(test_queue); ++idx) { test_queue[idx].gather_ctors(events); test_queue[idx].data.test_dtor = &dtor_count; @@ -67,9 +67,9 @@ SCENARIO("collections 'ice/container/queue.hxx'", "[collection][queue][complex]" CHECK(test_object.value == 42); } - ice::ucount dtor_count = 0; + ice::u32 dtor_count = 0; Test_ObjectEvents events{}; - for (ice::ucount idx = 0; idx < queue::count(test_queue); ++idx) + for (ice::u32 idx = 0; idx < queue::count(test_queue); ++idx) { test_queue[idx].gather_ctors(events); test_queue[idx].data.test_dtor = &dtor_count; @@ -90,8 +90,8 @@ SCENARIO("collections 'ice/container/queue.hxx'", "[collection][queue][complex]" { queue::resize(test_queue, 7); - ice::ucount dtor_count = 0; - for (ice::ucount idx = 0; idx < queue::count(test_queue); ++idx) + ice::u32 dtor_count = 0; + for (ice::u32 idx = 0; idx < queue::count(test_queue); ++idx) { test_queue[idx].data.test_dtor = &dtor_count; } @@ -111,7 +111,7 @@ SCENARIO("collections 'ice/container/queue.hxx'", "[collection][queue][complex]" CHECK(test_queue._offset != 0); CHECK(test_queue._capacity < (test_queue._offset + test_queue._count)); - for (ice::ucount idx = 0; idx < queue::count(test_queue); ++idx) + for (ice::u32 idx = 0; idx < queue::count(test_queue); ++idx) { test_queue[idx].data.test_dtor = &dtor_count; } @@ -183,7 +183,7 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod WHEN("we push 100 elements") { - for (ice::ucount i = 0; i < 100; ++i) + for (ice::u32 i = 0; i < 100; ++i) { queue::push_back(test_queue, 0xd00b); } @@ -197,12 +197,12 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod THEN("popping 50 front elements 'front' at once or one-by-one results in the same queue") { queue::pop_front(test_queue, 50); - for (ice::ucount idx = 0; idx < 50; ++idx) + for (ice::u32 idx = 0; idx < 50; ++idx) { queue::pop_front(test_copy); } - for (ice::ucount idx = 0; idx < ice::queue::count(test_copy); ++idx) + for (ice::u32 idx = 0; idx < ice::queue::count(test_copy); ++idx) { CHECK(test_queue[idx] == test_copy[idx]); } @@ -211,12 +211,12 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod THEN("popping from back 50 elements at once or one-by-one results in the same queue") { queue::pop_back(test_queue, 50); - for (ice::ucount idx = 0; idx < 50; ++idx) + for (ice::u32 idx = 0; idx < 50; ++idx) { queue::pop_back(test_copy); } - for (ice::ucount idx = 0; idx < ice::queue::count(test_copy); ++idx) + for (ice::u32 idx = 0; idx < ice::queue::count(test_copy); ++idx) { CHECK(test_queue[idx] == test_copy[idx]); } @@ -271,7 +271,7 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod AND_THEN("the queue matches test values2") { - for (ice::ucount idx = 0; idx < ice::queue::count(test_queue); ++idx) + for (ice::u32 idx = 0; idx < ice::queue::count(test_queue); ++idx) { CHECK(test_values2[idx] == test_queue[idx]); } @@ -287,7 +287,7 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod CHECK(test_queue._offset != 0); CHECK(queue::count(test_copy) == queue::count(test_queue)); - for (ice::ucount idx = 0; idx < ice::queue::count(test_copy); ++idx) + for (ice::u32 idx = 0; idx < ice::queue::count(test_copy); ++idx) { CHECK(test_queue[idx] == test_copy[idx]); } @@ -319,15 +319,15 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod THEN("Check if we iterate in the proper order over the queue") { - ice::ucount const queue_size = queue::count(test_queue); - for (ice::ucount i = 0; i < queue_size; ++i) + ice::u32 const queue_size = queue::count(test_queue); + for (ice::u32 i = 0; i < queue_size; ++i) { CHECK(test_queue[i] == test_values_2[i]); } WHEN("using 'for_each' we iterate as expected in succession") { - ice::ucount idx = 0; + ice::u32 idx = 0; ice::queue::for_each( test_queue, [&test_values_2, &idx](ice::i32 val) noexcept @@ -340,7 +340,7 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod WHEN("using 'for_each_reverse' we iterate as expected in reverse") { - ice::ucount idx = ice::count(test_values_2) - 1; + ice::u32 idx = ice::count(test_values_2) - 1; ice::queue::for_each_reverse( test_queue, [&test_values_2, &idx](ice::i32 val) noexcept @@ -355,7 +355,7 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod { if constexpr (ice::Allocator::HasDebugInformation) { - ice::ucount const alloc_count = alloc.allocation_total_count(); + ice::u32 const alloc_count = alloc.allocation_total_count(); queue::reserve(test_queue, 100); @@ -369,7 +369,7 @@ SCENARIO("collections 'ice/container/queue.hxx' (POD)", "[collection][queue][pod // Check the queue is still in tact CHECK(queue_size == queue::count(test_queue)); - for (ice::ucount i = 0; i < queue_size; ++i) + for (ice::u32 i = 0; i < queue_size; ++i) { CHECK(test_queue[i] == test_values_2[i]); } diff --git a/source/code/core/collections/tests/test_shard_container.cxx b/source/code/core/collections/tests/test_shard_container.cxx index 7247678e..973659fc 100644 --- a/source/code/core/collections/tests/test_shard_container.cxx +++ b/source/code/core/collections/tests/test_shard_container.cxx @@ -266,7 +266,7 @@ SCENARIO("collections 'ice/shard_container.hxx'", "[shard][collection]") ice::Array payloads{ alloc }; ice::shards::inspect_all(test_container, test_shard_1, payloads); - REQUIRE(ice::array::count(payloads) == 2); + REQUIRE(payloads.size() == 2); CHECK(payloads[0] == test_u32_payload_value1); CHECK(payloads[1] == test_u32_payload_value2); @@ -292,22 +292,22 @@ SCENARIO("collections 'ice/shard_container.hxx'", "[shard][collection]") CHECK(payload == payloads[0]); } - ice::array::clear(payloads); + payloads.clear(); ice::shards::inspect_all(test_container, test_shard_2, payloads); - REQUIRE(ice::array::count(payloads) == 0); + REQUIRE(payloads.size() == 0); - ice::array::clear(payloads); + payloads.clear(); ice::shards::inspect_all(test_container, test_shard_3, payloads); - REQUIRE(ice::array::count(payloads) == 2); + REQUIRE(payloads.size() == 2); CHECK(payloads[0] == test_u32_payload_value2); CHECK(payloads[1] == test_u32_payload_value1); - ice::array::clear(payloads); + payloads.clear(); ice::shards::inspect_all(test_container, test_shard_4, payloads); - REQUIRE(ice::array::count(payloads) == 1); + REQUIRE(payloads.size() == 1); CHECK(payloads[0] == test_u32_payload_value2); } } diff --git a/source/code/core/collections/tests/test_static_string.cxx b/source/code/core/collections/tests/test_static_string.cxx index 77745693..b9b82db7 100644 --- a/source/code/core/collections/tests/test_static_string.cxx +++ b/source/code/core/collections/tests/test_static_string.cxx @@ -1,12 +1,12 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include -#include +#include SCENARIO("ice :: StackString") { - static constexpr ice::ucount test_stack_string_capacity = 64u; + static constexpr ice::ncount test_stack_string_capacity = 64u; static constexpr ice::String test_string_value{ "test_string" }; GIVEN("A an empty String value") @@ -17,105 +17,103 @@ SCENARIO("ice :: StackString") // Reserve some capacity for tests //ice::string::reserve(test_string, 10); = deleted - CHECK(ice::string::size(test_string) == 0); - CHECK(ice::string::capacity(test_string) == test_stack_string_capacity); - CHECK(ice::string::empty(test_string) == true); + CHECK(test_string.size() == 0); + CHECK(test_string.capacity() == test_stack_string_capacity); + CHECK(test_string.is_empty()); THEN("Assigning a value") { test_string = test_string_value; - uint32_t const saved_size = ice::string::size(test_string); - uint32_t const saved_capacity = ice::string::capacity(test_string); + ice::ncount const saved_size = test_string.size(); + ice::ncount const saved_capacity = test_string.capacity(); - CHECK(ice::string::size(test_string) == ice::string::size(test_string_value)); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == test_string_value.size()); + CHECK(test_string.not_empty()); WHEN("Clearing the string") { + test_string.clear(); - ice::string::clear(test_string); - - CHECK(ice::string::size(test_string) == 0); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == true); + CHECK(test_string.size() == 0); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.is_empty()); REQUIRE(test_string == ""); } WHEN("Resizing the string") { - auto saved_capacity_2 = ice::string::capacity(test_string); + ice::ncount const saved_capacity_2 = test_string.capacity(); GIVEN("The value is zero") { - ice::string::resize(test_string, 0); + test_string.resize(0); - CHECK(ice::string::size(test_string) == 0); - CHECK(ice::string::capacity(test_string) == saved_capacity_2); - CHECK(ice::string::empty(test_string) == true); + CHECK(test_string.size() == 0); + CHECK(test_string.capacity() == saved_capacity_2); + CHECK(test_string.is_empty()); REQUIRE(test_string == ""); } GIVEN("A smaller value") { - ice::string::resize(test_string, 4); + test_string.resize(4); - CHECK(ice::string::size(test_string) == 4); - CHECK(ice::string::capacity(test_string) == saved_capacity_2); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 4); + CHECK(test_string.capacity() == saved_capacity_2); + CHECK(test_string.not_empty()); REQUIRE(test_string == "test"); } GIVEN("A larger value") { - ice::string::resize(test_string, 20); + test_string.resize(20); - CHECK(ice::string::size(test_string) == 20); - CHECK(ice::string::capacity(test_string) == saved_capacity_2); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 20); + CHECK(test_string.capacity() == saved_capacity_2); + CHECK(test_string.not_empty()); - REQUIRE(ice::string::substr(test_string, 0, saved_size) == test_string_value); + REQUIRE(test_string.substr(0, saved_size) == test_string_value); } } } THEN("Modyfing the string") { - uint32_t const saved_capacity = ice::string::capacity(test_string); - - ice::string::push_back(test_string, 'a'); + ice::ncount const saved_capacity = test_string.capacity(); + test_string.push_back('a'); WHEN("Appending a character") { - CHECK(ice::string::size(test_string) == 1); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 1); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.not_empty()); } - ice::string::push_back(test_string, "string"); + test_string.push_back("string"); THEN("Appending a string") { - CHECK(ice::string::size(test_string) == 7); - CHECK(ice::string::capacity(test_string) == saved_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 7); + CHECK(test_string.capacity() == saved_capacity); + CHECK(test_string.not_empty()); } - ice::string::resize(test_string, 20); + test_string.resize(20); // Fill the new string with space characters. - memset(ice::string::begin(test_string), ' ', ice::string::size(test_string)); + memset(test_string.begin(), ' ', test_string.size()); - ice::string::push_back(test_string, test_string); + test_string.push_back(test_string); THEN("Resizing the string and appending itself") { - CHECK(ice::string::size(test_string) == 40); - CHECK(ice::string::capacity(test_string) == test_stack_string_capacity); - CHECK(ice::string::empty(test_string) == false); + CHECK(test_string.size() == 40); + CHECK(test_string.capacity() == test_stack_string_capacity); + CHECK(test_string.not_empty()); } //ice::string::pop_back(test_string); diff --git a/source/code/core/collections/tests/util_tracking_object.hxx b/source/code/core/collections/tests/util_tracking_object.hxx index 2207e0dd..4fccea28 100644 --- a/source/code/core/collections/tests/util_tracking_object.hxx +++ b/source/code/core/collections/tests/util_tracking_object.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -8,15 +8,15 @@ struct Test_ObjectEvents { - ice::ucount test_ctor; - ice::ucount test_ctor_def; - ice::ucount test_ctor_move; - ice::ucount test_ctor_copy; + ice::u32 test_ctor; + ice::u32 test_ctor_def; + ice::u32 test_ctor_move; + ice::u32 test_ctor_copy; - ice::ucount test_op_move; - ice::ucount test_op_copy; + ice::u32 test_op_move; + ice::u32 test_op_copy; - ice::ucount* test_dtor = nullptr; + ice::u32* test_dtor = nullptr; }; bool operator==(Test_ObjectEvents const& lhs, Test_ObjectEvents const& rhs) noexcept; diff --git a/source/code/core/core/public/ice/base.hxx b/source/code/core/core/public/ice/base.hxx index 35a9be6a..65edee89 100644 --- a/source/code/core/core/public/ice/base.hxx +++ b/source/code/core/core/public/ice/base.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -121,7 +121,7 @@ namespace ice template using member_result_type_t = typename member_info::result_type; - template + template using member_arg_type_t = std::tuple_element_t::argument_types>; template diff --git a/source/code/core/core/public/ice/constants.hxx b/source/code/core/core/public/ice/constants.hxx index fad9d069..133d9b67 100644 --- a/source/code/core/core/public/ice/constants.hxx +++ b/source/code/core/core/public/ice/constants.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -22,8 +22,8 @@ namespace ice constexpr ice::u32 const u32_min = std::numeric_limits::min(); constexpr ice::u64 const u64_min = std::numeric_limits::min(); - constexpr ice::ucount const ucount_min = std::numeric_limits::min(); - constexpr ice::icount const icount_min = std::numeric_limits::min(); + //constexpr ice::ncount const ncount_min = std::numeric_limits::min(); + //constexpr ice::nindex const nindex_min = std::numeric_limits::min(); // Max values constexpr ice::f32 const f32_max = std::numeric_limits::max(); @@ -37,8 +37,8 @@ namespace ice constexpr ice::u32 const u32_max = std::numeric_limits::max(); constexpr ice::u64 const u64_max = std::numeric_limits::max(); - constexpr ice::ucount const ucount_max = std::numeric_limits::max(); - constexpr ice::icount const icount_max = std::numeric_limits::max(); + //constexpr ice::ucount const ucount_max = std::numeric_limits::max(); + //constexpr ice::icount const icount_max = std::numeric_limits::max(); // Special floating point values constexpr ice::f32 const f32_inf = std::numeric_limits::infinity(); diff --git a/source/code/core/core/public/ice/profiler.hxx b/source/code/core/core/public/ice/profiler.hxx index 593cc0d5..6d4147fe 100644 --- a/source/code/core/core/public/ice/profiler.hxx +++ b/source/code/core/core/public/ice/profiler.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -23,18 +23,18 @@ # define IPT_ZONE_SCOPED ZoneScoped # define IPT_ZONE_SCOPED_NAMED( ... ) ZoneScopedN( __VA_ARGS__ ) -# define IPT_ZONE_NAME_STR( str ) ZoneName( ice::string::begin(str), ice::string::size(str) ) +# define IPT_ZONE_NAME_STR( str ) ZoneName( str.begin(), str.size() ) # define IPT_ZONE_TEXT( txt, size ) ZoneText( txt, size ) -# define IPT_ZONE_TEXT_STR( str ) IPT_ZONE_TEXT( ice::string::begin(str), ice::string::size(str) ) +# define IPT_ZONE_TEXT_STR( str ) IPT_ZONE_TEXT( str.begin(), str.size() ) # define IPT_ALLOC( ptr, size ) TracyAlloc( ptr, size ) # define IPT_DEALLOC( ptr ) TracyFree( ptr ) -# define IPT_ALLOC_POOL( ptr, size, name ) TracyAllocN( ptr, size, ice::string::begin(name) ) -# define IPT_DEALLOC_POOL( ptr, name ) TracyFreeN( ptr, ice::string::begin(name) ) +# define IPT_ALLOC_POOL( ptr, size, name ) TracyAllocN( ptr, size, name.begin() ) +# define IPT_DEALLOC_POOL( ptr, name ) TracyFreeN( ptr, name.begin() ) # define IPT_MESSAGE( txt ) TracyMessage( txt, ice::count(txt) ) -# define IPT_MESSAGE_STR( txt ) TracyMessage( ice::string::begin(txt), ice::string::size(txt) ) +# define IPT_MESSAGE_STR( txt ) TracyMessage( txt.begin(), txt.size() ) # if defined(TRACY_FIBERS) diff --git a/source/code/core/core/public/ice/types.hxx b/source/code/core/core/public/ice/types.hxx index 233a0f52..a4d5bc26 100644 --- a/source/code/core/core/public/ice/types.hxx +++ b/source/code/core/core/public/ice/types.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -28,29 +28,10 @@ namespace ice using uptr = std::uintptr_t; - // Declaration of ref types - - //! \brief Holds 'offset' and 'size' fields (u32) to access data stored in a buffer-like object. - using ref32 = struct { ice::u32 offset; ice::u32 size; }; - - //! \brief Holds 'offset' and 'size' fields (u16) to access data stored in a buffer-like object. - struct ref16 - { - ice::u16 offset; - ice::u16 size; - - constexpr operator ice::ref32() const noexcept { return ref32{ offset, size }; } - }; - - //! \brief Holds 'offset' and 'size' fields (u8) to access data stored in a buffer-like object. - struct ref8 - { - ice::u8 offset; - ice::u8 size; - - constexpr operator ice::ref16() const noexcept { return ref16{ offset, size }; } - constexpr operator ice::ref32() const noexcept { return ref32{ offset, size }; } - }; + // Forward declaration of ref types + struct ref8; + struct ref16; + struct ref32; // Forward declaration of time-types struct Ts; diff --git a/source/code/core/core/public/ice/types/ref.hxx b/source/code/core/core/public/ice/types/ref.hxx new file mode 100644 index 00000000..37d78509 --- /dev/null +++ b/source/code/core/core/public/ice/types/ref.hxx @@ -0,0 +1,36 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + +#pragma once +#include + +namespace ice +{ + + //! \brief Holds 'offset' and 'size' fields (u32) to access data stored in a buffer-like object. + struct ref32 + { + ice::u32 offset; + ice::u32 size; + }; + + //! \brief Holds 'offset' and 'size' fields (u16) to access data stored in a buffer-like object. + struct ref16 + { + ice::u16 offset; + ice::u16 size; + + constexpr operator ice::ref32() const noexcept { return { offset, size }; } + }; + + //! \brief Holds 'offset' and 'size' fields (u8) to access data stored in a buffer-like object. + struct ref8 + { + ice::u8 offset; + ice::u8 size; + + constexpr operator ice::ref16() const noexcept { return { offset, size }; } + constexpr operator ice::ref32() const noexcept { return { offset, size }; } + }; + +} // namespace ice diff --git a/source/code/core/core/public/ice/types_extended.hxx b/source/code/core/core/public/ice/types_extended.hxx index 807a8cc9..c453cc0b 100644 --- a/source/code/core/core/public/ice/types_extended.hxx +++ b/source/code/core/core/public/ice/types_extended.hxx @@ -1,13 +1,6 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include - -namespace ice -{ - - using ucount = ice::u32; - using icount = ice::i32; - -} // namespace ice +#include diff --git a/source/code/core/core/public/ice/utility.hxx b/source/code/core/core/public/ice/utility.hxx index 6fbea2f1..5a21699e 100644 --- a/source/code/core/core/public/ice/utility.hxx +++ b/source/code/core/core/public/ice/utility.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -7,6 +7,24 @@ namespace ice { + // Const utlities (deducing-this helpers) + template + struct const_correct + { + using type = ValueT; + }; + + template + struct const_correct + { + using type = std::add_const_t; + }; + + template + using const_correct_t = typename ice::const_correct::type; + + // Tuple utilities + using std::tuple; template diff --git a/source/code/core/devui/private/devui_imgui.cxx b/source/code/core/devui/private/devui_imgui.cxx index e407f187..a4661be9 100644 --- a/source/code/core/devui/private/devui_imgui.cxx +++ b/source/code/core/devui/private/devui_imgui.cxx @@ -1,8 +1,8 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include -#include +#include #include namespace ice::detail @@ -27,14 +27,14 @@ namespace ice::detail if ((data->EventFlag & ImGuiInputTextFlags_CallbackResize) == ImGuiInputTextFlags_CallbackResize) { - ICE_ASSERT_CORE(ice::string::begin(*str) == data->Buf); - if (ice::string::capacity(*str) <= ice::ucount(data->BufTextLen)) + ICE_ASSERT_CORE(str->begin() == data->Buf); + if (str->capacity() <= data->BufTextLen) { - ice::string::grow(*str, data->BufSize); + str->grow(data->BufSize); } - ice::string::resize(*str, data->BufTextLen); - data->Buf = ice::string::begin(*str); + str->resize(data->BufTextLen); + data->Buf = str->begin(); } return 0; } @@ -61,12 +61,12 @@ namespace ImGui bool InputText(ice::String label, ice::HeapString<>& out_string, ImGuiInputTextFlags flags) noexcept { - ice::string::reserve(out_string, 1); + out_string.reserve(1); return ImGui::InputText( - ice::string::begin(label), - ice::string::begin(out_string), - ice::string::capacity(out_string), + label.begin(), + out_string.begin(), + out_string.capacity(), flags | ImGuiInputTextFlags_CallbackResize, ice::detail::textinput_heapstring_callback, ice::addressof(out_string) diff --git a/source/code/core/devui/public/ice/devui_context.hxx b/source/code/core/devui/public/ice/devui_context.hxx index e1b668dc..be62b0f5 100644 --- a/source/code/core/devui/public/ice/devui_context.hxx +++ b/source/code/core/devui/public/ice/devui_context.hxx @@ -1,11 +1,11 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include #include -#include +#include #include namespace ice diff --git a/source/code/core/devui/public/ice/devui_imgui.hxx b/source/code/core/devui/public/ice/devui_imgui.hxx index 12721d00..f37d59de 100644 --- a/source/code/core/devui/public/ice/devui_imgui.hxx +++ b/source/code/core/devui/public/ice/devui_imgui.hxx @@ -1,8 +1,8 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include #include @@ -22,17 +22,17 @@ namespace ImGui inline bool Begin(ice::String name, bool* inout_open = nullptr, ImGuiWindowFlags flags = 0) noexcept { - return ImGui::Begin(ice::string::begin(name), inout_open, flags); + return ImGui::Begin(name.begin(), inout_open, flags); } inline bool BeginListBox(ice::String label, ice::vec2f size = {}) noexcept { - return ImGui::BeginListBox(ice::string::begin(label), ImVec2{ size.x, size.y }); + return ImGui::BeginListBox(label.begin(), ImVec2{ size.x, size.y }); } inline void TextUnformatted(ice::String text) noexcept { - ImGui::TextUnformatted(ice::string::begin(text), ice::string::end(text)); + ImGui::TextUnformatted(text.begin(), text.end()); } inline bool Selectable( @@ -42,7 +42,7 @@ namespace ImGui ice::vec2f size = {} ) noexcept { - return ImGui::Selectable(ice::begin(label), selected, flags, ImVec2{ size.x, size.y }); + return ImGui::Selectable(label.begin(), selected, flags, ImVec2{ size.x, size.y }); } // Extensions diff --git a/source/code/core/devui/public/ice/devui_module.hxx b/source/code/core/devui/public/ice/devui_module.hxx index dbabea72..593402f1 100644 --- a/source/code/core/devui/public/ice/devui_module.hxx +++ b/source/code/core/devui/public/ice/devui_module.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include namespace ice::api diff --git a/source/code/core/devui/public/ice/devui_widget.hxx b/source/code/core/devui/public/ice/devui_widget.hxx index 73767e9d..0afb6d8e 100644 --- a/source/code/core/devui/public/ice/devui_widget.hxx +++ b/source/code/core/devui/public/ice/devui_widget.hxx @@ -1,9 +1,9 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include namespace ice { diff --git a/source/code/core/memsys/private/mem.cxx b/source/code/core/memsys/private/mem.cxx index 20b19639..a8509619 100644 --- a/source/code/core/memsys/private/mem.cxx +++ b/source/code/core/memsys/private/mem.cxx @@ -94,6 +94,11 @@ namespace ice return std::memcpy(dest, source, size.value); } + auto memcpy(void* dest, ice::Data source) noexcept -> void* + { + return std::memcpy(dest, source.location, source.size.value); + } + auto memcpy(ice::Memory memory, ice::Data data) noexcept -> ice::Memory { ICE_ASSERT_CORE(memory.alignment >= data.alignment); diff --git a/source/code/core/memsys/private/mem_allocator_forward.cxx b/source/code/core/memsys/private/mem_allocator_forward.cxx index 72f6300a..d39d29df 100644 --- a/source/code/core/memsys/private/mem_allocator_forward.cxx +++ b/source/code/core/memsys/private/mem_allocator_forward.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -13,7 +13,7 @@ namespace ice void* _end; // Only used for tracking of deallocations, do not use to calculate pointers! - ice::ucount _alloc_count; + ice::u32 _alloc_count; MemoryBucket* _next; @@ -28,7 +28,7 @@ namespace ice static auto alloc_buckets( ice::Allocator& alloc, ice::ForwardAllocatorParams const& params, - ice::ucount count + ice::u32 count ) noexcept -> MemoryBucket*; }; @@ -79,7 +79,7 @@ namespace ice void ForwardAllocator::reset() noexcept { - ice::ucount skipped_bucket_count = 0; + ice::u32 skipped_bucket_count = 0; MemoryBucket* new_list = nullptr; while (_buckets != nullptr) @@ -208,7 +208,7 @@ namespace ice auto ForwardAllocator::MemoryBucket::alloc_buckets( ice::Allocator& alloc, ice::ForwardAllocatorParams const& params, - ice::ucount count + ice::u32 count ) noexcept -> MemoryBucket* { MemoryBucket* result = nullptr; diff --git a/source/code/core/memsys/private/mem_allocator_snake.cxx b/source/code/core/memsys/private/mem_allocator_snake.cxx index 1b289a72..83488b6d 100644 --- a/source/code/core/memsys/private/mem_allocator_snake.cxx +++ b/source/code/core/memsys/private/mem_allocator_snake.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -23,9 +23,9 @@ namespace ice return reinterpret_cast(ice::ptr_add(entries, bucket_size * idx)); } - static auto count_entries(ice::usize block_size, ice::usize bucket_size) noexcept -> ice::ucount + static auto count_entries(ice::usize block_size, ice::usize bucket_size) noexcept -> ice::u32 { - return ice::ucount(block_size.value / bucket_size.value); + return ice::u32(block_size.value / bucket_size.value); } }; @@ -36,7 +36,7 @@ namespace ice { using Entry = ChainBlock::Entry; - Chain(ice::usize base_block_size, ice::ucount capacity, ice::usize base_size) noexcept + Chain(ice::usize base_block_size, ice::u32 capacity, ice::usize base_size) noexcept : _capacity{ capacity } , _count{ capacity } , block_size{ base_block_size + ice::size_of * Entry::count_entries(base_block_size, base_size) } @@ -113,13 +113,13 @@ namespace ice return false; } - ice::ucount const _capacity; - ice::ucount _count = 0; + ice::u32 const _capacity; + ice::u32 _count = 0; ice::usize const block_size; ice::usize const block_bucket_size; - ice::ucount const block_bucket_count; - ice::ucount const total_bucket_count; + ice::u32 const block_bucket_count; + ice::u32 const total_bucket_count; // NOTE: We run into false sharing here but for now it's not an issue. std::atomic_uint32_t allocated = 0; @@ -227,7 +227,7 @@ namespace ice _blocks = _backing_allocator.allocate(params.bucket_sizes.size() * params.chain_capacity); ice::memset(_blocks, 0, sizeof(ChainBlock) * params.bucket_sizes.size() * params.chain_capacity); - ice::ucount block_offset = 0; + ice::u32 block_offset = 0; for (ice::u32 chain_idx = 0; chain_idx < params.bucket_sizes.size(); ++chain_idx) { // Size is not a power of 2 diff --git a/source/code/core/memsys/public/ice/mem.hxx b/source/code/core/memsys/public/ice/mem.hxx index 5f16fa64..9e7cb10a 100644 --- a/source/code/core/memsys/public/ice/mem.hxx +++ b/source/code/core/memsys/public/ice/mem.hxx @@ -39,7 +39,9 @@ namespace ice void release_aligned(void* pointer) noexcept; auto memcpy(void* dest, void const* source, ice::usize size) noexcept -> void*; + auto memcpy(void* dest, ice::Data source) noexcept -> void*; auto memcpy(ice::Memory memory, ice::Data data) noexcept -> ice::Memory; + auto memset(ice::Memory memory, ice::u8 value) noexcept -> ice::Memory; constexpr AllocRequest::AllocRequest(ice::usize size, ice::ualign alignment) noexcept diff --git a/source/code/core/memsys/public/ice/mem_allocator_forward.hxx b/source/code/core/memsys/public/ice/mem_allocator_forward.hxx index 6c4f04d2..b06b6cc3 100644 --- a/source/code/core/memsys/public/ice/mem_allocator_forward.hxx +++ b/source/code/core/memsys/public/ice/mem_allocator_forward.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -13,7 +13,7 @@ namespace ice ice::usize bucket_size = 1_KiB; //! \brief The number of empty buckets allocated. - ice::ucount min_bucket_count = 1; + ice::u32 min_bucket_count = 1; }; struct ForwardAllocator : public ice::Allocator diff --git a/source/code/core/memsys/public/ice/mem_allocator_snake.hxx b/source/code/core/memsys/public/ice/mem_allocator_snake.hxx index a294fe30..57ad88d4 100644 --- a/source/code/core/memsys/public/ice/mem_allocator_snake.hxx +++ b/source/code/core/memsys/public/ice/mem_allocator_snake.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -13,7 +13,7 @@ namespace ice static constexpr ice::usize Constant_DefaultBlockSizes[]{ 32_KiB }; static constexpr ice::usize Constant_DefaultBucketSizes[]{ 256_KiB }; - ice::ucount chain_capacity = 4; + ice::u32 chain_capacity = 4; std::span block_sizes = Constant_DefaultBlockSizes; diff --git a/source/code/core/memsys/public/ice/mem_allocator_utils.hxx b/source/code/core/memsys/public/ice/mem_allocator_utils.hxx index b78ff5b3..c614a874 100644 --- a/source/code/core/memsys/public/ice/mem_allocator_utils.hxx +++ b/source/code/core/memsys/public/ice/mem_allocator_utils.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/memsys/public/ice/mem_data.hxx b/source/code/core/memsys/public/ice/mem_data.hxx index ac1d4d9e..73c544d9 100644 --- a/source/code/core/memsys/public/ice/mem_data.hxx +++ b/source/code/core/memsys/public/ice/mem_data.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -93,7 +93,7 @@ namespace ice return source; } - template + template requires (std::is_trivially_copyable_v && !std::is_pointer_v) inline auto read_raw_array(ice::Data source, T(&out_array)[Size]) noexcept -> ice::Data { diff --git a/source/code/core/memsys/public/ice/mem_initializers.hxx b/source/code/core/memsys/public/ice/mem_initializers.hxx index bea950c1..9f8b791a 100644 --- a/source/code/core/memsys/public/ice/mem_initializers.hxx +++ b/source/code/core/memsys/public/ice/mem_initializers.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -8,18 +8,31 @@ namespace ice { + template + auto mem_construct_at(void* memory_ptr, Args&&... args) noexcept -> T* + { + // TODO: Assert (align + size) + return new (memory_ptr) T{ ice::forward(args)... }; + } + template auto mem_construct_at(ice::Memory memory, Args&&... args) noexcept -> T* { // TODO: Assert (align + size) - return new (memory.location) T{ ice::forward(args)... }; + return mem_construct_at(memory.location, ice::forward(args)...); + } + + template + auto mem_move_construct_at(void* memory_ptr, T&& other) noexcept -> T* + { + return new (memory_ptr) T{ ice::move(other) }; } template auto mem_move_construct_at(ice::Memory memory, T&& other) noexcept -> T* { // TODO: Assert (align + size) - return new (memory.location) T{ ice::move(other) }; + return mem_move_construct_at(memory.location, ice::move(other)); } template @@ -30,11 +43,11 @@ namespace ice } template - auto mem_construct_n_at(ice::Memory memory, ice::ucount count) noexcept -> T* + auto mem_default_construct_n_at(ice::Memory memory, ice::u64 count) noexcept -> T* { // TODO: Assert (align + size) T* target_mem = reinterpret_cast(memory.location); - for (ice::ucount idx = 0; idx < count; ++idx) + for (ice::u64 idx = 0; idx < count; ++idx) { new (target_mem + idx) T{ }; } @@ -42,11 +55,11 @@ namespace ice } template - auto mem_move_construct_n_at(ice::Memory memory, T* objects, ice::ucount count) noexcept -> T* + auto mem_move_construct_n_at(ice::Memory memory, T* objects, ice::u64 count) noexcept -> T* { // TODO: Assert (align + size) T* target_mem = reinterpret_cast(memory.location); - for (ice::ucount idx = 0; idx < count; ++idx) + for (ice::u64 idx = 0; idx < count; ++idx) { new (target_mem + idx) T{ ice::move(objects[idx]) }; } @@ -54,9 +67,9 @@ namespace ice } template - auto mem_move_n_to(T* target_objects, T* objects, ice::ucount count) noexcept -> T* + auto mem_move_n_to(T* target_objects, T* objects, ice::u64 count) noexcept -> T* { - for (ice::ucount idx = 0; idx < count; ++idx) + for (ice::u64 idx = 0; idx < count; ++idx) { target_objects[idx] = ice::move(objects[idx]); } @@ -64,17 +77,30 @@ namespace ice } template - auto mem_copy_construct_n_at(ice::Memory memory, T const* objects, ice::ucount count) noexcept -> T* + auto mem_copy_construct_n_at(ice::Memory memory, T const* objects, ice::u64 count) noexcept -> T* { // TODO: Assert (align + size) T* target_mem = reinterpret_cast(memory.location); - for (ice::ucount idx = 0; idx < count; ++idx) + for (ice::u64 idx = 0; idx < count; ++idx) { new (target_mem + idx) T{ objects[idx] }; } return target_mem; } + template + auto mem_copy_construct_it_at(ice::Memory memory, ItT begin, ItT end) noexcept -> T* + { + T* const target_mem = reinterpret_cast(memory.location); + ice::u64 idx = 0; + while (begin != end) + { + new (target_mem + idx) T{ *begin }; + begin += 1; + idx += 1; + } + return target_mem; + } template @@ -84,9 +110,9 @@ namespace ice } template - void mem_destruct_n_at(T* location, ice::ucount count) noexcept + void mem_destruct_n_at(T* location, ice::u64 count) noexcept { - for (ice::ucount idx = 0; idx < count; ++idx) + for (ice::u64 idx = 0; idx < count; ++idx) { ice::mem_destruct_at(location + idx); } diff --git a/source/code/core/memsys/public/ice/mem_utils.hxx b/source/code/core/memsys/public/ice/mem_utils.hxx index 4f287c90..80433319 100644 --- a/source/code/core/memsys/public/ice/mem_utils.hxx +++ b/source/code/core/memsys/public/ice/mem_utils.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -9,18 +9,18 @@ namespace ice { - constexpr auto mem_max_capacity(ice::usize element_size, ice::usize memory_space) noexcept -> ice::ucount; + constexpr auto mem_max_capacity(ice::usize element_size, ice::usize memory_space) noexcept -> ice::u64; template - constexpr auto mem_max_capacity(ice::usize memory_space) noexcept -> ice::ucount; + constexpr auto mem_max_capacity(ice::usize memory_space) noexcept -> ice::u64; - constexpr auto mem_max_capacity(ice::usize element_size, ice::usize memory_space) noexcept -> ice::ucount + constexpr auto mem_max_capacity(ice::usize element_size, ice::usize memory_space) noexcept -> ice::u64 { - return static_cast(memory_space.value / element_size.value); + return ice::u64{ memory_space.value / element_size.value }; } template - constexpr auto mem_max_capacity(ice::usize memory_space) noexcept -> ice::ucount + constexpr auto mem_max_capacity(ice::usize memory_space) noexcept -> ice::u64 { return ice::mem_max_capacity(ice::size_of, memory_space); } diff --git a/source/code/core/modules/private/module_globals.cxx b/source/code/core/modules/private/module_globals.cxx index 478aa8a8..aaaf1fc3 100644 --- a/source/code/core/modules/private/module_globals.cxx +++ b/source/code/core/modules/private/module_globals.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -10,9 +10,9 @@ namespace ice auto load_global_modules( ice::Allocator& alloc, ice::ModuleRegister& modules_register - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { - ice::ucount loaded_modules = 0; + ice::u32 loaded_modules = 0; ice::ModulesEntry const* module_entry = Global_ModulesList; while(module_entry != nullptr) diff --git a/source/code/core/modules/private/module_native.cxx b/source/code/core/modules/private/module_native.cxx index 57e9ec35..2e69033c 100644 --- a/source/code/core/modules/private/module_native.cxx +++ b/source/code/core/modules/private/module_native.cxx @@ -1,8 +1,8 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "module_native.hxx" -#include +#include #include namespace ice::native_module @@ -12,22 +12,22 @@ namespace ice::native_module bool utf8_to_wide_append_module(ice::String path, ice::HeapString& out_str) noexcept { - ice::i32 const required_size = MultiByteToWideChar(CP_UTF8, 0, ice::string::begin(path), ice::string::size(path), NULL, 0); + ice::i32 const required_size = MultiByteToWideChar(CP_UTF8, 0, path.begin(), path.size().u32(), NULL, 0); if (required_size != 0) { - ice::u32 const current_size = ice::string::size(out_str); - ice::u32 const total_size = static_cast(required_size) + ice::string::size(out_str); - ice::string::resize(out_str, total_size); + ice::ncount const current_size = out_str.size(); + ice::ncount const total_size = current_size + required_size; + out_str.resize(total_size); [[maybe_unused]] ice::i32 const chars_written = MultiByteToWideChar( CP_UTF8, 0, - ice::string::begin(path), - ice::string::size(path), - ice::string::begin(out_str) + current_size, - ice::string::size(out_str) - current_size + path.begin(), + path.size().u32(), + out_str.begin() + current_size, + (out_str.size() - current_size).u32() ); } @@ -40,7 +40,7 @@ namespace ice::native_module ice::HeapString wide_path{ temp_alloc }; if (utf8_to_wide_append_module(path, wide_path)) { - return ice::native_module::ModuleHandle{ LoadLibraryExW(ice::string::begin(wide_path), NULL, NULL) }; + return ice::native_module::ModuleHandle{ LoadLibraryExW(wide_path.begin(), NULL, NULL) }; } return {}; } @@ -52,7 +52,7 @@ namespace ice::native_module auto module_find_address(ice::native_module::ModuleHandle const& module, ice::String symbol_name) noexcept -> void* { - return ::GetProcAddress(module.native(), ice::string::begin(symbol_name)); + return ::GetProcAddress(module.native(), symbol_name.begin()); } #elif ISP_UNIX diff --git a/source/code/core/modules/private/module_native.hxx b/source/code/core/modules/private/module_native.hxx index 7ebcec4f..29876085 100644 --- a/source/code/core/modules/private/module_native.hxx +++ b/source/code/core/modules/private/module_native.hxx @@ -1,9 +1,9 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include namespace ice::native_module { diff --git a/source/code/core/modules/private/module_register.cxx b/source/code/core/modules/private/module_register.cxx index faeba98f..18bdcb60 100644 --- a/source/code/core/modules/private/module_register.cxx +++ b/source/code/core/modules/private/module_register.cxx @@ -1,10 +1,10 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include -#include +#include #include -#include +#include #include #include #include @@ -33,7 +33,7 @@ namespace ice static bool from_app(ModuleNegotiatorAPIContext*) noexcept; static bool get_module_api(ModuleNegotiatorAPIContext*, ice::StringID_Hash, ice::u32, ice::ModuleAPI*) noexcept; - static bool get_module_apis(ModuleNegotiatorAPIContext*, ice::StringID_Hash, ice::u32, ice::ModuleAPI*, ice::ucount*) noexcept; + static bool get_module_apis(ModuleNegotiatorAPIContext*, ice::StringID_Hash, ice::u32, ice::ModuleAPI*, ice::u32*) noexcept; static bool register_module(ModuleNegotiatorAPIContext*, ice::StringID_Hash, FnModuleSelectAPI*) noexcept; }; @@ -58,13 +58,13 @@ namespace ice auto api_count( ice::StringID_Arg name, ice::u32 version - ) const noexcept -> ice::ucount; + ) const noexcept -> ice::u32; bool query_apis( ice::StringID_Arg api_name, ice::u32 version, ice::ModuleAPI* out_array, - ice::ucount* inout_array_size + ice::u32* inout_array_size ) const noexcept override; bool register_module( @@ -124,7 +124,7 @@ namespace ice /* is_app_context */ false ); - ice::array::push_back(_module_handles, ice::move(module_handle)); + _module_handles.push_back(ice::move(module_handle)); return true; } } @@ -167,9 +167,9 @@ namespace ice auto DefaultModuleRegister::api_count( ice::StringID_Arg api_name, ice::u32 version - ) const noexcept -> ice::ucount + ) const noexcept -> ice::u32 { - ice::ucount result = 0; + ice::u32 result = 0; auto it = ice::multi_hashmap::find_first(_modules, ice::hash(api_name)); while (it != nullptr) { @@ -187,7 +187,7 @@ namespace ice ice::StringID_Arg api_name, ice::u32 version, ice::ModuleAPI* out_array, - ice::ucount* inout_array_size + ice::u32* inout_array_size ) const noexcept { if (out_array == nullptr) @@ -204,7 +204,7 @@ namespace ice ice::u32 idx = 0; auto it = ice::multi_hashmap::find_first(_modules, ice::hash(api_name)); - ice::ucount const array_size = *inout_array_size; + ice::u32 const array_size = *inout_array_size; while (it != nullptr && idx < array_size) { ice::ModuleAPI api_ptr; @@ -237,7 +237,7 @@ namespace ice ice::StringID_Hash api_name, ice::u32 version, ice::ModuleAPI* out_api, - ice::ucount* inout_array_size + ice::u32* inout_array_size ) noexcept { return ctx->module_register->query_apis(ice::StringID{ api_name }, version, out_api, inout_array_size); diff --git a/source/code/core/modules/public/ice/module_concepts.hxx b/source/code/core/modules/public/ice/module_concepts.hxx index d4c9d1ff..5558d7c8 100644 --- a/source/code/core/modules/public/ice/module_concepts.hxx +++ b/source/code/core/modules/public/ice/module_concepts.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -30,7 +30,7 @@ namespace ice::concepts template concept ModuleNegotiator = requires(T const& t, ice::StringID_Arg id, ice::FnModuleSelectAPI* api) { - { t.query_apis(id, ice::u32{}, (ice::ModuleAPI*) nullptr, (ice::ucount*)nullptr) } -> std::convertible_to; + { t.query_apis(id, ice::u32{}, (ice::ModuleAPI*) nullptr, (ice::u32*)nullptr) } -> std::convertible_to; { t.register_api(id, api) } -> std::convertible_to; { t.from_app() } -> std::convertible_to; } && requires(T const& t, ice::ProcAPIQuickRegisterFunc func) { diff --git a/source/code/core/modules/public/ice/module_negotiator.hxx b/source/code/core/modules/public/ice/module_negotiator.hxx index 3558ba04..64af46f4 100644 --- a/source/code/core/modules/public/ice/module_negotiator.hxx +++ b/source/code/core/modules/public/ice/module_negotiator.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -29,7 +29,7 @@ namespace ice ice::StringID_Hash api_name, ice::u32 api_version, ice::ModuleAPI* out_array, - ice::ucount* inout_array_size + ice::u32* inout_array_size ) noexcept; //! \brief Registers an API selector function for the given API name. @@ -63,7 +63,7 @@ namespace ice ice::StringID_Arg api_name, ice::u32 api_version, ice::ModuleAPI* out_array, - ice::ucount* inout_array_size + ice::u32* inout_array_size ) const noexcept override; //! \brief Registers an API selector function with the given API name. diff --git a/source/code/core/modules/public/ice/module_query.hxx b/source/code/core/modules/public/ice/module_query.hxx index d5d51c55..73d98061 100644 --- a/source/code/core/modules/public/ice/module_query.hxx +++ b/source/code/core/modules/public/ice/module_query.hxx @@ -1,11 +1,11 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once +#include #include #include #include -#include namespace ice { @@ -36,7 +36,7 @@ namespace ice ice::StringID_Arg api_name, ice::u32 version, ice::ModuleAPI* out_array, - ice::ucount* inout_array_size + ice::u32* inout_array_size ) const noexcept = 0; //! \brief Queries a single API for the given API struct. @@ -81,14 +81,14 @@ namespace ice template requires (ice::concepts::APIType) bool ModuleQuery::query_apis(ice::Array& out_apis) const noexcept { - ice::ucount num_apis = 0; + ice::u32 num_apis = 0; if (query_apis(Type::Constant_APIName, Type::Constant_APIVersion, nullptr, &num_apis)) { // ICE_LOG_IF( // num_apis > 10, // ice::LogSeverity::Warning, ice::LogTag::Engine, // "More than 10 APIs of type {} where queried ({}).\n" - // "Use 'query_apis(ice::StringID_Arg, ice::u32, ice::ModuleAPI*, ice::ucount*)' instead to avoid truncating results.", + // "Use 'query_apis(ice::StringID_Arg, ice::u32, ice::ModuleAPI*, ice::u32*)' instead to avoid truncating results.", // num_apis, Type::Constant_APIName // ); @@ -96,10 +96,10 @@ namespace ice query_apis(Type::Constant_APIName, Type::Constant_APIVersion, temp_tab, &num_apis); // Fill the array with the found APIs - ice::array::reserve(out_apis, num_apis); + out_apis.reserve(num_apis); for (ice::u32 idx = 0; idx < num_apis; ++idx) { - ice::array::push_back(out_apis, *reinterpret_cast(temp_tab[idx].api_ptr)); + out_apis.push_back(*reinterpret_cast(temp_tab[idx].api_ptr)); } } return num_apis > 0; diff --git a/source/code/core/modules/public/ice/module_register.hxx b/source/code/core/modules/public/ice/module_register.hxx index eff77c4c..5d4a1fb6 100644 --- a/source/code/core/modules/public/ice/module_register.hxx +++ b/source/code/core/modules/public/ice/module_register.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -62,7 +62,7 @@ namespace ice auto load_global_modules( ice::Allocator& alloc, ice::ModuleRegister& modules_register - ) noexcept -> ice::ucount; + ) noexcept -> ice::u32; //! \brief Creates a default module register. //! \param[in] alloc The allocator to use for the module register. diff --git a/source/code/core/tasks/private/internal_tasks/task_utils.hxx b/source/code/core/tasks/private/internal_tasks/task_utils.hxx index d5629e4d..c13ff73f 100644 --- a/source/code/core/tasks/private/internal_tasks/task_utils.hxx +++ b/source/code/core/tasks/private/internal_tasks/task_utils.hxx @@ -111,13 +111,13 @@ namespace ice constexpr auto await_ready() const noexcept { // Only suspend if we actually have tasks - return ice::span::empty(tasks); + return tasks.is_empty(); } inline auto await_suspend(std::coroutine_handle<> coro) noexcept { // Set the 'running' variable so we can track how many tasks arleady finished. - running.store(ice::count(tasks) + 1, std::memory_order_relaxed); + running.store(tasks.size().u32() + 1, std::memory_order_relaxed); for (ice::Task& task : tasks) { @@ -132,7 +132,7 @@ namespace ice constexpr bool await_resume() const noexcept { ICE_ASSERT_CORE(running.load(std::memory_order_relaxed) == 0); - return ice::span::any(tasks); + return tasks.not_empty(); } }; return Awaitable{ tasks }; @@ -149,13 +149,13 @@ namespace ice constexpr auto await_ready() const noexcept { // Only suspend if we actually have tasks - return ice::span::empty(tasks); + return tasks.is_empty(); } inline auto await_suspend(std::coroutine_handle<> coro) noexcept { // Set the 'running' variable so we can track how many tasks arleady finished. - running.store(ice::count(tasks) + 1, std::memory_order_relaxed); + running.store(tasks.size().u32() + 1, std::memory_order_relaxed); for (ice::Task<>& task : tasks) { @@ -170,7 +170,7 @@ namespace ice constexpr bool await_resume() const noexcept { ICE_ASSERT_CORE(running.load(std::memory_order_relaxed) == 0); - return ice::span::any(tasks); + return tasks.not_empty(); } }; return Awaitable{ tasks, scheduler }; diff --git a/source/code/core/tasks/private/task_native_thread.cxx b/source/code/core/tasks/private/task_native_thread.cxx index 226b48a1..bd3d4dee 100644 --- a/source/code/core/tasks/private/task_native_thread.cxx +++ b/source/code/core/tasks/private/task_native_thread.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "task_native_thread.hxx" @@ -81,7 +81,7 @@ namespace ice return _runtime._state == ThreadState::Active; } - auto NativeTaskThread::estimated_task_count() const noexcept -> ice::ucount + auto NativeTaskThread::estimated_task_count() const noexcept -> ice::u32 { return 0; } @@ -275,10 +275,10 @@ namespace ice if constexpr (ice::build::is_release == false) { - if (ice::string::any(info.debug_name)) + if (info.debug_name.not_empty()) { ice::StackAllocator<256_B> stack_alloc; - ice::ucount const wide_count = ice::utf8_to_wide_size(info.debug_name); + ice::u32 const wide_count = ice::utf8_to_wide_size(info.debug_name); ICE_ASSERT( ice::size_of *(wide_count + 1) < stack_alloc.Constant_InternalCapacity, "Thread debug name too long!" diff --git a/source/code/core/tasks/private/task_native_thread.hxx b/source/code/core/tasks/private/task_native_thread.hxx index 9f28e917..05d355bb 100644 --- a/source/code/core/tasks/private/task_native_thread.hxx +++ b/source/code/core/tasks/private/task_native_thread.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -75,7 +75,7 @@ namespace ice bool is_busy() const noexcept override; bool is_running() const noexcept override; - auto estimated_task_count() const noexcept -> ice::ucount override; + auto estimated_task_count() const noexcept -> ice::u32 override; auto queue() noexcept -> ice::TaskQueue & override; private: diff --git a/source/code/core/tasks/private/task_queue.cxx b/source/code/core/tasks/private/task_queue.cxx index e27fcadc..f9585881 100644 --- a/source/code/core/tasks/private/task_queue.cxx +++ b/source/code/core/tasks/private/task_queue.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -98,9 +98,9 @@ namespace ice return awaitable != nullptr; } - auto TaskQueue::process_all(void* result_value) noexcept -> ice::ucount + auto TaskQueue::process_all(void* result_value) noexcept -> ice::u32 { - ice::ucount processed = 0; + ice::u32 processed = 0; for (ice::TaskAwaitableBase* const awaitable : ice::linked_queue::consume(_awaitables)) { if (result_value != nullptr) @@ -133,9 +133,9 @@ namespace ice return processed; } - // auto TaskQueue::prepare_all(void *result_value) noexcept -> ice::ucount + // auto TaskQueue::prepare_all(void *result_value) noexcept -> ice::u32 // { - // return ice::ucount(); + // return ice::u32(); // } void TaskQueue::wait_any() noexcept diff --git a/source/code/core/tasks/private/task_scoped_container.cxx b/source/code/core/tasks/private/task_scoped_container.cxx index eb91e810..bbee7e40 100644 --- a/source/code/core/tasks/private/task_scoped_container.cxx +++ b/source/code/core/tasks/private/task_scoped_container.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -22,21 +22,20 @@ namespace ice } auto ScopedTaskContainer::create_tasks( - ice::ucount count, + ice::u32 count, ice::ShardID shardid ) noexcept -> ice::Span> { - ice::ucount const new_count = ice::array::count(_tasks) + count; - - if (new_count > ice::array::capacity(_tasks)) + ice::ncount const new_count = _tasks.size() + count; + if (new_count > _tasks.capacity()) { // Updates the capacity of the array to fit the new tasks - ice::array::grow(_tasks, new_count); + _tasks.grow(new_count); } // Creates the tasks and returns a slice to them - ice::array::resize(_tasks, new_count); - return ice::array::slice(_tasks, ice::array::count(_tasks) - count, count); + _tasks.resize(new_count); + return _tasks.tailspan(_tasks.size() - count); } auto ScopedTaskContainer::await_tasks_scheduled_on(ice::TaskScheduler& scheduler, ice::TaskScheduler& resumer) noexcept -> ice::Task<> @@ -44,19 +43,19 @@ namespace ice co_await ice::await_scheduled_on(_tasks, scheduler, resumer); } - auto ScopedTaskContainer::execute_tasks() noexcept -> ice::ucount + auto ScopedTaskContainer::execute_tasks() noexcept -> ice::u32 { - ice::ucount const result = ice::array::count(_tasks); + ice::ncount const result = _tasks.size(); if (result > 0) { - _barrier.reset(static_cast(result)); + _barrier.reset(result.u8()); ice::manual_wait_for(_barrier, _tasks); - ice::array::clear(_tasks); + _tasks.clear(); } - return result; + return result.u32(); } - auto ScopedTaskContainer::running_tasks() const noexcept -> ice::ucount + auto ScopedTaskContainer::running_tasks() const noexcept -> ice::u32 { return _barrier.value(); } diff --git a/source/code/core/tasks/private/task_thread_pool_impl.cxx b/source/code/core/tasks/private/task_thread_pool_impl.cxx index ce4d25fe..604d20a3 100644 --- a/source/code/core/tasks/private/task_thread_pool_impl.cxx +++ b/source/code/core/tasks/private/task_thread_pool_impl.cxx @@ -1,9 +1,8 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "task_thread_pool_impl.hxx" -#include -#include +#include #include namespace ice @@ -19,11 +18,11 @@ namespace ice auto const result = fmt::vformat_to_n( raw_buffer, ice::count(raw_buffer), - fmt::string_view{format._data, format._size}, + fmt::string_view{ format.data(), format.size() }, fmt::make_format_args(std::forward(args)...) ); - out_string = ice::String{ raw_buffer, (ice::ucount) result.size }; + out_string = ice::String{ raw_buffer, (ice::u32) result.size }; } auto aio_thread_routine(void* userdata, ice::TaskQueue&) noexcept -> ice::u32 @@ -48,8 +47,8 @@ namespace ice , _created_threads{ _allocator } , _user_threads{ _allocator } { - ice::array::reserve(_thread_pool, info.thread_count); - ice::array::reserve(_managed_threads, info.thread_count); + _thread_pool.reserve(info.thread_count); + _managed_threads.reserve(info.thread_count); ice::hashmap::reserve(_created_threads, info.thread_count); ice::hashmap::reserve(_user_threads, info.thread_count); @@ -65,8 +64,7 @@ namespace ice detail::format_string(thread_name, info.debug_name_format, idx); thread_info.debug_name = thread_name; - ice::array::push_back( - _managed_threads, + _managed_threads.push_back( ice::make_unique( _allocator, _queue, @@ -80,8 +78,7 @@ namespace ice { detail::format_string(thread_name, "ice.aio {}", idx); - ice::array::push_back( - _managed_threads, + _managed_threads.push_back( ice::make_unique( _allocator, _queue, @@ -102,21 +99,21 @@ namespace ice { ice::hashmap::clear(_user_threads); ice::hashmap::clear(_created_threads); - ice::array::clear(_managed_threads); - ice::array::clear(_thread_pool); + _managed_threads.clear(); + _thread_pool.clear(); } - auto TaskThreadPoolImplementation::thread_count() const noexcept -> ice::ucount + auto TaskThreadPoolImplementation::thread_count() const noexcept -> ice::u32 { - return ice::array::count(_thread_pool); + return _thread_pool.size().u32(); } - auto TaskThreadPoolImplementation::managed_thread_count() const noexcept -> ice::ucount + auto TaskThreadPoolImplementation::managed_thread_count() const noexcept -> ice::u32 { - return ice::array::count(_managed_threads) + ice::hashmap::count(_created_threads); + return _managed_threads.size().u32() + ice::hashmap::count(_created_threads); } - auto TaskThreadPoolImplementation::estimated_task_count() const noexcept -> ice::ucount + auto TaskThreadPoolImplementation::estimated_task_count() const noexcept -> ice::u32 { return 0; // TODO: } @@ -134,7 +131,7 @@ namespace ice .exclusive_queue = false, .sort_by_priority = false, .stack_size = 0_B, // default - .debug_name = ice::String{ name_hint.data(), static_cast(name_hint.size()) } + .debug_name = ice::String{ name_hint.data(), static_cast(name_hint.size()) } }; ice::hashmap::set( diff --git a/source/code/core/tasks/private/task_thread_pool_impl.hxx b/source/code/core/tasks/private/task_thread_pool_impl.hxx index ec565c9c..4de86615 100644 --- a/source/code/core/tasks/private/task_thread_pool_impl.hxx +++ b/source/code/core/tasks/private/task_thread_pool_impl.hxx @@ -1,10 +1,10 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include -#include +#include #include #include "task_native_thread.hxx" @@ -21,9 +21,9 @@ namespace ice ) noexcept; ~TaskThreadPoolImplementation() noexcept override; - auto thread_count() const noexcept -> ice::ucount override; - auto managed_thread_count() const noexcept -> ice::ucount override; - auto estimated_task_count() const noexcept -> ice::ucount override; + auto thread_count() const noexcept -> ice::u32 override; + auto managed_thread_count() const noexcept -> ice::u32 override; + auto estimated_task_count() const noexcept -> ice::u32 override; auto create_thread(ice::StringID name) noexcept -> ice::TaskThread& override; auto find_thread(ice::StringID name) noexcept -> ice::TaskThread* override; diff --git a/source/code/core/tasks/private/task_utils.cxx b/source/code/core/tasks/private/task_utils.cxx index 3722d575..dc1fc2f4 100644 --- a/source/code/core/tasks/private/task_utils.cxx +++ b/source/code/core/tasks/private/task_utils.cxx @@ -81,7 +81,7 @@ namespace ice { ice::execute_detached_task(ice::move(task)); } - return ice::span::any(tasks); + return tasks.not_empty(); } bool schedule_task(ice::Task<> task, ice::TaskScheduler& scheduler) noexcept @@ -100,7 +100,7 @@ namespace ice { ice::schedule_detached_task(ice::move(task), scheduler); } - return ice::span::any(tasks); + return tasks.not_empty(); } bool schedule_queue(ice::TaskQueue& queue, ice::TaskScheduler& scheduler) noexcept diff --git a/source/code/core/tasks/public/ice/impl/task_utils.inl b/source/code/core/tasks/public/ice/impl/task_utils.inl index 37d010ee..15f4cc5c 100644 --- a/source/code/core/tasks/public/ice/impl/task_utils.inl +++ b/source/code/core/tasks/public/ice/impl/task_utils.inl @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT diff --git a/source/code/core/tasks/public/ice/task_container.hxx b/source/code/core/tasks/public/ice/task_container.hxx index d7d2909e..3bbb1807 100644 --- a/source/code/core/tasks/public/ice/task_container.hxx +++ b/source/code/core/tasks/public/ice/task_container.hxx @@ -1,11 +1,11 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include #include -#include +#include namespace ice { @@ -18,9 +18,9 @@ namespace ice virtual auto await_tasks_scheduled_on(ice::TaskScheduler& scheduler, ice::TaskScheduler& resumer) noexcept -> ice::Task<> = 0; - virtual auto execute_tasks() noexcept -> ice::ucount = 0; + virtual auto execute_tasks() noexcept -> ice::u32 = 0; - virtual auto running_tasks() const noexcept -> ice::ucount = 0; + virtual auto running_tasks() const noexcept -> ice::u32 = 0; virtual void wait_tasks() noexcept = 0; diff --git a/source/code/core/tasks/public/ice/task_debug_allocator.hxx b/source/code/core/tasks/public/ice/task_debug_allocator.hxx index e9b16ba3..03873b9d 100644 --- a/source/code/core/tasks/public/ice/task_debug_allocator.hxx +++ b/source/code/core/tasks/public/ice/task_debug_allocator.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -23,7 +23,7 @@ namespace ice::detail { static auto pool() noexcept -> ice::String { - return ice::string::any(_allocator_pool) ? _allocator_pool : "Tasks"; + return _allocator_pool.not_empty() ? _allocator_pool : "Tasks"; } static auto allocator() noexcept -> ice::Allocator& diff --git a/source/code/core/tasks/public/ice/task_expected_promise.hxx b/source/code/core/tasks/public/ice/task_expected_promise.hxx index ba11b4cc..fcd09f0a 100644 --- a/source/code/core/tasks/public/ice/task_expected_promise.hxx +++ b/source/code/core/tasks/public/ice/task_expected_promise.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/tasks/public/ice/task_queue.hxx b/source/code/core/tasks/public/ice/task_queue.hxx index f3e8192d..d91d2961 100644 --- a/source/code/core/tasks/public/ice/task_queue.hxx +++ b/source/code/core/tasks/public/ice/task_queue.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -28,14 +28,14 @@ namespace ice auto consume() noexcept -> ice::LinkedQueueRange; bool process_one(void* result_value = nullptr) noexcept; - auto process_all(void* result_value = nullptr) noexcept -> ice::ucount; + auto process_all(void* result_value = nullptr) noexcept -> ice::u32; void wait_any() noexcept; template inline bool process_one(Value& result_value) noexcept; template - inline auto process_all(Value& result_value) noexcept -> ice::ucount; + inline auto process_all(Value& result_value) noexcept -> ice::u32; //! \brief Flags of task allowed to be pushed onto this queue. ice::TaskFlags const flags; @@ -51,7 +51,7 @@ namespace ice } template - inline auto TaskQueue::process_all(Value& result_value) noexcept -> ice::ucount + inline auto TaskQueue::process_all(Value& result_value) noexcept -> ice::u32 { return this->process_all(reinterpret_cast(&result_value)); } diff --git a/source/code/core/tasks/public/ice/task_scoped_container.hxx b/source/code/core/tasks/public/ice/task_scoped_container.hxx index bad6eabb..7c027214 100644 --- a/source/code/core/tasks/public/ice/task_scoped_container.hxx +++ b/source/code/core/tasks/public/ice/task_scoped_container.hxx @@ -1,9 +1,9 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include namespace ice @@ -17,17 +17,17 @@ namespace ice //! \brief Create a new set of tasks and return the slice containing them. auto create_tasks( - ice::ucount count, + ice::u32 count, ice::ShardID shardid ) noexcept -> ice::Span> override; auto await_tasks_scheduled_on(ice::TaskScheduler& scheduler, ice::TaskScheduler& resumer) noexcept -> ice::Task<> override; //! \brief Execute all tasks that have been created. - auto execute_tasks() noexcept -> ice::ucount override; + auto execute_tasks() noexcept -> ice::u32 override; //! \brief Returns the number of tasks that are currently running. - auto running_tasks() const noexcept -> ice::ucount override; + auto running_tasks() const noexcept -> ice::u32 override; //! \brief Wait for all tasks to complete. void wait_tasks() noexcept override; diff --git a/source/code/core/tasks/public/ice/task_thread.hxx b/source/code/core/tasks/public/ice/task_thread.hxx index f13df652..7804239c 100644 --- a/source/code/core/tasks/public/ice/task_thread.hxx +++ b/source/code/core/tasks/public/ice/task_thread.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -53,7 +53,7 @@ namespace ice virtual bool is_busy() const noexcept = 0; virtual bool is_running() const noexcept = 0; - virtual auto estimated_task_count() const noexcept -> ice::ucount = 0; + virtual auto estimated_task_count() const noexcept -> ice::u32 = 0; virtual auto queue() noexcept -> ice::TaskQueue& = 0; }; diff --git a/source/code/core/tasks/public/ice/task_thread_pool.hxx b/source/code/core/tasks/public/ice/task_thread_pool.hxx index 7610c683..43aa7cb4 100644 --- a/source/code/core/tasks/public/ice/task_thread_pool.hxx +++ b/source/code/core/tasks/public/ice/task_thread_pool.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -14,7 +14,7 @@ namespace ice struct TaskThreadPoolCreateInfo { //! \brief The thread count of this thread pool. - ice::ucount thread_count = 0; + ice::u32 thread_count = 0; //! \brief The AIO port to be used for internal AIO threads. ice::native_aio::AIOPort aioport = nullptr; @@ -27,9 +27,9 @@ namespace ice { public: virtual ~TaskThreadPool() noexcept = default; - virtual auto thread_count() const noexcept -> ice::ucount = 0; - virtual auto managed_thread_count() const noexcept -> ice::ucount = 0; - virtual auto estimated_task_count() const noexcept -> ice::ucount = 0; + virtual auto thread_count() const noexcept -> ice::u32 = 0; + virtual auto managed_thread_count() const noexcept -> ice::u32 = 0; + virtual auto estimated_task_count() const noexcept -> ice::u32 = 0; //! \brief Creates an additonal thread with the given name (ID). //! diff --git a/source/code/core/tasks/public/ice/task_utils.hxx b/source/code/core/tasks/public/ice/task_utils.hxx index 830cc3ff..8750e3a1 100644 --- a/source/code/core/tasks/public/ice/task_utils.hxx +++ b/source/code/core/tasks/public/ice/task_utils.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/utils/private/assert.cxx b/source/code/core/utils/private/assert.cxx index c66c6c23..275f8870 100644 --- a/source/code/core/utils/private/assert.cxx +++ b/source/code/core/utils/private/assert.cxx @@ -1,8 +1,8 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include -#include +#include #include #include diff --git a/source/code/core/utils/private/config/config_builder.cxx b/source/code/core/utils/private/config/config_builder.cxx index 8ef46a53..9d9c7b1e 100644 --- a/source/code/core/utils/private/config/config_builder.cxx +++ b/source/code/core/utils/private/config/config_builder.cxx @@ -1,10 +1,10 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include #include -#include -#include +#include +#include #include "config_builder.hxx" @@ -91,8 +91,8 @@ namespace ice ) noexcept -> ice::usize { ice::usize result = 0_B; - ConfigBuilderEntry const* entry = ice::array::begin(config._entries); - ConfigBuilderEntry const* const entry_end = ice::array::end(config._entries); + ConfigBuilderEntry const* entry = config._entries.begin(); + ConfigBuilderEntry const* const entry_end = config._entries.end(); if (entry == entry_end) { @@ -119,9 +119,9 @@ namespace ice } else if (entry->vtype == CONFIG_VALTYPE_STRING) { - ice::ucount bytes = 0; - ice::ucount const size = ice::string::detail::read_varstring_size(entry->data.val_varstr->_data, bytes); - out_data_size += { bytes + size + 1 }; // +1 for '\0' + ice::usize bytes = 0_B; + ice::ncount const size = ice::varstring::read_size(entry->data.val_varstr->_data, bytes); + out_data_size += bytes + size.bytes() + 1_B; // +1 for '\0' } else if (entry->vtype >= CONFIG_VALTYPE_LARGE) { @@ -167,8 +167,8 @@ namespace ice { // First add all keys-values to the list ice::u32 keyoffset = 0; - ice::config::detail::ConfigBuilderEntry const* it_entry = ice::array::begin(config._entries); - ice::config::detail::ConfigBuilderEntry const* const it_end = ice::array::end(config._entries); + ice::config::detail::ConfigBuilderEntry const* it_entry = config._entries.begin(); + ice::config::detail::ConfigBuilderEntry const* const it_end = config._entries.end(); do { // Copy the whole key information and just update the str offset. @@ -196,11 +196,11 @@ namespace ice // Then add all children key-values ice::u32 out_keyidx = 0; - it_entry = ice::array::begin(config._entries); + it_entry = config._entries.begin(); if (config.vtype == CONFIG_VALTYPE_TABLE) { - ice::u32 const table_size = ice::count(config._entries); + ice::u32 const table_size = config._entries.size().u32(); // Save table size in first key out_keylist[0].offset = table_size >> 8; @@ -228,7 +228,7 @@ namespace ice else if (it_entry->vtype == CONFIG_VALTYPE_STRING) { ice::HeapVarString<> const& varstr = *config._entries[out_keyidx].data.val_varstr; - ice::Data const in_data = ice::string::data_view(varstr); + ice::Data const in_data = varstr.data_view(); // Set the '\0' character *(reinterpret_cast(out_data.memory.location) + (out_data.offset_strings - 1)) = '\0'; @@ -249,7 +249,7 @@ namespace ice ConfigBuilderContainer& sub = *config._entries[out_keyidx].data.val_container; // Set the value to the current 'keyoffset' value. This serves as the relative offset starting from the passed key. - out_vallist[out_keyidx].internal = ice::array::empty(sub._entries) ? ice::u32_max : keyoffset - out_keyidx; + out_vallist[out_keyidx].internal = sub._entries.is_empty() ? ice::u32_max : keyoffset - out_keyidx; if (out_vallist[out_keyidx].internal != ice::u32_max) { @@ -371,7 +371,7 @@ namespace ice using ice::config::detail::ConfigValue; ice::config::detail::ConfigBuilderContainer& container = *_internal->data.val_container; - if (ice::array::empty(container._entries)) + if (container._entries.is_empty()) { return {}; } @@ -397,18 +397,18 @@ namespace ice char const* final_keystrings = reinterpret_cast(final_keystrings_mem.location); // Reserve space to hold all keystring entries and build the string buffer. - ice::array::resize(keyoffsets, ice::hashmap::count(keystrings)); + keyoffsets.resize(ice::hashmap::count(keystrings)); - ice::u32 keystr_offset = 0; + ice::ncount keystr_offset = 0; for (CBKeyString const& keystr : ice::hashmap::values(keystrings)) { // Copy and advance the pointer - ice::memcpy(final_keystrings_mem, ice::string::data_view(keystr.value)); - final_keystrings_mem = ice::ptr_add(final_keystrings_mem, ice::string::data_view(keystr.value).size); + ice::memcpy(final_keystrings_mem, keystr.value.data_view()); + final_keystrings_mem = ice::ptr_add(final_keystrings_mem, keystr.value.size()); // Store the offset - keyoffsets[keystr.index] = keystr_offset; - keystr_offset += ice::string::size(keystr.value); + keyoffsets[keystr.index] = keystr_offset.u32(); + keystr_offset += keystr.value.size(); } // Build the new key and value arrays + copy large data. diff --git a/source/code/core/utils/private/config/config_builder_types.cxx b/source/code/core/utils/private/config/config_builder_types.cxx index 53cf8a68..51c32fcc 100644 --- a/source/code/core/utils/private/config/config_builder_types.cxx +++ b/source/code/core/utils/private/config/config_builder_types.cxx @@ -39,7 +39,7 @@ namespace ice::config::detail { cb_clear_value_type(_allocator, &entry); } - ice::array::clear(_entries); + _entries.clear(); } ConfigBuilderContainer::~ConfigBuilderContainer() noexcept diff --git a/source/code/core/utils/private/config/config_builder_types.hxx b/source/code/core/utils/private/config/config_builder_types.hxx index a3ba78d9..c56802ce 100644 --- a/source/code/core/utils/private/config/config_builder_types.hxx +++ b/source/code/core/utils/private/config/config_builder_types.hxx @@ -1,12 +1,12 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include "config_internal.hxx" #include -#include -#include -#include +#include +#include +#include namespace ice::config::detail { diff --git a/source/code/core/utils/private/config/config_builder_utils.cxx b/source/code/core/utils/private/config/config_builder_utils.cxx index df2384bf..a8298536 100644 --- a/source/code/core/utils/private/config/config_builder_utils.cxx +++ b/source/code/core/utils/private/config/config_builder_utils.cxx @@ -1,8 +1,8 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "config_builder_utils.hxx" -#include +#include namespace ice::config::detail { @@ -64,7 +64,7 @@ namespace ice::config::detail ice::config::detail::ConfigBuilderContainer& container = *entry.data.val_container; ice::u32 idx = 0; - for (;idx < ice::count(container._entries); ++idx) + for (;idx < container._entries.size(); ++idx) { ice::String const entry_key = detail::cb_getkey(container._keystrings, container._entries[idx]); if (key == entry_key) @@ -74,9 +74,9 @@ namespace ice::config::detail } ice::config::detail::ConfigBuilderEntry* result; - if (idx < ice::count(container._entries)) + if (idx < container._entries.size()) { - result = ice::array::begin(container._entries) + idx; + result = container._entries.begin() + idx; if (clean) { cb_clear_value_type(alloc, result); @@ -84,15 +84,15 @@ namespace ice::config::detail } else { - idx = ice::count(container._entries); - ice::u32 const offset = ice::string::size(container._keystrings); - ice::string::push_back(container._keystrings, key); + idx = container._entries.size().u32(); + ice::ncount const offset = container._keystrings.size(); + container._keystrings.push_back(key); // Add the new entry - ice::array::push_back(container._entries, ConfigKey{ 0, CONFIG_KEYTYPE_STRING, CONFIG_VALTYPE_NONE, offset, ice::size(key) }); + container._entries.push_back(ConfigKey{ 0, CONFIG_KEYTYPE_STRING, CONFIG_VALTYPE_NONE, offset.u32(), key.size().u32()}); // Return the entry - result = ice::array::begin(container._entries) + idx; + result = container._entries.begin() + idx; } return result; @@ -109,9 +109,9 @@ namespace ice::config::detail ice::config::detail::ConfigBuilderContainer& container = *entry.data.val_container; ice::config::detail::ConfigBuilderEntry* result; - if (idx < ice::count(container._entries)) + if (idx < container._entries.size()) { - result = ice::array::begin(container._entries) + idx; + result = container._entries.begin() + idx; if (clean) { cb_clear_value_type(alloc, result); @@ -121,16 +121,16 @@ namespace ice::config::detail { if (idx == ice::u32_max) { - idx = ice::count(container._entries); + idx = container._entries.size().u32(); } - while(ice::count(container._entries) <= idx) + while(container._entries.size() <= idx) { - ice::array::push_back(container._entries, ConfigKey{ 0, CONFIG_KEYTYPE_NONE, CONFIG_VALTYPE_NONE, 0, 0 }); + container._entries.push_back(ConfigKey{ 0, CONFIG_KEYTYPE_NONE, CONFIG_VALTYPE_NONE, 0, 0 }); } // Return the entry - result = ice::array::begin(container._entries) + idx; + result = container._entries.begin() + idx; } return result; diff --git a/source/code/core/utils/private/config/config_builder_value.cxx b/source/code/core/utils/private/config/config_builder_value.cxx index d3983aa8..be107f3f 100644 --- a/source/code/core/utils/private/config/config_builder_value.cxx +++ b/source/code/core/utils/private/config/config_builder_value.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "config_builder.hxx" @@ -86,7 +86,7 @@ namespace ice auto ice::ConfigBuilderValue::operator[](ice::String key) noexcept -> ConfigBuilderValue { - ICE_ASSERT_CORE(ice::string::find_first_of(key, '.') == ice::String_NPos); + ICE_ASSERT_CORE(key.find_first_of('.') == ice::nindex_none); ConfigBuilderEntry* const entry = _idx == ice::u32_max ? _internal : (static_cast(_internal)->_entries._data + _idx); diff --git a/source/code/core/utils/private/config/config_detail.cxx b/source/code/core/utils/private/config/config_detail.cxx index 717070eb..02a7a344 100644 --- a/source/code/core/utils/private/config/config_detail.cxx +++ b/source/code/core/utils/private/config/config_detail.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "config_detail.hxx" @@ -9,7 +9,7 @@ namespace ice::config::detail auto get_keyindex(ice::String key) noexcept -> ice::u32 { ice::u32 idx = 0; - char const* k = ice::string::begin(key); + char const* k = key.begin(); while(*k >= '0' && *k <= '9') { idx *= 10; @@ -101,7 +101,7 @@ namespace ice::config::detail } // The first element holds the size of the whole table - ice::ucount const table_size = ( config._keys->offset << 8) | config._keys->size; + ice::u32 const table_size = (config._keys->offset << 8) | config._keys->size; if (index >= table_size) // OutOfBounds? { return E_ConfigIndexOutOfBounds; @@ -131,11 +131,11 @@ namespace ice::config::detail Config finalcfg = config; // If this key has multiple parts recursively enter config search - ice::ucount key_split_location = ice::string::find_first_of(key, {".|"}); - while (key_split_location != ice::String_NPos && result) + ice::nindex key_split_location = key.find_first_of({".|"}); + while (key_split_location != ice::nindex_none && result) { bool const is_table = finalcfg._keys->type != CONFIG_KEYTYPE_STRING; - ice::String const keyval = ice::string::substr(key, 0, key_split_location); + ice::String const keyval = key.substr(0, key_split_location); if (is_table) { @@ -146,8 +146,8 @@ namespace ice::config::detail result = get_subconfig(finalcfg, keyval); } - key = ice::string::substr(key, key_split_location + 1); - key_split_location = ice::string::find_first_of(key, {".|"}); + key = key.substr(key_split_location + 1); + key_split_location = key.find_first_of({".|"}); } if (finalcfg._keys->type != CONFIG_KEYTYPE_STRING) [[unlikely]] diff --git a/source/code/core/utils/private/config_getters.cxx b/source/code/core/utils/private/config_getters.cxx index 29ad078d..1a18fb95 100644 --- a/source/code/core/utils/private/config_getters.cxx +++ b/source/code/core/utils/private/config_getters.cxx @@ -1,8 +1,8 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "config/config_detail.hxx" -#include +#include namespace ice::config::detail { @@ -317,10 +317,10 @@ namespace ice::config::detail } char const* strdata = reinterpret_cast(config._data) + value->internal; - ice::ucount varbytes = 0; - ice::ucount const size = ice::string::detail::read_varstring_size(strdata, varbytes); + ice::usize varbytes{}; + ice::ncount const size = ice::varstring::read_size(strdata, varbytes); - out_value = { strdata + varbytes, size }; + out_value = { strdata + varbytes.value, size }; return S_Ok; } diff --git a/source/code/core/utils/private/config_json.cxx b/source/code/core/utils/private/config_json.cxx index 6a40bdca..98414cdb 100644 --- a/source/code/core/utils/private/config_json.cxx +++ b/source/code/core/utils/private/config_json.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -51,7 +51,7 @@ namespace ice::config else if (value.IsDouble()) config_table = value.GetDouble(); break; case rapidjson::Type::kStringType: - config_table = ice::String{ value.GetString(), ice::ucount(value.GetStringLength()) }; + config_table = ice::String{ value.GetString(), value.GetStringLength() }; break; case rapidjson::Type::kArrayType: deserialize_json_array(value.GetArray(), config_table); @@ -96,7 +96,7 @@ namespace ice::config auto from_json(ice::ConfigBuilder& config_builder, ice::String json) noexcept -> ice::ErrorCode { rapidjson::Document doc; - if (doc.Parse(ice::string::begin(json),ice::string::size(json)).HasParseError() == false && doc.IsObject()) + if (doc.Parse(json.begin(), json.size()).HasParseError() == false && doc.IsObject()) { detail::deserialize_json_object(const_cast(doc).GetObject(), config_builder); return S_Ok; diff --git a/source/code/core/utils/private/log.cxx b/source/code/core/utils/private/log.cxx index 12c8791c..fd4ef953 100644 --- a/source/code/core/utils/private/log.cxx +++ b/source/code/core/utils/private/log.cxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include #include -#include +#include #include #include "log_internal.hxx" @@ -95,7 +95,7 @@ namespace ice::detail ice::detail::local_time(), fmt_string(detail::severity_value[static_cast(severity)]), fmt_string(base_tag_name), - fmt_string(ice::string::empty(tag_name) || ice::string::empty(base_tag_name) ? "" : " | "), + fmt_string(tag_name.is_empty() || base_tag_name.is_empty() ? "" : " | "), fmt_string(tag_name) ); diff --git a/source/code/core/utils/private/log_buffer.cxx b/source/code/core/utils/private/log_buffer.cxx index 296c9a74..4f3e7001 100644 --- a/source/code/core/utils/private/log_buffer.cxx +++ b/source/code/core/utils/private/log_buffer.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "log_buffer.hxx" @@ -11,7 +11,7 @@ namespace ice::detail static_cast(buf).grow(capacity); } - LogMessageBuffer::LogMessageBuffer(ice::Allocator& alloc, ice::ucount initial_allocation) noexcept + LogMessageBuffer::LogMessageBuffer(ice::Allocator& alloc, ice::u32 initial_allocation) noexcept : fmt::detail::buffer{ internal_grow_fmt_buffer } , _allocator{ alloc } { diff --git a/source/code/core/utils/private/log_buffer.hxx b/source/code/core/utils/private/log_buffer.hxx index 7c0b8207..737ada5a 100644 --- a/source/code/core/utils/private/log_buffer.hxx +++ b/source/code/core/utils/private/log_buffer.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -12,7 +12,7 @@ namespace ice::detail class LogMessageBuffer final : public fmt::v11::detail::buffer { public: - LogMessageBuffer(ice::Allocator& alloc, ice::ucount initial_allocation) noexcept; + LogMessageBuffer(ice::Allocator& alloc, ice::u32 initial_allocation) noexcept; ~LogMessageBuffer() noexcept; void grow(size_t size) noexcept; diff --git a/source/code/core/utils/private/log_internal.cxx b/source/code/core/utils/private/log_internal.cxx index 9042647f..87ea9ea9 100644 --- a/source/code/core/utils/private/log_internal.cxx +++ b/source/code/core/utils/private/log_internal.cxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "log_internal.hxx" #include -#include +#include namespace ice::detail { @@ -16,7 +16,7 @@ namespace ice::detail , _tags{ _allocator } , _sinks{ _allocator } { - ice::array::resize(_sinks, 5); + _sinks.resize(5); } LogState::~LogState() noexcept = default; @@ -32,18 +32,18 @@ namespace ice::detail auto LogState::register_sink(ice::LogSinkFn fn_sink, void* userdata) noexcept -> ice::LogSinkID { - ice::ucount const sinkidx = ice::count(_sinks); + ice::u32 const sinkidx = _sinks.size().u32(); // Pottentially an error when sinks are added and remove all the time! // NOTE: Once added sinks should only be reset when a module was reloaded! ICE_ASSERT_CORE(sinkidx < 50); - ice::array::push_back(_sinks, Sink{ fn_sink, userdata }); + _sinks.push_back(Sink{ fn_sink, userdata }); return static_cast(sinkidx); } void LogState::unregister_sink(ice::LogSinkID sinkid) noexcept { - ice::ucount const sinkidx = static_cast(sinkid); - if (ice::count(_sinks) > sinkidx) + ice::u32 const sinkidx = static_cast(sinkid); + if (_sinks.size() > sinkidx) { // Just clear the values _sinks[sinkidx] = Sink{ nullptr, nullptr }; diff --git a/source/code/core/utils/private/log_internal.hxx b/source/code/core/utils/private/log_internal.hxx index 42362d35..b292ae53 100644 --- a/source/code/core/utils/private/log_internal.hxx +++ b/source/code/core/utils/private/log_internal.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -121,7 +121,7 @@ namespace ice::detail constexpr auto fmt_string(ice::String str) noexcept -> fmt::string_view { - return fmt_string(str._data, str._data + str._size); + return fmt_string(str.begin(), str.end()); } static constexpr ice::String severity_value[]{ diff --git a/source/code/core/utils/private/native_aio.cxx b/source/code/core/utils/private/native_aio.cxx index f9d84991..5b44a98f 100644 --- a/source/code/core/utils/private/native_aio.cxx +++ b/source/code/core/utils/private/native_aio.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "native_aio.hxx" @@ -543,11 +543,11 @@ namespace ice::native_aio auto aio_process_events( ice::native_aio::AIOPort port, ice::native_aio::AIOProcessLimits limits - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { ice::usize bytes; - ice::ucount num_completed = 0; + ice::u32 num_completed = 0; while(limits.events_max > num_completed) { ice::native_aio::AIORequest const* request = nullptr; diff --git a/source/code/core/utils/private/native_file.cxx b/source/code/core/utils/private/native_file.cxx index 067122d1..4f6aa220 100644 --- a/source/code/core/utils/private/native_file.cxx +++ b/source/code/core/utils/private/native_file.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "native_aio.hxx" @@ -83,7 +83,7 @@ namespace ice::native_file bool exists_file(ice::native_file::FilePath path) noexcept { IPT_ZONE_SCOPED; - DWORD const result = GetFileAttributesW(ice::string::begin(path)); + DWORD const result = GetFileAttributesW(path.begin()); return result != INVALID_FILE_ATTRIBUTES && (result == FILE_ATTRIBUTE_NORMAL || (result & (FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_READONLY)) != 0); @@ -97,7 +97,7 @@ namespace ice::native_file IPT_ZONE_SCOPED; ice::win32::FileHandle handle{ CreateFileW( - ice::string::begin(path), + path.begin(), translate_access(flags), translate_mode(flags), // FILE_SHARE_* NULL, // SECURITY ATTRIBS @@ -126,7 +126,7 @@ namespace ice::native_file ice::native_aio::aio_file_flags(port, flags); ice::win32::FileHandle result = ice::win32::FileHandle{ CreateFileW( - ice::string::begin(path), + path.begin(), translate_access(flags), translate_mode(flags), // FILE_SHARE_* NULL, // SECURITY ATTRIBS @@ -357,20 +357,20 @@ namespace ice::native_file ) noexcept { // Store for later information about the current state of dirpath - if (ice::string::back(dirpath) != L'/') + if (dirpath.back() != L'/') { - ice::string::push_back(dirpath, L'/'); + dirpath.push_back(L'/'); } - ice::u32 const size_dirpath = ice::string::size(dirpath); - ice::string::push_back(dirpath, L'*'); + ice::ncount const size_dirpath = dirpath.size(); + dirpath.push_back(L'*'); WIN32_FIND_DATA direntry; HANDLE const handle = FindFirstFileW( - ice::string::begin(dirpath), + dirpath.begin(), &direntry ); - ice::string::pop_back(dirpath); + dirpath.pop_back(); bool traverse_success = false; if (handle != INVALID_HANDLE_VALUE) @@ -391,7 +391,7 @@ namespace ice::native_file // Append the entry name to the path ice::native_file::FilePath const entry_name = (ice::wchar const*)direntry.cFileName; - ice::string::push_back(dirpath, entry_name); + dirpath.push_back(entry_name); // Call the callback for the next entry encountered... ice::native_file::TraverseAction const action = callback(basepath, dirpath, type, userdata); @@ -411,7 +411,7 @@ namespace ice::native_file } // Rollback the directory string to the base value - ice::string::resize(dirpath, size_dirpath); + dirpath.resize(size_dirpath); } while (FindNextFileW(handle, &direntry) != FALSE); FindClose(handle); @@ -427,8 +427,8 @@ namespace ice::native_file { ice::StackAllocator_1024 temp_alloc; ice::native_file::HeapFilePath dirpath{ temp_alloc }; - ice::string::reserve(dirpath, 256 * 2); // 512 bytes for paths - ice::string::push_back(dirpath, starting_dir); + dirpath.reserve(256 * 2); // 512 bytes for paths + dirpath.push_back(starting_dir); return traverse_directories_internal(dirpath, dirpath, callback, userdata); } @@ -437,14 +437,14 @@ namespace ice::native_file ) noexcept { // If zero, we failed, check why. - if (CreateDirectory(ice::string::begin(dirpath), NULL) == 0) + if (CreateDirectory(dirpath.begin(), NULL) == 0) { // Try the next path before retrying this path. if (GetLastError() == ERROR_PATH_NOT_FOUND) { // Remove the top-most the directory explicitly. - ice::ucount const dirslash = ice::string::find_last_of(ice::WString{ dirpath }, ice::WString{ L"\\/" }); - if (dirslash == ice::String_NPos) + ice::nindex const dirslash = dirpath.find_last_of(L"\\/"); + if (dirslash == ice::nindex_none) { return false; } @@ -460,7 +460,7 @@ namespace ice::native_file dirpath[dirslash] = '/'; // Try again to create the directory - return CreateDirectory(ice::string::begin(dirpath), NULL) != 0; + return CreateDirectory(dirpath.begin(), NULL) != 0; } // else it's either 'ERROR_ALREADY_EXISTS' so we continue. } @@ -488,7 +488,7 @@ namespace ice::native_file ice::String path_string ) noexcept { - ice::string::clear(out_filepath); + out_filepath.clear(); ice::utf8_to_wide_append(path_string, out_filepath); } @@ -497,7 +497,7 @@ namespace ice::native_file ice::HeapString<>& out_string ) noexcept { - ice::string::clear(out_string); + out_string.clear(); ice::wide_to_utf8_append(path, out_string); } @@ -507,11 +507,11 @@ namespace ice::native_file ) noexcept { // TODO: Think if maybe moving this to a different function is possible? - if (ice::string::any(path) && ice::string::back(path) != L'/' && ice::string::back(path) != L'\\') + if (path.not_empty() && path.back() != L'/' && path.back() != L'\\') { - if (ice::string::front(string) != '/' && ice::string::front(string) != '\\') + if (string.front() != '/' && string.front() != '\\') { - ice::string::push_back(path, L'/'); + path.push_back(L'/'); } } ice::utf8_to_wide_append(string, path); @@ -793,8 +793,8 @@ namespace ice::native_file else if (errno == ENOENT) { // Remove the top-most the directory explicitly. - ice::ucount const dirslash = ice::string::find_last_of(dirpath, ice::String{ "/" }); - if (dirslash == ice::String_NPos) + ice::nindex const dirslash = ice::string::find_last_of(dirpath, ice::String{ "/" }); + if (dirslash == ice::nindex_none) { return false; } diff --git a/source/code/core/utils/private/params.cxx b/source/code/core/utils/private/params.cxx index 93af4206..679f4bd4 100644 --- a/source/code/core/utils/private/params.cxx +++ b/source/code/core/utils/private/params.cxx @@ -1,10 +1,10 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -20,14 +20,14 @@ namespace ice auto to_std(ice::String str) noexcept { - return std::string{ ice::string::begin(str), ice::string::end(str) }; + return std::string{ str.begin(), str.end() }; } auto to_std_or(ice::String str, std::string_view fallback) noexcept { - if (ice::string::any(str)) + if (str.not_empty()) { - return std::string{ ice::string::begin(str), ice::string::end(str) }; + return std::string{ str.begin(), str.end() }; } else { @@ -179,15 +179,15 @@ namespace ice opt->required(ice::has_any(definition.flags, PF::IsRequired)); opt->allow_extra_args(ice::has_all(definition.flags, PF::AllowExtraArgs)); // Arrays have one additional check - if (ice::string::any(definition.description)) + if (definition.description.not_empty()) { opt->description(to_std(definition.description)); } - if (ice::string::any(definition.group)) + if (definition.group.not_empty()) { opt->group(to_std(definition.group)); } - if (ice::string::any(definition.type_name)) + if (definition.type_name.not_empty()) { opt->type_name(to_std(definition.type_name)); } @@ -221,7 +221,7 @@ namespace ice opt->expected(definition.min, definition.max); } - if (ice::string::empty(definition.type_name)) + if (definition.type_name.is_empty()) { opt->type_name("VALUE"); } @@ -299,9 +299,7 @@ namespace ice { auto fn_callback = [&out_value](CLI::results_t const& results) noexcept { - std::string const& arg = results.front(); - out_value._data = arg.data(); - out_value._size = static_cast(arg.size()); + out_value = ice::String{ results.front() }; return true; }; params_setup(app.add_option(to_std(definition.name), ice::move(fn_callback)), definition); @@ -319,7 +317,7 @@ namespace ice auto fn_callback = [&out_value](CLI::results_t const& results) noexcept { std::string const& arg = results.front(); - ice::string::push_back(out_value, ice::String{ std::string_view{ arg } }); + out_value.push_back(ice::String{ std::string_view{ arg } }); return true; }; params_setup(app.add_option(to_std(definition.name), ice::move(fn_callback)), definition); @@ -338,7 +336,7 @@ namespace ice { for (std::string const& result : results) { - ice::array::push_back(out_values, { result.data(), static_cast(result.size()) }); + out_values.push_back({ result.data(), static_cast(result.size()) }); } return true; }; @@ -358,7 +356,7 @@ namespace ice { for (std::string const& result : results) { - ice::array::push_back(out_values, { alloc, ice::String{ std::string_view{ result } } }); + out_values.push_back({ alloc, ice::String{ std::string_view{ result } } }); } return true; }; @@ -380,12 +378,12 @@ namespace ice &alloc = params->_allocator ](CLI::results_t const& results) noexcept { - ice::ucount const result_count = (ice::ucount) std::min( + ice::u32 const result_count = (ice::u32) std::min( results.size(), std::max(typesize.y, 0) ); ice::StackAllocator * 8> stack_alloc; ice::Array ice_results{ result_count <= 8 ? stack_alloc : alloc }; - ice::array::reserve(ice_results, result_count); + ice_results.reserve(result_count); auto it = results.begin(); auto const end = results.end(); @@ -394,14 +392,14 @@ namespace ice while (it != end && valid) { std::string_view const result{ *it }; - if (ice::count(ice_results) == result_count || result.empty()) + if (ice_results.size() == result_count || result.empty()) { valid &= ice_callback(ice_userdata, ice_results); - ice::array::clear(ice_results); + ice_results.clear(); } else if (result.empty() == false) { - ice::array::push_back(ice_results, result); + ice_results.push_back(result); } it += 1; } diff --git a/source/code/core/utils/private/path_utils.cxx b/source/code/core/utils/private/path_utils.cxx index fa8fb624..04ff766c 100644 --- a/source/code/core/utils/private/path_utils.cxx +++ b/source/code/core/utils/private/path_utils.cxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include -#include -#include +#include +#include #include namespace ice::path @@ -28,15 +28,15 @@ namespace ice::path { if constexpr (ice::build::is_windows) { - if (ice::string::size(path) >= 3) + if (path.size() >= 3) { - return path[1] == Separators_Drive[0] && ice::string::find_first_of(Separators_Directory, path[2]) != ice::String_NPos; + return path[1] == Separators_Drive[0] && Separators_Directory.find_first_of(path[2]) != ice::nindex_none; } return false; } else { - return ice::string::any(path) && ice::string::front(path) == Separators_Directory[1]; + return path.not_empty() && path.front() == Separators_Directory[1]; } } @@ -46,45 +46,45 @@ namespace ice::path if constexpr (ice::build::is_windows) { // Only support single-letter drives - return ice::string::size(path) == 3 + return path.size() == 3 && path[1] == Separators_Drive[0] - && ice::string::find_first_of(Separators_Directory, path[2]) != ice::String_NPos; + && path.find_first_of(Separators_Directory, path[2]) != ice::nindex_none; } else { - return ice::string::size(path) == 1 && ice::string::front(path) == Separators_Directory[1]; + return path.size() == 1 && path.front() == Separators_Directory[1]; } } template constexpr auto extension(ice::BasicString str) noexcept -> ice::BasicString { - auto const separator_pos = ice::string::find_last_of(str, Separators_Dot); - return ice::string::substr(str, separator_pos == ice::String_NPos ? ice::string::size(str) : separator_pos); + ice::nindex const separator_pos = str.find_last_of(Separators_Dot); + return str.substr(separator_pos.value_or(str.size())); } template constexpr auto filename(ice::BasicString str) noexcept -> ice::BasicString { - auto const separator_pos = ice::string::find_last_of(str, Separators_Directory); - return ice::string::substr(str, separator_pos == ice::String_NPos ? 0 : separator_pos + 1); + ice::nindex const separator_pos = str.find_last_of(Separators_Directory) + 1; + return str.substr(separator_pos.value_or(0)); } template constexpr auto basename(ice::BasicString str) noexcept -> ice::BasicString { ice::BasicString const name = filename(str); - auto const extension_pos = ice::string::find_last_of(name, Separators_Dot); - return ice::string::substr(name, 0, extension_pos); + auto const extension_pos = name.find_last_of(Separators_Dot); + return name.substr(0, extension_pos); } template constexpr auto directory(ice::BasicString str) noexcept -> ice::BasicString { - auto const separator_pos = ice::string::find_last_of(str, Separators_Directory); - if (separator_pos == ice::String_NPos) + ice::nindex const separator_pos = str.find_last_of(Separators_Directory); + if (separator_pos == ice::nindex_none) { - return ice::string::substr(str, ice::string::size(str), separator_pos); + return str.substr(str.size(), separator_pos); } if constexpr (ice::build::is_windows) @@ -92,11 +92,11 @@ namespace ice::path if (separator_pos > 0 && str[separator_pos - 1] == ':') { // Keep the separator so we end up with C:/ - return ice::string::substr(str, 0, separator_pos + 1); + return str.substr(0, separator_pos + 1); } } - return ice::string::substr(str, 0, separator_pos); + return str.substr(0, separator_pos); } template @@ -109,23 +109,23 @@ namespace ice::path return left; } - if (auto last_char = ice::string::back(left); last_char != Separators_Directory[1]) + if (auto last_char = left.back(); last_char != Separators_Directory[1]) { if (last_char == Separators_Directory[0]) { - ice::string::pop_back(left); + left.pop_back(); } - ice::string::push_back(left, Separators_Directory[1]); + left.push_back(Separators_Directory[1]); } - if (ice::string::front(right) == Separators_Directory[1] || ice::string::front(right) == Separators_Directory[0]) + if (right.front() == Separators_Directory[1] || right.front() == Separators_Directory[0]) { - right = ice::string::substr(right, ice::string::find_first_not_of(right, Separators_Directory)); + right = right.substr(right.find_first_not_of(Separators_Directory)); } if (right != Separators_Dot) { - ice::string::push_back(left, right); + left.push_back(right); } return left; @@ -135,8 +135,8 @@ namespace ice::path auto normalize(ice::HeapString& path) noexcept -> ice::BasicString { bool const abs = detail::is_absolute(path); - CharType const* end = ice::string::end(path); - CharType* const beg = ice::string::begin(path); + CharType const* end = path.end(); + CharType* const beg = path.begin(); if (beg == end) { return path; @@ -177,10 +177,10 @@ namespace ice::path // Find starting position for next solve it = beg; - ice::ucount const begin = ice::string::find_first_of(path, Separators_Drive); - if (begin != ice::String_NPos) + ice::nindex const begin = path.find_first_of(Separators_Drive); + if (begin != ice::nindex_none) { - it += begin + 1; + it = it + begin + 1; } copy_to = it; @@ -214,46 +214,43 @@ namespace ice::path copy_to += 1; } - ice::string::resize( - path, - ice::ucount(copy_to - beg) - ); + path.resize(copy_to - beg); return path; } template auto replace_filename(ice::HeapString& str, ice::BasicString name) noexcept -> ice::BasicString { - auto const separator_pos = ice::string::find_last_of(str, Separators_Directory); - if (separator_pos != ice::String_NPos) + auto const separator_pos = str.find_last_of(Separators_Directory); + if (separator_pos != ice::nindex_none) { - ice::string::resize(str, separator_pos + 1); + str.resize(separator_pos + 1); } else { - ice::string::clear(str); + str.clear(); } - ice::string::push_back(str, name); + str.push_back(name); return str; } template auto replace_extension(ice::HeapString& str, ice::BasicString extension) noexcept -> ice::BasicString { - auto const separator_pos = ice::string::find_last_of(str, Separators_Dot[0]); - if (separator_pos != ice::String_NPos) + auto const separator_pos = str.find_last_of(Separators_Dot[0]); + if (separator_pos != ice::nindex_none) { - ice::string::resize(str, separator_pos); + str.resize(separator_pos); } - if (ice::string::empty(extension) == false) + if (str.not_empty()) { - if (ice::string::front(extension) != Separators_Dot[0]) + if (extension.front() != Separators_Dot[0]) { - ice::string::push_back(str, Separators_Dot[0]); + str.push_back(Separators_Dot[0]); } - ice::string::push_back(str, extension); + str.push_back(extension); } return str; } @@ -262,7 +259,7 @@ namespace ice::path bool is_absolute(ice::String path) noexcept { return detail::is_absolute(path); } bool is_absolute_root(ice::String path) noexcept { return detail::is_absolute_root(path); } - auto length(ice::String path) noexcept -> ice::ucount { return ice::string::size(path); } + auto length(ice::String path) noexcept -> ice::u32 { return path.size().u32(); } auto extension(ice::String path) noexcept -> ice::String { return detail::extension(path); } auto filename(ice::String path) noexcept -> ice::String { return detail::filename(path); } auto basename(ice::String path) noexcept -> ice::String { return detail::basename(path); } @@ -274,7 +271,7 @@ namespace ice::path bool is_absolute(ice::WString path) noexcept { return detail::is_absolute(path); } bool is_absolute_root(ice::WString path) noexcept { return detail::is_absolute_root(path); } - auto length(ice::WString path) noexcept -> ice::ucount { return ice::string::size(path); } + auto length(ice::WString path) noexcept -> ice::u32 { return path.size().u32(); } auto extension(ice::WString path) noexcept -> ice::WString { return detail::extension(path); } auto filename(ice::WString path) noexcept -> ice::WString { return detail::filename(path); } auto basename(ice::WString path) noexcept -> ice::WString { return detail::basename(path); } diff --git a/source/code/core/utils/private/string_utils.cxx b/source/code/core/utils/private/string_utils.cxx index f3c0d61d..4310361c 100644 --- a/source/code/core/utils/private/string_utils.cxx +++ b/source/code/core/utils/private/string_utils.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -17,8 +17,8 @@ namespace ice { #if ISP_WINDOWS ice::u32 const comp_result = check_case == CaseSensitive::Yes - ? strncmp(ice::string::begin(left), ice::string::begin(right), count) - : strnicmp(ice::string::begin(left), ice::string::begin(right), count); + ? strncmp(left.begin(), right.begin(), count) + : strnicmp(left.begin(), right.begin(), count); #elif ISP_UNIX ice::u32 const comp_result = check_case == CaseSensitive::Yes ? strncmp(ice::string::begin(left), ice::string::begin(right), count) @@ -34,11 +34,11 @@ namespace ice ice::CaseSensitive check_case /*= CaseSensitive::No*/ ) noexcept -> ice::CompareResult { - ice::u32 const max_size = ice::min(ice::size(left), ice::size(right)); + ice::ncount const max_size = ice::min(left.size(), right.size()); #if ISP_WINDOWS ice::u32 const comp_result = check_case == CaseSensitive::Yes - ? strncmp(ice::string::begin(left), ice::string::begin(right), max_size) - : strnicmp(ice::string::begin(left), ice::string::begin(right), max_size); + ? strncmp(left.begin(), right.begin(), max_size) + : strnicmp(left.begin(), right.begin(), max_size); #elif ISP_UNIX ice::u32 const comp_result = check_case == CaseSensitive::Yes ? strncmp(ice::string::begin(left), ice::string::begin(right), max_size) @@ -56,8 +56,8 @@ namespace ice ice::i32 const chars_written = MultiByteToWideChar( CP_UTF8, 0, - ice::string::begin(utf8_str), - ice::string::size(utf8_str), + utf8_str.begin(), + utf8_str.size().u32(), nullptr, 0 ); @@ -74,28 +74,28 @@ namespace ice ) noexcept { #if ISP_WINDOWS - ice::i32 const required_size = MultiByteToWideChar( + ice::ncount const required_size = MultiByteToWideChar( CP_UTF8, 0, - ice::string::begin(utf8_str), - ice::string::size(utf8_str), + utf8_str.begin(), + utf8_str.size().u32(), NULL, 0 ); if (required_size != 0) { - ice::u32 const current_size = ice::string::size(out_str); - ice::u32 const total_size = static_cast(required_size) + ice::string::size(out_str); - ice::string::resize(out_str, total_size); + ice::ncount const current_size = out_str.size(); + ice::ncount const total_size = required_size + out_str.size(); + out_str.resize(total_size); - ice::i32 const chars_written = MultiByteToWideChar( + ice::ncount const chars_written = MultiByteToWideChar( CP_UTF8, 0, - ice::string::begin(utf8_str), - ice::string::size(utf8_str), - ice::string::begin(out_str) + current_size, - ice::string::size(out_str) - current_size + utf8_str.begin(), + utf8_str.size().u32(), + out_str.begin() + current_size, + out_str.size().u32() - current_size.u32() ); ICE_ASSERT( @@ -132,8 +132,8 @@ namespace ice ice::i32 const required_size = WideCharToMultiByte( CP_UTF8, 0, - ice::string::begin(path), - ice::string::size(path), + path.begin(), + path.size().u32(), NULL, 0, NULL, @@ -152,20 +152,20 @@ namespace ice ) noexcept { #if ISP_WINDOWS - ice::i32 const required_size = wide_to_utf8_size(path); + ice::ncount const required_size = wide_to_utf8_size(path); if (required_size != 0) { - ice::u32 const current_size = ice::string::size(out_str); - ice::u32 const total_size = static_cast(required_size) + ice::string::size(out_str); - ice::string::resize(out_str, total_size); + ice::ncount const current_size = out_str.size(); + ice::ncount const total_size = required_size + out_str.size(); + out_str.resize(total_size); ice::i32 const chars_written = WideCharToMultiByte( CP_UTF8, 0, - ice::string::begin(path), - ice::string::size(path), - ice::string::begin(out_str) + current_size, - ice::string::size(out_str) - current_size, + path.begin(), + path.size().u32(), + out_str.begin() + current_size, + out_str.size().u32() - current_size.u32(), NULL, NULL ); diff --git a/source/code/core/utils/public/ice/algorithm.hxx b/source/code/core/utils/public/ice/algorithm.hxx index 169e1696..0423731c 100644 --- a/source/code/core/utils/public/ice/algorithm.hxx +++ b/source/code/core/utils/public/ice/algorithm.hxx @@ -11,7 +11,7 @@ namespace ice template constexpr auto accumulate(ice::Span range, U val) noexcept { - return ::std::accumulate(ice::begin(range), ice::end(range), val); + return ::std::accumulate(range.begin(), range.end(), val); } } // namespace ice diff --git a/source/code/core/utils/public/ice/config/config_builder.hxx b/source/code/core/utils/public/ice/config/config_builder.hxx index 9dbfa9f0..c01061c0 100644 --- a/source/code/core/utils/public/ice/config/config_builder.hxx +++ b/source/code/core/utils/public/ice/config/config_builder.hxx @@ -1,10 +1,10 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once +#include #include -#include -#include +#include namespace ice { diff --git a/source/code/core/utils/public/ice/config/config_details.hxx b/source/code/core/utils/public/ice/config/config_details.hxx index 77fd421a..85874c32 100644 --- a/source/code/core/utils/public/ice/config/config_details.hxx +++ b/source/code/core/utils/public/ice/config/config_details.hxx @@ -1,9 +1,9 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include namespace ice { diff --git a/source/code/core/utils/public/ice/config/config_impl.hxx b/source/code/core/utils/public/ice/config/config_impl.hxx index 5278f498..f5cf5075 100644 --- a/source/code/core/utils/public/ice/config/config_impl.hxx +++ b/source/code/core/utils/public/ice/config/config_impl.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include namespace ice::config::detail { @@ -132,13 +132,13 @@ namespace ice::config::detail } ice::ErrorCode result = S_Ok; - ice::array::reserve(out_values, table_size); + out_values.reserve(table_size); do { T temp_value; if (result = ice::config::detail::get(config, entry_key, entry_value, temp_value, flags); result == S_Ok) { - ice::array::push_back(out_values, temp_value); + out_values.push_back(temp_value); } else if (result != E_ConfigValueTypeMissmatch) { diff --git a/source/code/core/utils/public/ice/expected.hxx b/source/code/core/utils/public/ice/expected.hxx index 5c57a25f..245953e0 100644 --- a/source/code/core/utils/public/ice/expected.hxx +++ b/source/code/core/utils/public/ice/expected.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/core/utils/public/ice/log.hxx b/source/code/core/utils/public/ice/log.hxx index 0071d6a8..8b518817 100644 --- a/source/code/core/utils/public/ice/log.hxx +++ b/source/code/core/utils/public/ice/log.hxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include #include #include diff --git a/source/code/core/utils/public/ice/log_formatters.hxx b/source/code/core/utils/public/ice/log_formatters.hxx index 72de9b49..de13f69b 100644 --- a/source/code/core/utils/public/ice/log_formatters.hxx +++ b/source/code/core/utils/public/ice/log_formatters.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -15,7 +15,7 @@ struct fmt::formatter> : public fmt::formatter constexpr auto format(ice::BasicString value, FormatContext& ctx) const noexcept { - return fmt::formatter>::format({ value._data, value._size }, ctx); + return fmt::formatter>::format(value, ctx); } }; @@ -82,6 +82,22 @@ struct fmt::formatter> } }; +template<> +struct fmt::formatter +{ + template + constexpr auto parse(ParseContext& ctx) + { + return ctx.begin(); + } + + template + constexpr auto format(ice::ncount value, FormatContext& ctx) const noexcept + { + return fmt::format_to(ctx.out(), "{}", value.native()); + } +}; + template<> struct fmt::formatter { diff --git a/source/code/core/utils/public/ice/log_sink.hxx b/source/code/core/utils/public/ice/log_sink.hxx index 043722fb..3d674511 100644 --- a/source/code/core/utils/public/ice/log_sink.hxx +++ b/source/code/core/utils/public/ice/log_sink.hxx @@ -1,9 +1,9 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include namespace ice { diff --git a/source/code/core/utils/public/ice/log_tag.hxx b/source/code/core/utils/public/ice/log_tag.hxx index 4df6d1a5..e05c11ce 100644 --- a/source/code/core/utils/public/ice/log_tag.hxx +++ b/source/code/core/utils/public/ice/log_tag.hxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include namespace ice { diff --git a/source/code/core/utils/public/ice/native_aio.hxx b/source/code/core/utils/public/ice/native_aio.hxx index d05c9aa4..8287f346 100644 --- a/source/code/core/utils/public/ice/native_aio.hxx +++ b/source/code/core/utils/public/ice/native_aio.hxx @@ -1,8 +1,8 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once -#include +#include namespace ice::native_aio { @@ -11,7 +11,7 @@ namespace ice::native_aio struct AIOPortInfo { - ice::ucount worker_limit = 1; + ice::u32 worker_limit = 1; ice::String debug_name; }; @@ -68,6 +68,6 @@ namespace ice::native_aio auto aio_process_events( ice::native_aio::AIOPort port, ice::native_aio::AIOProcessLimits limits = {} - ) noexcept -> ice::ucount; + ) noexcept -> ice::u32; } // namespace ice::native_aio diff --git a/source/code/core/utils/public/ice/params_types.hxx b/source/code/core/utils/public/ice/params_types.hxx index 6222659d..21a1096e 100644 --- a/source/code/core/utils/public/ice/params_types.hxx +++ b/source/code/core/utils/public/ice/params_types.hxx @@ -1,10 +1,10 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include -#include +#include #include #include diff --git a/source/code/core/utils/public/ice/path_utils.hxx b/source/code/core/utils/public/ice/path_utils.hxx index e347ee7d..88cbb648 100644 --- a/source/code/core/utils/public/ice/path_utils.hxx +++ b/source/code/core/utils/public/ice/path_utils.hxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include namespace ice::path { @@ -16,7 +16,7 @@ namespace ice::path bool is_absolute_root(ice::String path) noexcept; //! \return The lenght of the path. - auto length(ice::String path) noexcept -> ice::ucount; + auto length(ice::String path) noexcept -> ice::u32; //! \return The last extension part (with the dot character) or empty string if no extension was found. auto extension(ice::String path) noexcept -> ice::String; @@ -59,7 +59,7 @@ namespace ice::path bool is_absolute(ice::WString path) noexcept; bool is_absolute_root(ice::WString path) noexcept; - auto length(ice::WString path) noexcept -> ice::ucount; + auto length(ice::WString path) noexcept -> ice::u32; auto extension(ice::WString path) noexcept -> ice::WString; auto filename(ice::WString path) noexcept -> ice::WString; auto basename(ice::WString path) noexcept -> ice::WString; diff --git a/source/code/core/utils/public/ice/string_utils.hxx b/source/code/core/utils/public/ice/string_utils.hxx index 9486898b..7caeff63 100644 --- a/source/code/core/utils/public/ice/string_utils.hxx +++ b/source/code/core/utils/public/ice/string_utils.hxx @@ -1,10 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once -#include -#include -#include +#include +#include #include #include #include @@ -19,7 +18,7 @@ namespace ice template constexpr void push_format( - ice::HeapString& str, + ice::string::ResizableStringType auto& str, fmt::format_string format, Args&&... args ) noexcept; @@ -74,8 +73,8 @@ namespace ice if constexpr (std::is_integral_v) { fc_res = std::from_chars( - ice::string::begin(str), - ice::string::end(str), + str.begin(), + str.end(), out_value ); } @@ -86,8 +85,8 @@ namespace ice // We don't try to handle errors in this version. fc_res.ec = std::errc{}; char* ptr_end = nullptr; // Why the hell is this a char ptr? - out_value = strtof(ice::string::begin(str), &ptr_end); - ICE_ASSERT_CORE(ice::ptr_distance(ice::string::begin(str), ptr_end).value <= ice::size(str)); + out_value = strtof(str.begin(), &ptr_end); + ICE_ASSERT_CORE(ice::ptr_distance(str.begin(), ptr_end).value <= str.size()); fc_res.ptr = ptr_end; #else fc_res = std::from_chars( @@ -110,7 +109,7 @@ namespace ice return { .ec = res, - .remaining = ice::String{ fc_res.ptr, ice::string::end(str) } + .remaining = ice::String{ fc_res.ptr, str.end() } }; } @@ -186,20 +185,19 @@ namespace ice template constexpr void push_format( - ice::HeapString& str, + ice::string::ResizableStringType auto& str, fmt::format_string format, Args&&... args ) noexcept { - ice::u32 const size = ice::u32(fmt::formatted_size(format, ice::forward(args)...)); - ice::u32 const new_size = ice::string::size(str) + size; - if (new_size + 1 >= str._capacity) + ice::ncount const pushed_size = fmt::formatted_size(format, ice::forward(args)...); + ice::ncount const final_size = str.size() + pushed_size; + if (final_size + 1 >= str.capacity()) { - ice::string::grow(str, new_size + 1); + str.grow(final_size + 1); } - fmt::format_to_n(ice::string::end(str), size, format, ice::forward(args)...); - str._size += size; - str._data[str._size] = '\0'; + fmt::format_to_n(str.end(), pushed_size, format, ice::forward(args)...); + str.resize(final_size); } template @@ -209,31 +207,30 @@ namespace ice Args&&... args ) noexcept { - ice::u32 const size = ice::u32(fmt::formatted_size(format, ice::forward(args)...)); - ice::u32 new_size = ice::string::size(str) + size; - if (new_size + 1 >= Capacity) + ice::ncount const pushed_size = fmt::formatted_size(format, ice::forward(args)...); + ice::ncount const final_size = str.size() + pushed_size; + if (final_size + 1 >= Capacity) { - new_size = Capacity - 1; + final_size = Capacity - 1; } - fmt::format_to_n(ice::string::end(str), new_size, format, ice::forward(args)...); - str._size += new_size; - str._data[str._size] = '\0'; + fmt::format_to_n(str.end(), final_size, format, ice::forward(args)...); + str.resize(final_size); } template constexpr auto for_each_split(ice::String contents, ice::String separator, Fn&& fn) noexcept -> ice::u32 { ice::u32 count = 0; - while(ice::string::any(contents)) + while(contents.not_empty()) { count += 1; - ice::ucount const separator_pos = ice::string::find_first_of(contents, separator); - ice::String const line = ice::string::substr(contents, 0, separator_pos); + ice::nindex const separator_pos = contents.find_first_of(separator); + ice::String const line = contents.substr(0, separator_pos); if (ice::forward(fn)(line) == false) { break; } - contents = ice::string::substr(contents, separator_pos + 1); + contents = contents.substr(separator_pos + 1); } return count; } diff --git a/source/code/core/utils/utils_tests.bff b/source/code/core/utils/utils_tests.bff index e97f6afe..991c00bf 100644 --- a/source/code/core/utils/utils_tests.bff +++ b/source/code/core/utils/utils_tests.bff @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT .Project = @@ -29,7 +29,7 @@ .UnitTests = [ - .Enabled = true + .Enabled = false ] ] .Projects + .Project diff --git a/source/code/framework/framework_base/private/asset/tilemap/asset_tilemap_oven_tmx.cxx b/source/code/framework/framework_base/private/asset/tilemap/asset_tilemap_oven_tmx.cxx index 9d2190bc..02db7c69 100644 --- a/source/code/framework/framework_base/private/asset/tilemap/asset_tilemap_oven_tmx.cxx +++ b/source/code/framework/framework_base/private/asset/tilemap/asset_tilemap_oven_tmx.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "asset_tilemap.hxx" @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -141,14 +140,14 @@ namespace ice Fn&& tileid_callback ) noexcept { - ice::String csv_data{ node_data->value(), ice::ucount(node_data->value_size()) }; + ice::String csv_data{ node_data->value(), ice::u32(node_data->value_size()) }; - ice::u32 beg = 0; - ice::u32 end = ice::string::find_first_of(csv_data, ','); - while (end != ice::String_NPos) + ice::nindex beg = 0; + ice::nindex end = csv_data.find_first_of(','); + while (end != ice::nindex_none) { - char const* val_beg = ice::string::begin(csv_data) + beg; - char const* val_end = ice::string::begin(csv_data) + end; + char const* val_beg = csv_data.begin() + beg; + char const* val_end = csv_data.begin() + end; while (std::isdigit(*val_beg) == false && val_beg != val_end) { @@ -162,12 +161,12 @@ namespace ice } beg = end + 1; - end = ice::string::find_first_of(csv_data, ',', beg); + end = csv_data.find_first_of(',', beg); } { - char const* val_beg = ice::string::begin(csv_data) + beg; - char const* val_end = ice::string::begin(csv_data) + node_data->value_size(); + char const* val_beg = csv_data.begin() + beg; + char const* val_end = csv_data.begin() + node_data->value_size(); while (std::isdigit(*val_beg) == false && val_beg != val_end) { @@ -188,14 +187,14 @@ namespace ice Fn&& point_callback ) noexcept { - char const* const data = ice::string::begin(points); + char const* const data = points.begin(); - ice::u32 beg = 0; - ice::u32 end = ice::string::find_first_of(points, ' '); - while (end != ice::String_NPos) + ice::nindex beg = 0; + ice::nindex end = points.find_first_of(' '); + while (end != ice::nindex_none) { char const* val_beg = data + beg; - char const* val_delim = data + ice::string::find_first_of(points, ',', beg); + char const* val_delim = data + points.find_first_of(',', beg); char const* val_end = data + end; while (std::isdigit(*val_beg) == false && val_beg != val_end) @@ -213,13 +212,13 @@ namespace ice } beg = end + 1; - end = ice::string::find_first_of(points, ' ', beg); + end = points.find_first_of(' ', beg); } { char const* val_beg = data + beg; - char const* val_delim = data + ice::string::find_first_of(points, ',', beg); - char const* val_end = data + ice::string::size(points); + char const* val_delim = data + points.find_first_of(',', beg); + char const* val_end = data + points.size(); while (std::isdigit(*val_beg) == false && val_beg != val_end) { @@ -875,8 +874,8 @@ namespace ice } ice::String origin = ice::resource_path(image_res); - ice::String name = ice::string::substr(origin, 0, ice::string::find_last_of(origin, '.')); - total_tileset_assets_size += ice::string::size(name) + 1; + ice::String name = origin.substr(0, origin.find_last_of('.').u32()); + total_tileset_assets_size += name.size().u32() + 1; } total_tilemap_bytes += total_tileset_assets_size; @@ -929,24 +928,24 @@ namespace ice image_res = resource_tracker.find_resource({ ice::Scheme_URN, ice::resource_path(image_res) }); ice::String origin = ice::resource_path(image_res); - ice::String name = ice::string::substr(origin, 0, ice::string::find_last_of(origin, '.')); - char const* tileset_asset_str = ice::string::begin(name); - ice::u32 const tileset_asset_len = ice::string::size(name); + ice::String name = origin,substr(0, origin.find_last_of('.')); + char const* tileset_asset_str = name.begin(); + ice::ncount const tileset_asset_len = name.size(); ice::memcpy( tileset_assets, tileset_asset_str, - tileset_asset_len + tileset_asset_len.bytes() ); tilesets[idx].element_size = tilemap_info.tileset_info[idx].element_size; ice::u32* asset_loc = reinterpret_cast(&tilesets[idx].asset);// = ice::String{ tileset_assets, tileset_asset_len }; asset_loc[0] = asset_str_offset; - asset_loc[1] = tileset_asset_len; + asset_loc[1] = tileset_asset_len.u32(); tileset_assets += tileset_asset_len; - asset_str_offset += tileset_asset_len; + asset_str_offset += tileset_asset_len.u32(); } if (result == true) @@ -1058,7 +1057,7 @@ namespace ice { if (node != nullptr) { - return ice::String{ node->name(), ice::ucount(node->name_size()) }; + return ice::String{ node->name(), ice::u32(node->name_size()) }; } return { }; } @@ -1068,7 +1067,7 @@ namespace ice { if (attrib != nullptr) { - out_value = ice::String{ attrib->value(), ice::ucount(attrib->value_size()) }; + out_value = ice::String{ attrib->value(), ice::u32(attrib->value_size()) }; return true; } return false; diff --git a/source/code/framework/framework_base/private/framework_main.cxx b/source/code/framework/framework_base/private/framework_main.cxx index 5da6a90e..79177b37 100644 --- a/source/code/framework/framework_base/private/framework_main.cxx +++ b/source/code/framework/framework_base/private/framework_main.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -58,7 +58,7 @@ #include #include #include -#include +#include #include #include @@ -338,15 +338,15 @@ auto ice_setup( ice::path::join(config.dev_dirs.assets, "../source/data"); ice::path::normalize(config.dev_dirs.shaders); ice::path::normalize(config.dev_dirs.assets); - ice::string::push_back(config.dev_dirs.shaders, '/'); - ice::string::push_back(config.dev_dirs.assets, '/'); - ice::array::push_back(resource_paths, config.dev_dirs.assets); - ice::array::push_back(resource_paths, config.dev_dirs.shaders); + config.dev_dirs.shaders.push_back('/'); + config.dev_dirs.assets.push_back('/'); + resource_paths.push_back(config.dev_dirs.assets); + resource_paths.push_back(config.dev_dirs.shaders); } else { dylib_path = storage->dylibs_location(); - ice::array::push_back(resource_paths, storage->data_locations()); + resource_paths.push_back(storage->data_locations()); } ice::framework::Config game_config{ @@ -593,7 +593,7 @@ auto ice_game_frame( co_await runtime.runner->pre_update(new_frame->shards()); // Push input events - ice::array::clear(runtime.input_events); + runtime.input_events.clear(); runtime.input_tracker->process_device_events(state.platform.core->input_events(), runtime.input_events); ice_process_input_events(runtime.input_events, new_frame->shards()); diff --git a/source/code/framework/framework_base/private/traits/trait_sprite_animator.cxx b/source/code/framework/framework_base/private/traits/trait_sprite_animator.cxx index 43ad5ed0..f94d9d2b 100644 --- a/source/code/framework/framework_base/private/traits/trait_sprite_animator.cxx +++ b/source/code/framework/framework_base/private/traits/trait_sprite_animator.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "trait_sprite_animator.hxx" @@ -14,7 +14,6 @@ #include #include #include -#include #include namespace ice diff --git a/source/code/framework/framework_base/private/traits/trait_tilemap.hxx b/source/code/framework/framework_base/private/traits/trait_tilemap.hxx index 2c2ad6f0..788970ac 100644 --- a/source/code/framework/framework_base/private/traits/trait_tilemap.hxx +++ b/source/code/framework/framework_base/private/traits/trait_tilemap.hxx @@ -6,7 +6,7 @@ #include #include -#include +#include namespace ice { diff --git a/source/code/framework/framework_base/private/traits/ui/game_ui_trait.cxx b/source/code/framework/framework_base/private/traits/ui/game_ui_trait.cxx index 792f7b2c..6c0706c2 100644 --- a/source/code/framework/framework_base/private/traits/ui/game_ui_trait.cxx +++ b/source/code/framework/framework_base/private/traits/ui/game_ui_trait.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "render_ui_trait.hxx" @@ -37,8 +37,7 @@ #include #include -#include -#include +#include #include #include #include diff --git a/source/code/iceshard/engine/private/action/action_system.cxx b/source/code/iceshard/engine/private/action/action_system.cxx index 8094b45a..42e2973b 100644 --- a/source/code/iceshard/engine/private/action/action_system.cxx +++ b/source/code/iceshard/engine/private/action/action_system.cxx @@ -8,7 +8,7 @@ #include #include -#include +#include #include namespace ice::action @@ -163,10 +163,7 @@ namespace ice::action if (instance != nullptr) { instance->stage_timeline = ice::timeline::create_timeline(_clock); - ice::array::push_back( - _actions, - instance - ); + _actions.push_back(instance); } } diff --git a/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx b/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx index 9c59b973..7a424e54 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx @@ -1,8 +1,8 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include -#include +#include #include #include #include @@ -36,9 +36,9 @@ namespace ice::ecs { using QueryTypeInfo = ice::ecs::detail::QueryTypeInfo; - ice::u32 const tag_count = ice::count(in_required_tags); - ice::u32 const condition_count = ice::count(in_conditions); - ice::u32 const identifier_count = ice::count(checked_identifiers); + ice::u32 const tag_count = in_required_tags.size().u32(); + ice::u32 const condition_count = in_conditions.size().u32(); + ice::u32 const identifier_count = checked_identifiers.size().u32(); ice::u32 const identifier_last_index = identifier_count - 1; ice::u32 tag_idx = 0; @@ -121,12 +121,12 @@ namespace ice::ecs ice::usize& offset_values_out ) noexcept -> ice::meminfo { - ice::ucount const component_count = ice::span::count(info.component_identifiers); + ice::u32 const component_count = info.component_identifiers.size().u32(); ice::meminfo result = ice::meminfo_of; - offset_name_out = result += ice::meminfo_of * (ice::string::size(name) + 1); + offset_name_out = result += ice::meminfo_of * (name.size() + 1); offset_ids_out = result += ice::meminfo_of * component_count; - offset_values_out = result += ice::meminfo_of * component_count * 3; // 3 = size, alignment, offset + offset_values_out = result += ice::meminfo_of * component_count * 3; // 3 = size, alignment, offset return result; } @@ -146,13 +146,13 @@ namespace ice::ecs , _archetype_names_index{ _allocator } , _archetype_data{ _allocator } { - ice::array::reserve(_archetype_data, ice::ecs::Constant_MaxArchetypeCount); - ice::array::push_back(_archetype_data, nullptr); + _archetype_data.reserve(ice::ecs::Constant_MaxArchetypeCount); + _archetype_data.push_back(nullptr); } ArchetypeIndex::~ArchetypeIndex() noexcept { - for (ArchetypeDataHeader* header : ice::array::slice(_archetype_data, 1)) + for (ArchetypeDataHeader* header : _archetype_data.tailspan()) { ice::usize const size = ArchetypeDataHeader::calculate_meminfo(header->archetype_name, header->archetype_info); _allocator.deallocate( @@ -167,7 +167,7 @@ namespace ice::ecs auto ArchetypeIndex::registered_archetype_count() const noexcept -> ice::u32 { - return ice::array::count(_archetype_data); + return _archetype_data.size().u32(); } auto ArchetypeIndex::register_archetype( @@ -191,7 +191,7 @@ namespace ice::ecs data_block_pool = _default_block_pool.get(); } - ice::u32 const component_count = ice::count(archetype_info.component_identifiers); + ice::u32 const component_count = archetype_info.component_identifiers.size().u32(); ICE_ASSERT( component_count >= 2, @@ -227,10 +227,10 @@ namespace ice::ecs { // Copy archetype name ice::memset(mem_archetype_name, 0); - ice::memcpy(mem_archetype_name, ice::string::data_view(archetype_info.name)); + ice::memcpy(mem_archetype_name, archetype_info.name.data_view()); // Copy the component idnetifiers - ice::memcpy(mem_component_data, ice::span::data_view(archetype_info.component_identifiers)); + ice::memcpy(mem_component_data, archetype_info.component_identifiers.data_view()); component_identifiers = reinterpret_cast(mem_component_data.location); // Calculate where we start storing the u32 values... @@ -238,12 +238,12 @@ namespace ice::ecs // Copy the size and alignment. component_sizes = reinterpret_cast(mem_component_data.location); - ice::memcpy(mem_component_data, ice::span::data_view(archetype_info.component_sizes)); - mem_component_data = ice::ptr_add(mem_component_data, ice::span::size_bytes(archetype_info.component_sizes)); + ice::memcpy(mem_component_data, archetype_info.component_sizes.data_view()); + mem_component_data = ice::ptr_add(mem_component_data, archetype_info.component_sizes.size()); component_alignments = reinterpret_cast(mem_component_data.location); - ice::memcpy(mem_component_data, ice::span::data_view(archetype_info.component_alignments)); - mem_component_data = ice::ptr_add(mem_component_data, ice::span::size_bytes(archetype_info.component_alignments)); + ice::memcpy(mem_component_data, archetype_info.component_alignments.data_view()); + mem_component_data = ice::ptr_add(mem_component_data, archetype_info.component_alignments.size()); // Save location to store calculated offsets component_offsets = reinterpret_cast(mem_component_data.location); @@ -255,7 +255,7 @@ namespace ice::ecs ); } - data_header->archetype_name = ice::String{ (char const*) mem_archetype_name.location, ice::size(archetype_info.name) }; + data_header->archetype_name = ice::String{ (char const*) mem_archetype_name.location, archetype_info.name.size() }; data_header->archetype_identifier = archetype_info.identifier; data_header->archetype_info.data_block_filter = data_block_filter; data_header->archetype_info.component_identifiers = ice::Span{ component_identifiers, component_count }; @@ -267,7 +267,7 @@ namespace ice::ecs // We need now to calculate the number of entities that we can store in the remaining memory. // Additionally calculate the offets each component array will be located at. { - ice::ucount const component_entity_count_max = ice::ecs::detail::calculate_entity_count_for_space( + ice::u32 const component_entity_count_max = ice::ecs::detail::calculate_entity_count_for_space( data_header->archetype_info, data_block_pool->provided_block_size() ); @@ -296,14 +296,14 @@ namespace ice::ecs } } - ice::u32 const archetype_index = ice::array::count(_archetype_data); + ice::u32 const archetype_index = _archetype_data.size().u32(); data_header->archetype_info.archetype_instance = ice::ecs::detail::ArchetypeInstance{ archetype_index }; - ice::array::push_back(_archetype_data, data_header); + _archetype_data.push_back(data_header); ice::hashmap::set(_archetype_index, ice::hash(archetype_info.identifier), archetype_index); // Save the 'index' for the given name - if (ice::string::any(data_header->archetype_name)) + if (data_header->archetype_name.not_empty()) { ice::hashmap::set(_archetype_names_index, ice::hash(data_header->archetype_name), archetype_index); } @@ -315,7 +315,7 @@ namespace ice::ecs ice::String name ) const noexcept -> ice::ecs::Archetype { - ice::u32 const instance_count = ice::array::count(_archetype_data); + ice::u32 const instance_count = _archetype_data.size().u32(); ice::u32 const instance_idx = ice::hashmap::get(_archetype_names_index, ice::hash(name), ice::u32_max); if (instance_idx >= instance_count) { @@ -331,16 +331,16 @@ namespace ice::ecs ice::Span query_tags ) const noexcept { - ice::array::clear(out_archetypes); + out_archetypes.clear(); // We need to skip the first query entry if it's for `ice::ecs::Entity` // This is due to the fact that it's always there and is not taken into account when sorting components by identifiers. - if (ice::span::front(query_info).identifier == ice::ecs::Constant_ComponentIdentifier) + if (query_info.first().identifier == ice::ecs::Constant_ComponentIdentifier) { - query_info = ice::span::subspan(query_info, 1); + query_info = query_info.subspan(1); } - ice::u32 const required_tag_count = ice::count(query_tags); + ice::u32 const required_tag_count = query_tags.size().u32(); ice::u32 const required_component_count = [](auto const& query_conditions) noexcept -> ice::u32 { ice::u32 result = 0; @@ -358,11 +358,11 @@ namespace ice::ecs ); ice::u32 const total_required_type_count = required_component_count + required_tag_count; - for (ArchetypeDataHeader const* entry : ice::array::slice(_archetype_data, 1)) + for (ArchetypeDataHeader const* entry : _archetype_data.tailspan()) { ice::ecs::detail::ArchetypeInstanceInfo const& archetype_info = entry->archetype_info; - ice::u32 const archetype_component_count = ice::count(archetype_info.component_identifiers); + ice::u32 const archetype_component_count = archetype_info.component_identifiers.size().u32(); if (archetype_component_count < total_required_type_count) { continue; @@ -378,7 +378,7 @@ namespace ice::ecs // #todo: we should probably also check for the existance of the EntityHandle in the query. Then the check should be `> 1` if (was_matched) { - ice::array::push_back(out_archetypes, entry->archetype_identifier); + out_archetypes.push_back(entry->archetype_identifier); } } } @@ -389,11 +389,11 @@ namespace ice::ecs ) const noexcept { ICE_ASSERT( - ice::count(archetypes) == ice::count(out_instance_infos), + archetypes.size() == out_instance_infos.size(), "Archetype instance fetch called with different input and output array sizes." ); - ice::u32 const instance_count = ice::array::count(_archetype_data); + ice::u32 const instance_count = _archetype_data.size().u32(); ice::u32 archetype_idx = 0; for (Archetype archetype : archetypes) @@ -417,11 +417,11 @@ namespace ice::ecs ) const noexcept { ICE_ASSERT( - ice::count(archetype_instances) == ice::count(out_instance_infos), + archetype_instances.size() == out_instance_infos.size(), "Archetype instance fetch called with different input and output array sizes." ); - ice::u32 const instance_count = ice::array::count(_archetype_data); + ice::u32 const instance_count = _archetype_data.size().u32(); ice::u32 archetype_idx = 0; for (ice::ecs::detail::ArchetypeInstance archetype_instance : archetype_instances) @@ -443,7 +443,7 @@ namespace ice::ecs ice::ecs::detail::ArchetypeInstanceInfo const*& out_instance_info ) const noexcept { - ice::u32 const instance_count = ice::array::count(_archetype_data); + ice::u32 const instance_count = _archetype_data.size().u32(); ice::u32 const instance_idx = index; if (instance_idx < instance_count) @@ -464,7 +464,7 @@ namespace ice::ecs ice::ecs::detail::DataBlockPool*& out_block_pool ) const noexcept { - ice::u32 const instance_count = ice::array::count(_archetype_data); + ice::u32 const instance_count = _archetype_data.size().u32(); ice::u32 const instance_idx = ice::hashmap::get(_archetype_index, ice::hash(archetype), ice::u32_max); if (instance_idx < instance_count) @@ -486,7 +486,7 @@ namespace ice::ecs ice::ecs::detail::DataBlockPool*& out_block_pool ) const noexcept { - ice::u32 const instance_count = ice::array::count(_archetype_data); + ice::u32 const instance_count = _archetype_data.size().u32(); ice::u32 const instance_idx = static_cast(archetype_instance); if (instance_idx < instance_count) diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx index 510187bf..8e4de4bd 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_index.cxx @@ -2,7 +2,7 @@ /// SPDX-License-Identifier: MIT #include -#include +#include #include #include @@ -44,7 +44,7 @@ namespace ice::ecs _max_entity_count ); - ice::array::reserve(_generation, estimated_entity_count); + _generation.reserve(estimated_entity_count); // #todo: decide if we need this [[maybe_unused]] @@ -56,7 +56,7 @@ namespace ice::ecs auto EntityIndex::count() const noexcept -> ice::u32 { - return ice::array::count(_generation) - ice::queue::count(_free_indices); + return _generation.size().u32() - ice::queue::count(_free_indices); } bool EntityIndex::is_alive(ice::ecs::Entity entity) const noexcept @@ -64,12 +64,12 @@ namespace ice::ecs using ice::ecs::EntityInfo; EntityInfo const info = ice::ecs::entity_info(entity); - return ice::count(_generation) > info.index && _generation[info.index] == info.generation; + return _generation.size() > info.index && _generation[info.index] == info.generation; } auto EntityIndex::create() noexcept -> ice::ecs::Entity { - ice::u32 index = 0; + ice::nindex index = 0; if (ice::queue::count(_free_indices) >= ice::ecs::Constant_MinimumFreeIndicesBeforeReuse) { @@ -78,17 +78,17 @@ namespace ice::ecs } else { - index = ice::array::count(_generation); - ice::array::push_back(_generation, ice::u8{ 0 }); + index = _generation.size(); + _generation.push_back(ice::u8{ 0 }); } - return ice::ecs::detail::make_entity(index, _generation[index]); + return ice::ecs::detail::make_entity(index.u32(), _generation[index]); } bool EntityIndex::create_many(ice::Span out_entities) noexcept { ice::u32 total_indices_taken = 0; - auto out_it = ice::span::begin(out_entities); + auto out_it = out_entities.begin(); ice::u32 indices[256]; ice::i32 free_count = ice::i32(ice::queue::count(_free_indices)) - ice::ecs::Constant_MinimumFreeIndicesBeforeReuse; @@ -96,7 +96,7 @@ namespace ice::ecs { ice::u32 const indices_taken = ice::queue::take_front( _free_indices, - ice::span::subspan(ice::Span{indices}, 0, ice::min(free_count, ice::count(indices))) + ice::Span{ indices }.headspan(free_count) ); for (ice::u32 idx = 0; idx < indices_taken; ++idx) @@ -109,8 +109,8 @@ namespace ice::ecs total_indices_taken += indices_taken; } - ice::u32 gen_index = ice::array::count(_generation); - ice::u32 const missing_entities = ice::count(out_entities) - total_indices_taken; + ice::u32 gen_index = _generation.size().u32(); + ice::u32 const missing_entities = out_entities.size().u32() - total_indices_taken; ice::u32 const final_index = gen_index + missing_entities; if (final_index > 0) @@ -120,7 +120,7 @@ namespace ice::ecs "Moved past the maximum allowed number of entities!" ); - ice::array::resize(_generation, final_index); + _generation.resize(final_index); } while (gen_index < final_index) @@ -156,7 +156,7 @@ namespace ice::ecs bool EntityIndex::recreate(ice::Array& entities, ice::u32 new_count) noexcept { destroy_many(entities); - ice::array::resize(entities, new_count); + entities.resize(new_count); create_many(entities); return false; } diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_operations.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_operations.cxx index 71d52834..138051d7 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_operations.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_operations.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -297,20 +297,20 @@ namespace ice::ecs void EntityOperations::destroy(ice::Span entities) noexcept { - if (ice::span::empty(entities)) + if (entities.is_empty()) { return; } void* handle_loc; - EntityOperation* operation = new_storage_operation(ice::meminfo_of * ice::count(entities), handle_loc); + EntityOperation* operation = new_storage_operation(ice::meminfo_of * entities.size().u32(), handle_loc); operation->archetype = ice::ecs::Archetype::Invalid; operation->entities = reinterpret_cast(handle_loc); - operation->entity_count = ice::count(entities); + operation->entity_count = entities.size().u32(); operation->component_data = nullptr; operation->component_data_size = 0; - ice::memcpy(operation->entities, ice::span::data(entities), ice::span::size_bytes(entities)); + ice::memcpy(operation->entities, entities.data_view()); } auto OperationBuilder::with_data( @@ -318,22 +318,22 @@ namespace ice::ecs ice::Span component_data ) noexcept -> Result { - if (ice::span::empty(entities) || (mode == 2 && index_create_count == 0) || mode == 0) + if (entities.is_empty() || (mode == 2 && index_create_count == 0) || mode == 0) { return Result{ *this }; } - ice::ucount const entity_count = mode == 2 ? index_create_count : ice::count(entities); - ice::ucount const component_count = ice::count(component_info.names); + ice::u32 const entity_count = mode == 2 ? index_create_count : entities.size().u32(); + ice::u32 const component_count = component_info.names.size().u32(); ice::meminfo additional_data_size = ice::meminfo{ filter_data_size, ice::ualign::b_8 }; additional_data_size += ice::meminfo_of * entity_count; // Data for storing component info additional_data_size += ice::meminfo_of; - additional_data_size.size += ice::span::size_bytes(component_info.names); - additional_data_size.size += ice::span::size_bytes(component_info.sizes); - additional_data_size.size += ice::span::size_bytes(component_info.offsets); + additional_data_size.size += component_info.names.size().bytes(); + additional_data_size.size += component_info.sizes.size().bytes(); + additional_data_size.size += component_info.offsets.size().bytes(); // Component data for (ice::Data const& data : component_data) @@ -354,7 +354,7 @@ namespace ice::ecs ice::ecs::Entity* entities_ptr = reinterpret_cast(operation_data); if (mode == 1) { - ice::memcpy(entities_ptr, ice::span::data(entities), ice::span::size_bytes(entities)); + ice::memcpy(entities_ptr, entities.data_view()); } else { @@ -364,10 +364,10 @@ namespace ice::ecs // Set component info object ice::StringID* names_ptr = reinterpret_cast(entities_ptr + entity_count); - ice::memcpy(names_ptr, ice::span::data(component_info.names), ice::span::size_bytes(component_info.names)); + ice::memcpy(names_ptr, component_info.names.data_view()); ice::u32* sizes_ptr = reinterpret_cast(names_ptr + component_count); - ice::memcpy(sizes_ptr, ice::span::data(component_info.sizes), ice::span::size_bytes(component_info.sizes)); + ice::memcpy(sizes_ptr, component_info.sizes.data_view()); ice::u32* offsets_ptr = reinterpret_cast(sizes_ptr + component_count); @@ -398,7 +398,7 @@ namespace ice::ecs ice::memcpy(operation_data, data.location, data.size); // Save the offset - offsets_ptr[component_idx] = ice::ucount(ice::ptr_distance(data_beg, operation_data).value); + offsets_ptr[component_idx] = ice::u32(ice::ptr_distance(data_beg, operation_data).value); operation_data = ice::ptr_add(operation_data, data.size); component_idx += 1; @@ -408,7 +408,7 @@ namespace ice::ecs operation->entities = entities_ptr; operation->entity_count = entity_count; operation->component_data = component_info_ptr; - operation->component_data_size = ice::ucount(ice::ptr_distance(component_info_ptr, operation_data).value); + operation->component_data_size = ice::u32(ice::ptr_distance(component_info_ptr, operation_data).value); operation->filter_data = filter_ptr; if (mode == 2) @@ -424,7 +424,7 @@ namespace ice::ecs { if (mode != 0) { - ice::ucount const entity_count = mode == 2 ? index_create_count : ice::count(entities); + ice::u32 const entity_count = mode == 2 ? index_create_count : entities.size().u32(); ice::meminfo required_memory = ice::meminfo{ filter_data_size, ice::ualign::b_8 }; required_memory += ice::meminfo_of * entity_count; @@ -439,7 +439,7 @@ namespace ice::ecs ice::ecs::Entity* entities_ptr = reinterpret_cast(operation_data); if (mode == 1) { - ice::memcpy(entities_ptr, ice::span::data(entities), ice::span::size_bytes(entities)); + ice::memcpy(entities_ptr, entities.data_view()); } else { @@ -455,7 +455,7 @@ namespace ice::ecs operation->filter_data = filter_ptr; ice::memcpy(operation_data, filter_data, filter_data_size); - ice::memcpy(operation->entities, ice::span::data(entities), ice::span::size_bytes(entities)); + ice::memcpy(operation->entities, entities.data_view()); if (mode == 2) { diff --git a/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx b/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx index 6fb2eb71..03d4b86c 100644 --- a/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx +++ b/source/code/iceshard/engine/private/ecs/ecs_entity_storage.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -50,7 +50,7 @@ namespace ice::ecs if (components[cmp] != ice::StringID_Invalid) { ice::u32 in_arch_idx; - bool const found = ice::binary_search(ice::span::subspan(info.component_identifiers, 1), components[cmp], in_arch_idx); + bool const found = ice::binary_search(info.component_identifiers.subspan(1), components[cmp], in_arch_idx); ICE_ASSERT_CORE(found); out_sizes[cmp] = info.component_sizes[in_arch_idx + 1]; out_offsets[cmp] = info.component_offsets[in_arch_idx + 1]; @@ -92,10 +92,10 @@ namespace ice::ecs ) noexcept { IPT_ZONE_SCOPED; - ice::u32 const entity_count = ice::count(src_entities); + ice::u32 const entity_count = src_entities.size().u32(); - ice::u32 const src_component_count = ice::count(src_info.names); - ice::u32 const dst_component_count = ice::count(dst_info.names); + ice::u32 const src_component_count = src_info.names.size().u32(); + ice::u32 const dst_component_count = dst_info.names.size().u32(); ice::u32 const max_component_count = ice::max(src_component_count, dst_component_count); bool const source_is_smaller = src_component_count < max_component_count; @@ -193,8 +193,8 @@ namespace ice::ecs ) noexcept { IPT_ZONE_SCOPED; - ice::u32 const src_component_count = ice::count(src_info.names); - ice::u32 const dst_component_count = ice::count(dst_info.names); + ice::u32 const src_component_count = src_info.names.size().u32(); + ice::u32 const dst_component_count = dst_info.names.size().u32(); ice::u32 const max_component_count = ice::max(src_component_count, dst_component_count); bool const source_is_smaller = src_component_count < max_component_count; @@ -259,8 +259,8 @@ namespace ice::ecs ) noexcept { IPT_ZONE_SCOPED; - ice::u32 const entity_count = ice::count(src_entities); - ice::u32 const component_count = ice::count(info.names); + ice::u32 const entity_count = src_entities.size().u32(); + ice::u32 const component_count = info.names.size().u32(); // Iterate over each component in the source archetype for (ice::u32 component_index = 0; component_index < component_count; ++component_index) @@ -322,8 +322,8 @@ namespace ice::ecs ice::Span data_blocks ) noexcept { - auto const* it = ice::span::begin(entities_to_remove); - auto const* const end = ice::span::end(entities_to_remove); + auto const* it = entities_to_remove.begin(); + auto const* const end = entities_to_remove.end(); ArchetypeInstance archetype{}; ArchetypeInstanceInfo const* archetype_infos[1]{ nullptr }; @@ -331,7 +331,7 @@ namespace ice::ecs ice::ecs::detail::DataBlock* archetype_block = nullptr; ice::u32 archetype_block_index = ice::u32_max; - ice::ucount dtor_count = 0; + ice::u32 dtor_count = 0; ice::ecs::detail::EntityDestructor const* dtors[5]; ice::u32 dtor_components_sizes[10]; ice::u32 dtor_components_offsets[10]; @@ -546,7 +546,7 @@ namespace ice::ecs } // namespace detail - static constexpr ice::ucount Constant_InitialEntityCount = 1024 * 32; + static constexpr ice::u32 Constant_InitialEntityCount = 1024 * 32; EntityStorage::EntityStorage( ice::Allocator& alloc, @@ -561,8 +561,8 @@ namespace ice::ecs , _data_slots{ _allocator } , _destructors{ _allocator } { - ice::array::reserve(_head_blocks, 100); // 100 archetypes should suffice for now - ice::array::resize(_data_slots, Constant_InitialEntityCount); + _head_blocks.reserve(100); // 100 archetypes should suffice for now + _data_slots.resize(Constant_InitialEntityCount); } EntityStorage::~EntityStorage() noexcept @@ -621,15 +621,15 @@ namespace ice::ecs using ice::ecs::detail::DataBlock; using ice::ecs::detail::ArchetypeInstance; - ice::u32 const existing_count = ice::count(_head_blocks); + ice::u32 const existing_count = _head_blocks.size().u32(); ice::u32 const archetype_count = _archetype_index.registered_archetype_count(); if (existing_count >= archetype_count) { return; // Don't remove archetype headblocks because queries might still reference them. } - ice::array::resize(_head_blocks, archetype_count); - ice::array::resize(_data_blocks, archetype_count); + _head_blocks.resize(archetype_count); + _data_blocks.resize(archetype_count); ice::hashmap::reserve(_destructors, archetype_count); // Setup the empty head blocks for new archetypes. @@ -711,9 +711,9 @@ namespace ice::ecs // [Done] Set Component: {EntityHandle[*], None} // remove // Ensure we have enough data slots - if (ice::array::count(_data_slots) < _entity_index.count()) + if (_data_slots.size() < _entity_index.count()) { - ice::array::resize(_data_slots, _entity_index.count()); + _data_slots.resize(_entity_index.count()); } // Ensure all queries are finished @@ -959,7 +959,7 @@ namespace ice::ecs src_data_details.block_offset = data_block_it_2->block_entity_count - 1; // Get the last entity ice::ecs::Entity const move_entities[1]{ - ice::span::front(ice::ecs::detail::get_entity_array(src_component_info, src_data_details, 1)) + ice::ecs::detail::get_entity_array(src_component_info, src_data_details, 1).first() }; EntityDataSlot const move_slot{ @@ -1112,10 +1112,10 @@ namespace ice::ecs auto EntityStorage::query_data_slots( ice::Span requested, ice::Span out_data_slots - ) const noexcept -> ice::ucount + ) const noexcept -> ice::u32 { ice::u32 idx = 0; - ice::ucount valid = 0; + ice::u32 valid = 0; for (ice::ecs::Entity entity : requested) { ice::ecs::EntityInfo const entity_info = ice::ecs::entity_info(entity); @@ -1153,24 +1153,24 @@ namespace ice::ecs IPT_ZONE_SCOPED; ice::StackAllocator<512_B> archetypes_alloc{}; ice::Array archetypes{ archetypes_alloc }; - ice::array::reserve(archetypes, ice::mem_max_capacity(archetypes_alloc.Constant_InternalCapacity)); + archetypes.reserve(ice::mem_max_capacity(archetypes_alloc.Constant_InternalCapacity)); _archetype_index.find_archetypes(archetypes, query_info, query_tags); - ice::u32 const prev_archetype_count = ice::count(out_instance_infos); - ice::u32 const new_archetype_count = ice::count(archetypes); - ice::array::resize(out_instance_infos, prev_archetype_count + new_archetype_count); - ice::array::reserve(out_data_blocks, prev_archetype_count + new_archetype_count); + ice::ncount const prev_archetype_count = out_instance_infos.size(); + ice::ncount const new_archetype_count = archetypes.size(); + out_instance_infos.resize(prev_archetype_count + new_archetype_count); + out_data_blocks.reserve(prev_archetype_count + new_archetype_count); - _archetype_index.fetch_archetype_instance_infos(archetypes, ice::array::slice(out_instance_infos, prev_archetype_count)); + _archetype_index.fetch_archetype_instance_infos(archetypes, out_instance_infos.tailspan(prev_archetype_count)); - for (ice::ecs::detail::ArchetypeInstanceInfo const* instance : ice::array::slice(out_instance_infos, prev_archetype_count)) + for (ice::ecs::detail::ArchetypeInstanceInfo const* instance : out_instance_infos.tailspan(prev_archetype_count)) { ice::u32 const instance_idx = static_cast(instance->archetype_instance); - ice::array::push_back(out_data_blocks, _data_blocks[instance_idx]); + out_data_blocks.push_back(_data_blocks[instance_idx]); } // Find or create work trackers for queried components - ice::u32 idx = prev_archetype_count; + ice::nindex idx = prev_archetype_count; for (ice::ecs::detail::QueryTypeInfo const& type_info : query_info) { ice::ecs::QueryAccessTracker* tracker = ice::hashmap::get(_access_trackers, ice::hash(type_info.identifier), nullptr); diff --git a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx index d0e6c791..bcd60142 100644 --- a/source/code/iceshard/engine/private/engine_state_tracker_default.cxx +++ b/source/code/iceshard/engine/private/engine_state_tracker_default.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "engine_state_tracker_default.hxx" @@ -49,9 +49,9 @@ namespace ice ice::multi_hashmap::insert( _current_state_index, ice::hash(params.initial.graph.value), - ice::count(_current_state) + _current_state.size().u32() ); - ice::array::push_back(_current_state, initial_state); + _current_state.push_back(initial_state); } else { @@ -71,9 +71,9 @@ namespace ice ice::multi_hashmap::insert( _current_state_index, ice::hash(params.initial.graph.value), - ice::count(_current_state) + _current_state.size().u32() ); - ice::array::push_back(_current_state, initial_state); + _current_state.push_back(initial_state); } ice::hashmap::set( @@ -89,10 +89,7 @@ namespace ice params.committer ); - ice::array::push_back( - _available_triggers, - triggers - ); + _available_triggers.push_back(triggers); return true; } @@ -115,9 +112,9 @@ namespace ice ice::multi_hashmap::insert( _current_state_index, ice::hash(engine_state.graph.value), - ice::count(_current_state) + _current_state.size().u32() ); - ice::array::push_back(_current_state, engine_state); + _current_state.push_back(engine_state); } return true; } @@ -163,12 +160,11 @@ namespace ice auto EngineStateTracker_Default::update_states( ice::ShardContainer const& shards, ice::ShardContainer& out_shards - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { ice::StackAllocator<512_B> temp_alloc; ice::ShardContainer temp_shards{ temp_alloc }; - ice::array::reserve( - temp_shards._data, + temp_shards._data.reserve( ice::mem_max_capacity( ice::size_of, decltype(temp_alloc)::Constant_InternalCapacity diff --git a/source/code/iceshard/engine/private/engine_state_tracker_default.hxx b/source/code/iceshard/engine/private/engine_state_tracker_default.hxx index 0f19d6cb..43d489d3 100644 --- a/source/code/iceshard/engine/private/engine_state_tracker_default.hxx +++ b/source/code/iceshard/engine/private/engine_state_tracker_default.hxx @@ -1,9 +1,9 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include #include #include @@ -58,7 +58,7 @@ namespace ice auto update_states( ice::ShardContainer const& shards, ice::ShardContainer& out_shards - ) noexcept -> ice::ucount override; + ) noexcept -> ice::u32 override; void collect_pending_state( ice::Shard trigger_shard, diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx b/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx index e0d2dfc5..d5890165 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_graph.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "ice_gfx_graph.hxx" @@ -36,27 +36,27 @@ namespace ice::gfx .name = stage.name }; - ice::u32 offset = ice::array::count(out_resources); + ice::u32 offset = out_resources.size().u32(); for (ice::gfx::GfxResource res : stage.depth_stencil) { - ice::array::push_back(out_resources, res); + out_resources.push_back(res); } - stage_copy.depth_stencil = ice::array::slice(out_resources, offset, ice::count(stage.depth_stencil)); - offset += ice::count(stage.depth_stencil); + stage_copy.depth_stencil = out_resources.subspan(offset, stage.depth_stencil.size().u32()); + offset += stage.depth_stencil.size().u32(); for (ice::gfx::GfxResource res : stage.inputs) { - ice::array::push_back(out_resources, res); + out_resources.push_back(res); } - stage_copy.inputs = ice::array::slice(out_resources, offset, ice::count(stage.inputs)); - offset += ice::count(stage.inputs); + stage_copy.inputs = out_resources.subspan(offset, stage.inputs.size().u32()); + offset += stage.inputs.size().u32(); for (ice::gfx::GfxResource res : stage.outputs) { - ice::array::push_back(out_resources, res); + out_resources.push_back(res); } - stage_copy.outputs = ice::array::slice(out_resources, offset, ice::count(stage.outputs)); - offset += ice::count(stage.inputs); + stage_copy.outputs = out_resources.subspan(offset, stage.outputs.size().u32()); + offset += stage.inputs.size().u32(); return stage_copy; } @@ -90,22 +90,22 @@ namespace ice::gfx { if (ice::hashmap::has(_objects, ice::hash(pass.name)) == false) { - ice::ucount res_count = 0; + ice::u32 res_count = 0; for (ice::gfx::GfxGraphStage const& stage : pass.stages) { - res_count += ice::count(stage.depth_stencil) + ice::count(stage.inputs) + ice::count(stage.outputs); + res_count += stage.depth_stencil.size().u32() + stage.inputs.size().u32() + stage.outputs.size().u32(); } IceshardGfxGraphPassObjects gfxpass{ _allocator, pass.name }; - ice::array::reserve(gfxpass.resources, res_count); - ice::array::reserve(gfxpass.stages, ice::count(pass.stages)); + gfxpass.resources.reserve(res_count); + gfxpass.stages.reserve(pass.stages.size().u32()); for (ice::gfx::GfxGraphStage const& stage : pass.stages) { - ice::array::push_back(gfxpass.stages, detail::copy_gfx_pass_stage(stage, gfxpass.resources)); + gfxpass.stages.push_back(detail::copy_gfx_pass_stage(stage, gfxpass.resources)); } - ice::array::push_back(_passes, GfxGraphPass{ .name = pass.name, .stages = gfxpass.stages }); + _passes.push_back(GfxGraphPass{ .name = pass.name, .stages = gfxpass.stages }); ice::hashmap::set(_objects, ice::hash(pass.name), ice::move(gfxpass)); } return true; @@ -130,13 +130,13 @@ namespace ice::gfx ice::vec2u extent = swapchain.extent(); - ice::ucount const count_images = ice::count(resources); + ice::u32 const count_images = resources.size().u32(); - ice::array::clear(out_images); - ice::array::reserve(out_images, count_images); - ice::array::push_back(out_images, Image::Invalid); // First image beeing framebuffer + out_images.clear(); + out_images.reserve(count_images); + out_images.push_back(Image::Invalid); // First image beeing framebuffer - for (GfxResource res : ice::span::subspan(resources, 1)) + for (GfxResource res : resources.subspan(1)) { ImageInfo image_info { .type = ImageType::Image2D, @@ -156,10 +156,7 @@ namespace ice::gfx image_info.usage = ImageUsageFlags::DepthStencilAttachment; } - ice::array::push_back( - out_images, - render_device.create_image(image_info, {}) - ); + out_images.push_back(render_device.create_image(image_info, {})); } ice::u32 fb_idx = 0; @@ -193,7 +190,7 @@ namespace ice::gfx , _clears{ _allocator } , _stages{ ice::move(stages) } { - ice::array::resize(_framebuffers, _swapchain.image_count()); + _framebuffers.resize(_swapchain.image_count()); create_framebuffers( _allocator, @@ -205,7 +202,7 @@ namespace ice::gfx _framebuffers ); - ice::array::resize(_clears, ice::count(_resources)); + _clears.resize(_resources.size()); for (vec4f& ccolor : _clears) { ccolor = vec4f{ 0.2f }; @@ -230,7 +227,7 @@ namespace ice::gfx { device.destroy_framebuffer(framebuffer); } - for (ice::render::Image image : ice::array::slice(_framebuffer_images, 1)) + for (ice::render::Image image : _framebuffer_images.tailspan()) { device.destroy_image(image); } @@ -265,7 +262,7 @@ namespace ice::gfx ice::Array temp_stages{ _allocator }; if (stage_registry.query_stages(_stages._stage_names, temp_stages)) { - for (ice::u32 idx = 0; idx < ice::count(_stages._stage_names); ++idx) + for (ice::u32 idx = 0; idx < _stages._stage_names.size(); ++idx) { ice::u64 const stage_hash = ice::hash(_stages._stage_names[idx]); GfxStage* stage_ptr = temp_stages[idx]; @@ -373,10 +370,10 @@ namespace ice::gfx return false; } - ice::ucount const fb_idx = _context.next_frame(); + ice::u32 const fb_idx = _context.next_frame(); // TODO: Can we do this differently? - if (fb_idx == ice::ucount_max) + if (fb_idx == ice::u32_max) { return false; } @@ -440,7 +437,7 @@ namespace ice::gfx } else if (GfxGraphSnapshot.event & GfxSnapshotEvent::EventNextSubPass && ice::exchange(first_skipped, true)) { - for (ice::StringID_Arg stage : ice::array::slice(_stages._stage_names, stage_idx, _stages._counts[pass_idx])) + for (ice::StringID_Arg stage : _stages._stage_names.subspan(stage_idx, _stages._counts[pass_idx])) { // TODO: Separate update and draw? _stages.apply_stages(stage, &GfxStage::update, frame, _context); @@ -455,7 +452,7 @@ namespace ice::gfx { { IPT_ZONE_SCOPED_NAMED("graph_execute_stages"); - for (ice::StringID_Arg stage : ice::array::slice(_stages._stage_names, stage_idx, _stages._counts[pass_idx])) + for (ice::StringID_Arg stage : _stages._stage_names.subspan( stage_idx, _stages._counts[pass_idx])) { // TODO: Separate update and draw? _stages.apply_stages(stage, &GfxStage::update, frame, _context); @@ -486,7 +483,7 @@ namespace ice::gfx GfxSnapshotEvent result = GfxSnapshotEvent::EventCreateRes; bool pass_boundary = false; - for (ice::u32 idx = ice::count(snapshots) - 1; idx >= 0; --idx) + for (ice::u32 idx = snapshots.size().u32() - 1; idx >= 0; --idx) { GfxGraphSnapshot const prev = snapshots[idx]; diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx b/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx index 9d9e4187..f73fe0c7 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_graph_runtime.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "ice_gfx_graph_runtime.hxx" @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include namespace ice::gfx @@ -20,7 +20,7 @@ namespace ice::gfx ) noexcept { ice::u32 last_pass = 0; - for (ice::u32 idx = 0; idx < ice::count(snapshots); ++idx) + for (ice::u32 idx = 0; idx < snapshots.size().u32(); ++idx) { GfxGraphSnapshot& current = snapshots[idx]; if (current.event & (GfxSnapshotEvent::EventBeginPass | GfxSnapshotEvent::EventNextSubPass | GfxSnapshotEvent::EventEndPass)) @@ -35,7 +35,7 @@ namespace ice::gfx } GfxGraphSnapshot prev{}, next{}; - for (GfxGraphSnapshot const prev_candidate : ice::span::subspan(snapshots, 0, idx)) + for (GfxGraphSnapshot const prev_candidate : snapshots.headspan(idx)) { if (current.resource == prev_candidate.resource) { @@ -43,7 +43,7 @@ namespace ice::gfx } } - for (GfxGraphSnapshot const next_candidate : ice::span::subspan(snapshots, idx + 1)) + for (GfxGraphSnapshot const next_candidate : snapshots.subspan(idx + 1)) { if (current.resource == next_candidate.resource) { @@ -63,12 +63,11 @@ namespace ice::gfx ICE_ASSERT_CORE(prev.event != GfxSnapshotEvent::EventInvalid || next.event != GfxSnapshotEvent::EventInvalid); if (prev.event != GfxSnapshotEvent::EventInvalid) { - current.info = ice::array::count(out_barriers); + current.info = out_barriers.size().u32(); if (current.event & GfxSnapshotEvent::EventReadRes) { - ice::array::push_back( - out_barriers, + out_barriers.push_back( GraphBarrier{ .pass_idx = last_pass, .source_layout = render::ImageLayout::Color, @@ -80,8 +79,7 @@ namespace ice::gfx } else { - ice::array::push_back( - out_barriers, + out_barriers.push_back( GraphBarrier{ .pass_idx = last_pass, .source_layout = render::ImageLayout::Undefined, @@ -113,11 +111,10 @@ namespace ice::gfx ice::Array subpasses{ alloc }; ice::Array dependencies{ alloc }; - ice::array::reserve(attachments, ice::count(resources)); - ice::array::reserve(references, ice::count(graph_snapshots)); + attachments.reserve(resources.size().u32()); + references.reserve(graph_snapshots.size().u32()); - ice::array::push_back( - attachments, + attachments.push_back( RenderAttachment{ .format = swapchain.image_format(), .final_layout = ImageLayout::Present, @@ -138,8 +135,7 @@ namespace ice::gfx } else if (type == GfxResourceType::RenderTarget) { - ice::array::push_back( - attachments, + attachments.push_back( RenderAttachment{ .format = swapchain.image_format(), .final_layout = ImageLayout::ShaderReadOnly, @@ -153,8 +149,7 @@ namespace ice::gfx } else // if (type == GfxResourceType::DepthStencil) { - ice::array::push_back( - attachments, + attachments.push_back( RenderAttachment{ .format = ImageFormat::SFLOAT_D32_UINT_S8, .final_layout = ImageLayout::DepthStencil, @@ -178,11 +173,10 @@ namespace ice::gfx { if (subpass_idx > 1) { - ice::array::push_back( - subpasses, + subpasses.push_back( RenderSubPass{ - .input_attachments = ice::array::slice(references, ref_subpass_idx, counts[0]), - .color_attachments = ice::array::slice(references, ref_subpass_idx + counts[0], counts[1]), + .input_attachments = references.subspan(ref_subpass_idx, counts[0]), + .color_attachments = references.subspan(ref_subpass_idx + counts[0], counts[1]), .depth_stencil_attachment = counts[2] == 0 ? AttachmentReference{ } : references[ref_subpass_idx + counts[0] + counts[1]], } ); @@ -195,8 +189,7 @@ namespace ice::gfx { if (subpass_idx == 2) { - ice::array::push_back( - dependencies, + dependencies.push_back( SubpassDependency{ .source_subpass = subpass_idx - 2, .source_stage = PipelineStage::ColorAttachmentOutput, @@ -209,8 +202,7 @@ namespace ice::gfx } else { - ice::array::push_back( - dependencies, + dependencies.push_back( SubpassDependency{ .source_subpass = subpass_idx - 2, .source_stage = PipelineStage::ColorAttachmentOutput, @@ -234,8 +226,7 @@ namespace ice::gfx if (type == GfxResourceType::DepthStencil) { counts[2] += 1; - ice::array::push_back( - references, + references.push_back( AttachmentReference{ .attachment_index = idx, .layout = ImageLayout::DepthStencil @@ -245,8 +236,7 @@ namespace ice::gfx else if (graph_snapshot.event & GfxSnapshotEvent::EventWriteRes) { counts[1] += 1; - ice::array::push_back( - references, + references.push_back( AttachmentReference{ .attachment_index = idx, .layout = ImageLayout::Color @@ -256,8 +246,7 @@ namespace ice::gfx else { counts[0] += 1; - ice::array::push_back( - references, + references.push_back( AttachmentReference{ .attachment_index = idx, .layout = ImageLayout::ShaderReadOnly @@ -295,11 +284,10 @@ namespace ice::gfx ice::Array snapshots{ alloc }; ice::Array resources{ alloc }; - ice::array::push_back(resources, base_definition.get_framebuffer()); + resources.push_back(base_definition.get_framebuffer()); ice::u32 pass_idx = 0; - ice::array::push_back( - snapshots, + snapshots.push_back( GfxGraphSnapshot{ .subpass = 0, .resource = { pass_idx++ }, @@ -311,8 +299,7 @@ namespace ice::gfx IceshardGfxGraphStages stages{ alloc }; for (GfxGraphPass const& pass : base_definition.passes()) { - ice::array::push_back( - snapshots, + snapshots.push_back( GfxGraphSnapshot{ .subpass = pass_idx, .resource = { pass_idx }, @@ -323,12 +310,11 @@ namespace ice::gfx for (GfxGraphStage const& stage : pass.stages) { - ice::array::push_back(stages._stage_names, stage.name); + stages._stage_names.push_back(stage.name); for (GfxResource res : stage.inputs) { - ice::array::push_back( - snapshots, + snapshots.push_back( GfxGraphSnapshot{ .subpass = pass_idx, .resource = res, @@ -339,8 +325,7 @@ namespace ice::gfx } for (GfxResource res : stage.outputs) { - ice::array::push_back( - snapshots, + snapshots.push_back( GfxGraphSnapshot{ .subpass = pass_idx, .resource = res, @@ -351,8 +336,7 @@ namespace ice::gfx } for (GfxResource res : stage.depth_stencil) { - ice::array::push_back( - snapshots, + snapshots.push_back( GfxGraphSnapshot{ .subpass = pass_idx, .resource = res, @@ -363,12 +347,11 @@ namespace ice::gfx } } - ice::array::push_back(stages._counts, ice::u8(ice::count(pass.stages))); + stages._counts.push_back(pass.stages.size().u8()); pass_idx += 1; } - ice::array::push_back( - snapshots, + snapshots.push_back( GfxGraphSnapshot{ .subpass = pass_idx, .resource = { pass_idx }, @@ -381,9 +364,9 @@ namespace ice::gfx ice::Array barriers{ alloc }; postprocess_snapshots(snapshots, barriers); - ice::ucount max_images = 0; - ice::ucount current_images = 0; - ice::ucount removed_images = 0; + ice::u32 max_images = 0; + ice::u32 current_images = 0; + ice::u32 removed_images = 0; for (GfxGraphSnapshot const snapshot : snapshots) { if (snapshot.event & GfxSnapshotEvent::MaskPass) @@ -398,7 +381,7 @@ namespace ice::gfx bool const res_created = (snapshot.event & GfxSnapshotEvent::EventCreateRes) != 0; if (res_created) { - ice::array::push_back(resources, snapshot.resource); + resources.push_back(snapshot.resource); } current_images += ice::u32(res_created); @@ -407,7 +390,7 @@ namespace ice::gfx } ice::sort( - ice::array::slice(resources), + resources.tailspan(0), [](GfxResource lhs, GfxResource rhs) noexcept { return (lhs.value & 0xffff) < (rhs.value & 0xffff); } ); diff --git a/source/code/iceshard/engine/private/gfx/ice_gfx_stage_registry.cxx b/source/code/iceshard/engine/private/gfx/ice_gfx_stage_registry.cxx index b8153688..8eb9c268 100644 --- a/source/code/iceshard/engine/private/gfx/ice_gfx_stage_registry.cxx +++ b/source/code/iceshard/engine/private/gfx/ice_gfx_stage_registry.cxx @@ -62,7 +62,7 @@ namespace ice::gfx for (ice::StringID_Arg key : stage_keys) { ice::gfx::GfxStage* const* stage_ptr = ice::hashmap::try_get(_stages, ice::hash(key)); - ice::array::push_back(out_stages, stage_ptr == nullptr ? nullptr : *stage_ptr); + out_stages.push_back(stage_ptr == nullptr ? nullptr : *stage_ptr); result |= stage_ptr != nullptr; } return result; diff --git a/source/code/iceshard/engine/private/world_trait.cxx b/source/code/iceshard/engine/private/world_trait.cxx index d448cacc..73e9d1bb 100644 --- a/source/code/iceshard/engine/private/world_trait.cxx +++ b/source/code/iceshard/engine/private/world_trait.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -44,7 +44,7 @@ namespace ice void Trait::send(ice::ShardID shardid, ice::String value, SendMode mode) noexcept { - this->send(shardid | ice::string::begin(value), mode); + this->send(shardid | value.begin(), mode); } void Trait::send(ice::ShardID shardid, ice::Asset asset, SendMode mode) noexcept diff --git a/source/code/iceshard/engine/private/world_trait_module.cxx b/source/code/iceshard/engine/private/world_trait_module.cxx index c68eedf6..b0eab282 100644 --- a/source/code/iceshard/engine/private/world_trait_module.cxx +++ b/source/code/iceshard/engine/private/world_trait_module.cxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include namespace ice { diff --git a/source/code/iceshard/engine/public/ice/action/action_trigger.hxx b/source/code/iceshard/engine/public/ice/action/action_trigger.hxx index 586637f9..307f9fb6 100644 --- a/source/code/iceshard/engine/public/ice/action/action_trigger.hxx +++ b/source/code/iceshard/engine/public/ice/action/action_trigger.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -10,7 +10,7 @@ namespace ice::action { - using ActionTriggerHandler = bool ( + using ActionTriggerHandler = bool( ice::Shard const& user_shard, ice::Shard const& event_shard, ice::Tns stage_time_elapsed diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_archetype.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_archetype.hxx index e846eb71..29bd3cc3 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_archetype.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_archetype.hxx @@ -110,7 +110,7 @@ namespace ice::ecs component_alignments[idx] = sorted_components[idx - 1].alignment; } - identifier = ice::ecs::detail::make_archetype_identifier(ice::span::from_std_const(component_identifiers)); + identifier = ice::ecs::detail::make_archetype_identifier(ice::make_span(component_identifiers)); } template @@ -125,9 +125,9 @@ namespace ice::ecs ) noexcept : name{ archetype_info.name } , identifier{ archetype_info.identifier } - , component_identifiers{ ice::span::from_std_const(archetype_info.component_identifiers) } - , component_sizes{ ice::span::from_std_const(archetype_info.component_sizes) } - , component_alignments{ ice::span::from_std_const(archetype_info.component_alignments) } + , component_identifiers{ ice::make_span(archetype_info.component_identifiers) } + , component_sizes{ ice::make_span(archetype_info.component_sizes) } + , component_alignments{ ice::make_span(archetype_info.component_alignments) } { } diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_archetype_detail.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_archetype_detail.hxx index eefecbd8..5b1a4a53 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_archetype_detail.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_archetype_detail.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -117,13 +117,13 @@ namespace ice::ecs::detail return result; } - constexpr auto calculate_entity_count_for_space(ice::ecs::detail::ArchetypeInstanceInfo const& arch, ice::usize space) noexcept -> ice::ucount + constexpr auto calculate_entity_count_for_space(ice::ecs::detail::ArchetypeInstanceInfo const& arch, ice::usize space) noexcept -> ice::u32 { ice::u32 const component_size_sum = ice::accumulate(arch.component_sizes, 0); ice::u32 const component_alignment_sum = ice::accumulate(arch.component_alignments, 0); ice::usize const available_block_size = { ice::usize::subtract(space, arch.data_block_filter.data_size).value - component_alignment_sum }; - return ice::ucount(available_block_size.value) / component_size_sum; + return ice::u32(available_block_size.value) / component_size_sum; } } // namespace ice::ecs diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_concepts.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_concepts.hxx index 52c6e019..9c80474b 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_concepts.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_concepts.hxx @@ -1,9 +1,9 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include namespace ice::ecs { diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_data_block.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_data_block.hxx index 32590bf7..c8e1a853 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_data_block.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_data_block.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -13,12 +13,12 @@ namespace ice::ecs::detail //! \brief Maximum number of entities this specific data-block can hold. This value can change depending on the block size. //! //! \note It is important to remember that a block is not able to hold more than `ice::ecs::Constant_MaxBlockEntityIndex` entities. - ice::ucount block_entity_count_max = 0; + ice::u32 block_entity_count_max = 0; //! \brief Current number of entities in the block. //! //! \note The `EntityStorage` ensures that all entities are always stored one after another inside blocks without empty data locations. - ice::ucount block_entity_count = 0; + ice::u32 block_entity_count = 0; //! \brief Size of the available data to be used for entity components. ice::usize block_data_size = 0_B; diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx index 3dcb789c..4c269771 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_operations.hxx @@ -1,8 +1,8 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include #include #include @@ -58,13 +58,13 @@ namespace ice::ecs struct Result { - auto one() const noexcept -> ice::ecs::Entity { return ice::span::front(_builder.entities); } + auto one() const noexcept -> ice::ecs::Entity { return _builder.entities.first(); } auto all() const noexcept -> ice::Span { return _builder.entities; } auto store(ice::Array& out_entities, bool append = true) const noexcept { - if (append == false) ice::array::clear(out_entities); - ice::array::push_back(out_entities, all()); + if (append == false) out_entities.clear(); + out_entities.push_back(all()); } Result(OperationBuilder& builder) noexcept : _builder{ builder } { } @@ -82,7 +82,7 @@ namespace ice::ecs ice::ecs::EntityOperations& operations, ice::ecs::Archetype archetype, ice::ecs::EntityIndex& index, - ice::ucount entity_count + ice::u32 entity_count ) noexcept; ~OperationBuilder() noexcept; @@ -241,7 +241,7 @@ namespace ice::ecs ice::ecs::EntityOperations& operations, ice::ecs::Archetype archetype, ice::ecs::EntityIndex& index, - ice::ucount entity_count + ice::u32 entity_count ) noexcept : operations{ operations } , archetype{ archetype } @@ -270,7 +270,7 @@ namespace ice::ecs inline auto EntityOperations::create( ice::ecs::concepts::ArchetypeRef auto ref, - ice::ucount count + ice::u32 count ) noexcept -> ice::ecs::OperationBuilder { return OperationBuilder{ *this, this->get_archetype(ref), _entities, count }; @@ -291,14 +291,14 @@ namespace ice::ecs static ice::ecs::ArchetypeDefinition constexpr HelperArchetype; static ice::StaticArray constexpr ComponentIdxMap = ice::ecs::detail::make_argument_idx_map( - ice::span::from_std_const(HelperArchetype.component_identifiers) + ice::make_span(HelperArchetype.component_identifiers) ); static ice::ecs::OperationComponentInfo constexpr ComponentsInfo{ - .names = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_identifiers), 1), - .sizes = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_sizes), 1), + .names = ice::make_span(HelperArchetype.component_identifiers).tailspan(1), + .sizes = ice::make_span(HelperArchetype.component_sizes).tailspan(1), // We store alignments in this span just for convenience - .offsets = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_alignments), 1) + .offsets = ice::make_span(HelperArchetype.component_alignments).tailspan(1) }; ice::Data const unsorted_component_Data[]{ @@ -311,13 +311,13 @@ namespace ice::ecs sorted_data_array[ComponentIdxMap[idx] - 1] = unsorted_component_Data[idx]; } - return this->with_data(ComponentsInfo, ice::span::from_std_const(sorted_data_array)); + return this->with_data(ComponentsInfo, ice::make_span(sorted_data_array)); } template inline auto OperationBuilder::with_data(ice::Span&... out_component_spans) noexcept -> Result { - if (ice::span::empty(entities) && mode != 2) + if (entities.is_empty() && mode != 2) { return Result{ *this }; } @@ -325,26 +325,26 @@ namespace ice::ecs static ice::ecs::ArchetypeDefinition constexpr HelperArchetype; static ice::StaticArray constexpr ComponentIdxMap = ice::ecs::detail::make_argument_idx_map( - ice::span::from_std_const(HelperArchetype.component_identifiers) + ice::make_span(HelperArchetype.component_identifiers) ); static ice::ecs::OperationComponentInfo constexpr ComponentsInfo{ - .names = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_identifiers), 1), - .sizes = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_sizes), 1), + .names = ice::make_span(HelperArchetype.component_identifiers).tailspan(1), + .sizes = ice::make_span(HelperArchetype.component_sizes).tailspan(1), // We store alignments in this span just for convenience - .offsets = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_alignments), 1) + .offsets = ice::make_span(HelperArchetype.component_alignments).tailspan(1) }; - ice::ucount const entity_count = mode == 2 ? index_create_count : ice::count(entities); - ice::ucount constexpr component_count = sizeof...(Components); + ice::u32 const entity_count = mode == 2 ? index_create_count : ice::count(entities); + ice::u32 constexpr component_count = sizeof...(Components); ice::meminfo additional_data_size = ice::meminfo{ filter_data_size, ice::ualign::b_8 }; additional_data_size += ice::meminfo_of * entity_count; // Data for storing component info additional_data_size += ice::meminfo_of; - additional_data_size.size += ice::span::size_bytes(ComponentsInfo.names); - additional_data_size.size += ice::span::size_bytes(ComponentsInfo.sizes); - additional_data_size.size += ice::span::size_bytes(ComponentsInfo.offsets); + additional_data_size.size += ComponentsInfo.names.size(); + additional_data_size.size += ComponentsInfo.sizes.size(); + additional_data_size.size += ComponentsInfo.offsets.size(); // Use folded expression to calculate all the size for the components... additional_data_size.size += ((ice::usize{ alignof(Components) } + ice::size_of * entity_count) + ...); @@ -362,7 +362,7 @@ namespace ice::ecs ice::ecs::Entity* entities_ptr = reinterpret_cast(operation_data); if (mode == 1) { - ice::memcpy(entities_ptr, ice::span::data(entities), ice::span::size_bytes(entities)); + ice::memcpy(entities_ptr, entities.data_view()); } else { @@ -372,10 +372,10 @@ namespace ice::ecs // Set component info object ice::StringID* names_ptr = reinterpret_cast(entities_ptr + entity_count); - ice::memcpy(names_ptr, ice::span::data(ComponentsInfo.names), ice::span::size_bytes(ComponentsInfo.names)); + ice::memcpy(names_ptr, ComponentsInfo.names.data_view()); ice::u32* sizes_ptr = reinterpret_cast(names_ptr + component_count); - ice::memcpy(sizes_ptr, ice::span::data(ComponentsInfo.sizes), ice::span::size_bytes(ComponentsInfo.sizes)); + ice::memcpy(sizes_ptr, ComponentsInfo.sizes.data_view()); ice::u32* offsets_ptr = reinterpret_cast(sizes_ptr + component_count); @@ -416,7 +416,7 @@ namespace ice::ecs span_ptr->_count = entity_count; // Move to the next data location... - data_ptr = ice::ptr_add(data_ptr, ice::span::size_bytes(*span_ptr)); + data_ptr = ice::ptr_add(data_ptr, span_ptr->size()); return true; }; @@ -444,7 +444,7 @@ namespace ice::ecs operation->entities = entities_ptr; operation->entity_count = entity_count; operation->component_data = component_info_ptr; - operation->component_data_size = ice::ucount(ice::ptr_distance(component_info_ptr, component_info_ptr).value); + operation->component_data_size = ice::u32(ice::ptr_distance(component_info_ptr, component_info_ptr).value); operation->filter_data = filter_ptr; if (mode == 2) @@ -459,7 +459,7 @@ namespace ice::ecs template inline auto OperationBuilder::with_data(ice::Span... component_spans) noexcept -> Result { - if (ice::span::empty(entities) && mode != 2) + if (entities.is_empty() && mode != 2) { return { *this }; } @@ -467,26 +467,26 @@ namespace ice::ecs static ice::ecs::ArchetypeDefinition constexpr HelperArchetype; static ice::StaticArray constexpr ComponentIdxMap = ice::ecs::detail::make_argument_idx_map( - ice::span::from_std_const(HelperArchetype.component_identifiers) + ice::make_span(HelperArchetype.component_identifiers) ); static ice::ecs::OperationComponentInfo constexpr ComponentsInfo{ - .names = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_identifiers), 1), - .sizes = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_sizes), 1), + .names = ice::make_span(HelperArchetype.component_identifiers).tailspan(1), + .sizes = ice::make_span(HelperArchetype.component_sizes).tailspan(1), // We store alignments in this span just for convenience - .offsets = ice::span::subspan(ice::span::from_std_const(HelperArchetype.component_alignments), 1) + .offsets = ice::make_span(HelperArchetype.component_alignments).tailspan(1) }; - ice::ucount const entity_count = mode == 2 ? index_create_count : ice::count(entities); - ice::ucount constexpr component_count = sizeof...(Components); + ice::u32 const entity_count = mode == 2 ? index_create_count : ice::count(entities); + ice::u32 constexpr component_count = sizeof...(Components); ice::meminfo additional_data_size = ice::meminfo{ filter_data_size, ice::ualign::b_8 }; additional_data_size += ice::meminfo_of * entity_count; // Data for storing component info additional_data_size += ice::meminfo_of; - additional_data_size.size += ice::span::size_bytes(ComponentsInfo.names); - additional_data_size.size += ice::span::size_bytes(ComponentsInfo.sizes); - additional_data_size.size += ice::span::size_bytes(ComponentsInfo.offsets); + additional_data_size.size += ComponentsInfo.names.size(); + additional_data_size.size += ComponentsInfo.sizes.size(); + additional_data_size.size += ComponentsInfo.offsets.size(); // Use folded expression to calculate all the size for the components... additional_data_size.size += ((ice::usize{ alignof(Components) } + ice::size_of * entity_count) + ...); @@ -504,7 +504,7 @@ namespace ice::ecs ice::ecs::Entity* entities_ptr = reinterpret_cast(operation_data); if (mode == 1) { - ice::memcpy(entities_ptr, ice::span::data(entities), ice::span::size_bytes(entities)); + ice::memcpy(entities_ptr, entities.data_view()); } else { @@ -514,10 +514,10 @@ namespace ice::ecs // Set component info object ice::StringID* names_ptr = reinterpret_cast(entities_ptr + entity_count); - ice::memcpy(names_ptr, ice::span::data(ComponentsInfo.names), ice::span::size_bytes(ComponentsInfo.names)); + ice::memcpy(names_ptr, ComponentsInfo.names.data_view()); ice::u32* sizes_ptr = reinterpret_cast(names_ptr + component_count); - ice::memcpy(sizes_ptr, ice::span::data(ComponentsInfo.sizes), ice::span::size_bytes(ComponentsInfo.sizes)); + ice::memcpy(sizes_ptr, ComponentsInfo.sizes.data_view()); ice::u32* offsets_ptr = reinterpret_cast(sizes_ptr + component_count); @@ -554,10 +554,10 @@ namespace ice::ecs // Update the span object... SpanType* span_ptr = reinterpret_cast(span_raw_ptr); - ice::memcpy(data_ptr, span_ptr->_data, ice::span::size_bytes(*span_ptr)); + ice::memcpy(data_ptr, span_ptr->data_view()); // Move to the next data location... - data_ptr = ice::ptr_add(data_ptr, ice::span::size_bytes(*span_ptr)); + data_ptr = ice::ptr_add(data_ptr, span_ptr->size()); return true; }; @@ -585,7 +585,7 @@ namespace ice::ecs operation->entities = entities_ptr; operation->entity_count = entity_count; operation->component_data = component_info_ptr; - operation->component_data_size = ice::ucount(ice::ptr_distance(component_info_ptr, component_info_ptr).value); + operation->component_data_size = ice::u32(ice::ptr_distance(component_info_ptr, component_info_ptr).value); operation->filter_data = filter_ptr; if (mode == 2) diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_storage.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_storage.hxx index 35b8fd28..75182aa0 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_entity_storage.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_entity_storage.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -52,7 +52,7 @@ namespace ice::ecs auto query_data_slots( ice::Span requested, ice::Span out_data_slots - ) const noexcept -> ice::ucount override; + ) const noexcept -> ice::u32 override; bool query_archetype_block( ice::ecs::Archetype archetype, diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_awaitable.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_awaitable.hxx index fae9c6f0..6d7f95b7 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_awaitable.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_awaitable.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -74,7 +74,7 @@ namespace ice::ecs inline auto entity_count( ice::ecs::QueryObject const& query, ice::ecs::detail::DataBlockFilter::QueryFilter filter - ) noexcept -> ice::ucount; + ) noexcept -> ice::u32; } // namespace query diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_definition.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_definition.hxx index 5298d1bc..681eb60f 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_definition.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_definition.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -15,7 +15,7 @@ namespace ice::ecs template struct QueryDefinition { - static constexpr ice::ucount Constant_ComponentCount = sizeof...(QueryComponents); + static constexpr ice::u32 Constant_ComponentCount = sizeof...(QueryComponents); static constexpr ice::StaticArray Constant_Requirements = ice::ecs::detail::QueryRequirements::Constant_Requirements; @@ -51,7 +51,7 @@ namespace ice::ecs template struct QueryTagsDefinition { - static constexpr ice::ucount Constant_TagCount = sizeof...(Tags); + static constexpr ice::u32 Constant_TagCount = sizeof...(Tags); static constexpr ice::StaticArray Constant_Tags = ice::ecs::detail::QueryTags::Constant_Tags; }; diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_details.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_details.hxx index 07516903..e1b82b4b 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_details.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_details.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -121,7 +121,7 @@ namespace ice::ecs::detail using QueryEntityIteratorSignature = void (typename QueryIteratorArgument::EntityIteratorArg...); template - using QueryBlockTupleResult = std::tuple::BlockIteratorArg...>; + using QueryBlockTupleResult = std::tuple::BlockIteratorArg...>; template using QueryEntityTupleResult = std::tuple::BlockIteratorArg...>; diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx index 271b3ca2..9e959a6a 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_operations.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -16,7 +16,7 @@ namespace ice::ecs { public: template - inline auto entity_count(this Self&& self) noexcept -> ice::ucount; + inline auto entity_count(this Self&& self) noexcept -> ice::u32; template inline auto for_entity(this Self&& self, ice::ecs::Entity entity) noexcept -> typename ice::clear_type_t::ResultType; @@ -32,7 +32,7 @@ namespace ice::ecs public: template - inline auto block_count(this Self&& self) noexcept -> ice::ucount; + inline auto block_count(this Self&& self) noexcept -> ice::u32; template inline auto for_each_block(this Self&& self) noexcept -> ice::Generator::BlockResultType>; @@ -85,7 +85,7 @@ namespace ice::ecs RefType const& ref = std::get(in_tuple); - static constexpr ice::ucount component_count = sizeof...(SubQueryTypes); + static constexpr ice::u32 component_count = sizeof...(SubQueryTypes); ice::ecs::EntityDataSlot const slotinfo = provider.query_data_slot(ref->entity); ice::u32 arch_idx = 0; @@ -112,7 +112,7 @@ namespace ice::ecs ICE_ASSERT_CORE(arch != nullptr && block != nullptr); void* helper_pointer_array[component_count]{ nullptr }; - ice::Span make_argument_idx_map = ice::span::subspan(archetype_argument_idx_map, arch_idx * component_count, component_count); + ice::Span make_argument_idx_map = archetype_argument_idx_map.subspan(arch_idx * component_count, component_count); for (ice::u32 arg_idx = 0; arg_idx < component_count; ++arg_idx) { @@ -172,7 +172,7 @@ namespace ice::ecs using QueryTypeTuple = std::tuple; using SubQueryTypeTuple = std::tuple; - static constexpr ice::ucount component_count = sizeof...(SubQueryTypes); + static constexpr ice::u32 component_count = sizeof...(SubQueryTypes); void* helper_pointer_array[component_count]{ nullptr }; auto const invoke_for_entity = [&]( @@ -219,7 +219,7 @@ namespace ice::ecs ICE_ASSERT_CORE(arch != nullptr && block != nullptr); - ice::Span make_argument_idx_map = ice::span::subspan(archetype_argument_idx_map, arch_idx * component_count, component_count); + ice::Span make_argument_idx_map = archetype_argument_idx_map.subspan(arch_idx * component_count, component_count); for (ice::u32 arg_idx = 0; arg_idx < component_count; ++arg_idx) { @@ -271,12 +271,12 @@ namespace ice::ecs inline auto entity_count( ice::ecs::QueryObject const& query, ice::ecs::detail::DataBlockFilter::QueryFilter filter - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { // On a query with multiple parts we only want to check the blocks of the main part. - ice::Span const blocks_to_check = ice::array::slice(query.archetype_data_blocks, 0, query.archetype_count_for_part[0]); + ice::Span const blocks_to_check = query.archetype_data_blocks.headspan(query.archetype_count_for_part[0]); - ice::ucount result = 0; + ice::u32 result = 0; for (ice::ecs::detail::DataBlock const* const head_block : blocks_to_check) { // We don't want to count the head-block since it never contains actual entity data. @@ -296,12 +296,12 @@ namespace ice::ecs template inline auto block_count( ice::ecs::QueryObject const& query - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { // On a query with multiple parts we only want to check the blocks of the main part. - ice::Span const blocks_to_check = ice::array::slice(query.archetype_data_blocks, 0, query.archetype_count_for_part[0]); + ice::Span const blocks_to_check = query.archetype_data_blocks.headspan(query.archetype_count_for_part[0]); - ice::ucount result = 0; + ice::u32 result = 0; for (ice::ecs::detail::DataBlock const* const head_block : blocks_to_check) { // We don't want to count the head-block since it never contains actual entity data. @@ -322,7 +322,7 @@ namespace ice::ecs bool allow_failure ) noexcept -> typename ice::ecs::QueryObject::ResultType { - static constexpr ice::ucount component_count = MainPart::ComponentCount; + static constexpr ice::u32 component_count = MainPart::ComponentCount; ice::ecs::EntityDataSlot const slotinfo = query.provider->query_data_slot(entity); ice::u32 arch_idx = 0; @@ -356,8 +356,8 @@ namespace ice::ecs ICE_ASSERT_CORE(arch != nullptr && block != nullptr); void* helper_pointer_array[component_count]{ nullptr }; - ice::Span make_argument_idx_map = ice::array::slice( - query.archetype_argument_idx_map, arch_idx * component_count, component_count + ice::Span make_argument_idx_map = query.archetype_argument_idx_map.subspan( + arch_idx * component_count, component_count ); for (ice::u32 arg_idx = 0; arg_idx < component_count; ++arg_idx) @@ -386,10 +386,10 @@ namespace ice::ecs return ice::ecs::detail::create_entity_tuple_concat( ice::ecs::detail::create_entity_tuple(slotinfo.index, helper_pointer_array, MainPart{}), *query.provider, - ice::array::slice(query.archetype_instances, arch_count), - ice::array::slice(query.archetype_data_blocks, arch_count), - ice::array::slice(query.archetype_argument_idx_map, arch_count * component_count), - ice::span::subspan(ice::Span{ query.archetype_count_for_part }, 1), + query.archetype_instances.headspan(arch_count), + query.archetype_data_blocks.headspan(arch_count), + query.archetype_argument_idx_map.headspan(arch_count * component_count), + ice::Span{ query.archetype_count_for_part }.tailspan(1), RefParts{}... ); } @@ -402,7 +402,7 @@ namespace ice::ecs QueryObjectOwner ) noexcept -> ice::Generator::ResultType> { - static constexpr ice::ucount component_count = MainPart::ComponentCount; + static constexpr ice::u32 component_count = MainPart::ComponentCount; void* helper_pointer_array[component_count]{ nullptr }; @@ -412,7 +412,7 @@ namespace ice::ecs { ice::ecs::detail::ArchetypeInstanceInfo const* arch = query_object.archetype_instances[arch_idx]; ice::ecs::detail::DataBlock const* block = query_object.archetype_data_blocks[arch_idx]; - ice::Span make_argument_idx_map = ice::array::slice(query_object.archetype_argument_idx_map, arch_idx * component_count, component_count); + ice::Span make_argument_idx_map = query_object.archetype_argument_idx_map.subspan(arch_idx * component_count, component_count); // We skip the first block because it will be always empty. ICE_ASSERT_CORE(block->block_entity_count == 0); @@ -437,7 +437,7 @@ namespace ice::ecs } } - ice::ucount entity_idx = 0; + ice::u32 entity_idx = 0; while (entity_idx < block->block_entity_count) { if constexpr (sizeof...(RefParts) == 0) @@ -449,10 +449,10 @@ namespace ice::ecs co_yield ice::ecs::detail::create_entity_tuple_concat( ice::ecs::detail::create_entity_tuple(entity_idx, helper_pointer_array, MainPart{}), *query_object.provider, - ice::array::slice(query_object.archetype_instances, arch_count), - ice::array::slice(query_object.archetype_data_blocks, arch_count), - ice::array::slice(query_object.archetype_argument_idx_map, arch_count * component_count), - ice::span::subspan(ice::Span{ query_object.archetype_count_for_part }, 1), + query_object.archetype_instances.headspan(arch_count), + query_object.archetype_data_blocks.headspan(arch_count), + query_object.archetype_argument_idx_map.headspan(arch_count * component_count), + ice::Span{ query_object.archetype_count_for_part }.tailspan(1), RefParts{}... ); } @@ -472,7 +472,7 @@ namespace ice::ecs ) noexcept { using Definition = typename ice::ecs::QueryObject::Definition; - static constexpr ice::ucount component_count = MainPart::ComponentCount; + static constexpr ice::u32 component_count = MainPart::ComponentCount; void* helper_pointer_array[component_count]{ nullptr }; @@ -482,7 +482,9 @@ namespace ice::ecs { ice::ecs::detail::ArchetypeInstanceInfo const* arch = query_object.archetype_instances[arch_idx]; ice::ecs::detail::DataBlock const* block = query_object.archetype_data_blocks[arch_idx]; - ice::Span make_argument_idx_map = ice::array::slice(query_object.archetype_argument_idx_map, arch_idx * component_count, component_count); + ice::Span make_argument_idx_map = query_object.archetype_argument_idx_map.subspan( + arch_idx * component_count, component_count + ); // We skip the first block because it will be always empty. ICE_ASSERT_CORE(block->block_entity_count == 0); @@ -523,10 +525,10 @@ namespace ice::ecs helper_pointer_array, // Ref parts *query_object.provider, - ice::array::slice(query_object.archetype_instances, arch_count), - ice::array::slice(query_object.archetype_data_blocks, arch_count), - ice::array::slice(query_object.archetype_argument_idx_map, arch_count * component_count), - ice::span::subspan(ice::Span{ query_object.archetype_count_for_part }, 1), + query_object.archetype_instances.headspan(arch_count), + query_object.archetype_data_blocks.headspan(arch_count), + query_object.archetype_argument_idx_map.headspan(arch_count * component_count), + ice::Span{ query_object.archetype_count_for_part }.tailspan(1), MainPart{}, RefParts{}... ); @@ -546,7 +548,7 @@ namespace ice::ecs { static_assert(sizeof...(RefParts) == 0, "'for_each_block' only supports basic queries with no entity references!"); - static constexpr ice::ucount component_count = MainPart::ComponentCount; + static constexpr ice::u32 component_count = MainPart::ComponentCount; void* helper_pointer_array[component_count]{ nullptr }; @@ -555,7 +557,9 @@ namespace ice::ecs { ice::ecs::detail::ArchetypeInstanceInfo const* arch = query.archetype_instances[arch_idx]; ice::ecs::detail::DataBlock const* block = query.archetype_data_blocks[arch_idx]; - ice::Span make_argument_idx_map = ice::array::slice(query.archetype_argument_idx_map, arch_idx * component_count, component_count); + ice::Span make_argument_idx_map = query.archetype_argument_idx_map.subspan( + arch_idx* component_count, component_count + ); // We skip the first block because it will be always empty. ICE_ASSERT_CORE(block->block_entity_count == 0); @@ -595,16 +599,16 @@ namespace ice::ecs ) noexcept { static_assert(sizeof...(RefParts) == 0, "'for_each_block' only supports basic queries with no entity references!"); - static constexpr ice::ucount component_count = MainPart::ComponentCount; + static constexpr ice::u32 component_count = MainPart::ComponentCount; void* helper_pointer_array[component_count]{ nullptr }; - ice::u32 const arch_count = ice::count(query.archetype_instances); + ice::u32 const arch_count = query.archetype_instances.size().u32(); for (ice::u32 arch_idx = 0; arch_idx < arch_count; ++arch_idx) { ice::ecs::detail::ArchetypeInstanceInfo const* arch = query.archetype_instances[arch_idx]; ice::ecs::detail::DataBlock const* block = query.archetype_data_blocks[arch_idx]; - ice::Span make_argument_idx_map = ice::array::slice(query.archetype_argument_idx_map, arch_idx * component_count, component_count); + ice::Span make_argument_idx_map = query.archetype_argument_idx_map.subspan(arch_idx * component_count, component_count); // We skip the first block because it will be always empty. ICE_ASSERT_CORE(block->block_entity_count == 0); @@ -643,13 +647,13 @@ namespace ice::ecs } // namespace query template - inline auto TraitQueryOperations::entity_count(this Self&& self) noexcept -> ice::ucount + inline auto TraitQueryOperations::entity_count(this Self&& self) noexcept -> ice::u32 { return ice::ecs::query::entity_count(self.query_object(), self.filter_object()); } template - inline auto TraitQueryOperations::block_count(this Self&& self) noexcept -> ice::ucount + inline auto TraitQueryOperations::block_count(this Self&& self) noexcept -> ice::u32 { return ice::ecs::query::block_count(self.query_object()); } diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx index f5cef37d..72521ce7 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_provider.hxx @@ -1,8 +1,8 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include #include #include @@ -37,7 +37,7 @@ namespace ice::ecs virtual auto query_data_slots( ice::Span requested, ice::Span out_data_slots - ) const noexcept -> ice::ucount = 0; + ) const noexcept -> ice::u32 = 0; virtual bool query_archetype_block( ice::ecs::Archetype archetype, @@ -79,25 +79,25 @@ namespace ice::ecs { using Part = ice::ecs::detail::QueryObjectPart; - ice::u32 const prev_arch_count = ice::count(out_instance_infos); + ice::u32 const prev_arch_count = out_instance_infos.size().u32(); this->query_internal( - ice::span::from_std_const(Part::Definition::Constant_Requirements), + ice::make_span(Part::Definition::Constant_Requirements), (RefIdx == 0 ? query_tags : ice::Span{}), // We only want to apply tags on the main part out_access_trackers, out_instance_infos, out_data_blocks ); - ice::u32 const new_arch_count = ice::count(out_instance_infos); + ice::u32 const new_arch_count = out_instance_infos.size().u32(); out_archetype_count = new_arch_count - prev_arch_count; - ice::u32 const prev_arim_count = ice::count(out_argument_idx_map); - ice::array::resize(out_argument_idx_map, prev_arim_count + out_archetype_count * Part::ComponentCount); + ice::u32 const prev_arim_count = out_argument_idx_map.size().u32(); + out_argument_idx_map.resize(prev_arim_count + out_archetype_count * Part::ComponentCount); // Copy values to the array - ice::u32* it = ice::array::begin(out_argument_idx_map) + prev_arim_count; - for (ice::ecs::detail::ArchetypeInstanceInfo const* instance : ice::array::slice(out_instance_infos, prev_arch_count)) + ice::u32* it = out_argument_idx_map.begin() + prev_arim_count; + for (ice::ecs::detail::ArchetypeInstanceInfo const* instance : out_instance_infos.tailspan(prev_arch_count)) { auto const archetype_argument_idx_map = ice::ecs::detail::make_argument_idx_map(*instance); ice::memcpy(it, archetype_argument_idx_map.data(), archetype_argument_idx_map.size() * sizeof(ice::u32)); diff --git a/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage_entry.hxx b/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage_entry.hxx index 674174f8..dbc11b17 100644 --- a/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage_entry.hxx +++ b/source/code/iceshard/engine/public/ice/ecs/ecs_query_storage_entry.hxx @@ -59,7 +59,7 @@ namespace ice::ecs { if constexpr (sizeof...(Tags) > 0) { - provider.initialize_query_object(_query_object, ice::span::from_std_const(ice::ecs::QueryTagsDefinition::Constant_Tags)); + provider.initialize_query_object(_query_object, ice::make_span(ice::ecs::QueryTagsDefinition::Constant_Tags)); } else { diff --git a/source/code/iceshard/engine/public/ice/engine_asset_categories.hxx b/source/code/iceshard/engine/public/ice/engine_asset_categories.hxx index 2322da57..1bd96cfb 100644 --- a/source/code/iceshard/engine/public/ice/engine_asset_categories.hxx +++ b/source/code/iceshard/engine/public/ice/engine_asset_categories.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/iceshard/engine/public/ice/engine_data_storage.hxx b/source/code/iceshard/engine/public/ice/engine_data_storage.hxx index dd5e1a7b..cb8b674f 100644 --- a/source/code/iceshard/engine/public/ice/engine_data_storage.hxx +++ b/source/code/iceshard/engine/public/ice/engine_data_storage.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -25,13 +25,13 @@ namespace ice inline auto store(ice::StringID_Arg name) noexcept -> T&; template requires (std::is_trivially_destructible_v>) - inline auto store(ice::StringID_Arg name, ice::ucount size) noexcept -> ice::Span; + inline auto store(ice::StringID_Arg name, ice::u32 size) noexcept -> ice::Span; template requires (std::is_trivially_destructible_v) inline auto read_or_store(ice::StringID_Arg name) noexcept -> T&; template requires (std::is_trivially_destructible_v>) - inline auto read_or_store(ice::StringID_Arg name, ice::ucount size) noexcept -> ice::Span; + inline auto read_or_store(ice::StringID_Arg name, ice::u32 size) noexcept -> ice::Span; template inline auto read(ice::StringID_Arg name) noexcept -> T&; @@ -49,7 +49,7 @@ namespace ice } template requires (std::is_trivially_destructible_v>) - inline auto DataStorage::store(ice::StringID_Arg name, ice::ucount size) noexcept -> ice::Span + inline auto DataStorage::store(ice::StringID_Arg name, ice::u32 size) noexcept -> ice::Span { ice::meminfo minfo = ice::meminfo_of>; ice::usize const offset = minfo += ice::meminfo_of * size; @@ -70,7 +70,7 @@ namespace ice } template requires (std::is_trivially_destructible_v>) - inline auto DataStorage::read_or_store(ice::StringID_Arg name, ice::ucount size) noexcept -> ice::Span + inline auto DataStorage::read_or_store(ice::StringID_Arg name, ice::u32 size) noexcept -> ice::Span { if (this->has(name)) { diff --git a/source/code/iceshard/engine/public/ice/engine_state_tracker.hxx b/source/code/iceshard/engine/public/ice/engine_state_tracker.hxx index 4a2516bc..1ca17154 100644 --- a/source/code/iceshard/engine/public/ice/engine_state_tracker.hxx +++ b/source/code/iceshard/engine/public/ice/engine_state_tracker.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -40,7 +40,7 @@ namespace ice virtual auto update_states( ice::ShardContainer const& shards, ice::ShardContainer& out_shards - ) noexcept -> ice::ucount = 0; + ) noexcept -> ice::u32 = 0; }; auto create_state_tracker( diff --git a/source/code/iceshard/engine/public/ice/gfx/gfx_graph_runtime.hxx b/source/code/iceshard/engine/public/ice/gfx/gfx_graph_runtime.hxx index 3b8983e6..14e3708b 100644 --- a/source/code/iceshard/engine/public/ice/gfx/gfx_graph_runtime.hxx +++ b/source/code/iceshard/engine/public/ice/gfx/gfx_graph_runtime.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include #include diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx index 32141b13..1ba67e81 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.cxx @@ -156,7 +156,7 @@ namespace ice::gfx ) noexcept -> ice::UniquePtr { ice::Array queue_families{ alloc }; - ice::array::reserve(queue_families, 20); + queue_families.reserve(20); render_driver.query_queue_infos(queue_families); using ice::render::QueueFlags; @@ -164,11 +164,11 @@ namespace ice::gfx using ice::render::QueueID; ice::Array queues{ alloc }; - ice::array::reserve(queues, ice::count(render_queues)); + queues.reserve(render_queues.size().u32()); auto find_queue_index = [](auto const& array_, QueueID id_, ice::u32& idx_out) noexcept -> bool { - ice::u32 const size = ice::array::count(array_); + ice::u32 const size = array_.size().u32(); idx_out = 0; while (idx_out < size && array_[idx_out].id != id_) @@ -176,7 +176,7 @@ namespace ice::gfx idx_out += 1; } - return ice::array::count(array_) > idx_out; + return array_.size() > idx_out; }; ice::HashMap queue_index_tracker{ alloc }; @@ -195,8 +195,7 @@ namespace ice::gfx } else { - ice::array::push_back( - queues, + queues.push_back( QueueInfo{ .id = pass_queue_id, .count = 1 @@ -231,15 +230,14 @@ namespace ice::gfx if (render_device != nullptr) { ice::Array pass_groups{ alloc }; - ice::array::reserve(pass_groups, pass_group_count); + pass_groups.reserve(pass_group_count); for (ice::u32 group_pool_index = 0; group_pool_index < pass_group_count; ++group_pool_index) { - ice::array::push_back( - pass_groups, + pass_groups.push_back( alloc.create( alloc, - ice::count(render_queues) + render_queues.size().u32() ) ); } diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.hxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.hxx index 1d009725..d9a236fe 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.hxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_device.hxx @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include "../iceshard_data_storage.hxx" namespace ice::gfx diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx index ccaf5f74..e4ef8f4c 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.cxx @@ -28,7 +28,7 @@ namespace ice::gfx , _primary{ alloc } , _secondary{ alloc } { - ice::array::resize(_primary, 1); + _primary.resize(1); _render_queue->allocate_buffers( _queue_pool_index, ice::render::CommandBufferType::Primary, @@ -84,17 +84,16 @@ namespace ice::gfx ice::Array& cmds = (type == CommandBufferType::Primary) ? _primary : _secondary; ice::u32& used = _cmd_buffers_used[static_cast(type)]; - ice::u32 const available = ice::array::count(cmds) - used; - ice::u32 const required = ice::count(out_buffers); + ice::u32 const available = cmds.size().u32() - used; + ice::u32 const required = out_buffers.size().u32(); if (available < required) { - ice::array::resize(cmds, used + required); - _render_queue->allocate_buffers(_queue_pool_index, type, ice::array::slice(cmds, used)); + cmds.resize(used + required); + _render_queue->allocate_buffers(_queue_pool_index, type, cmds.tailspan(used)); } - auto from = ice::array::slice(cmds, used); - + ice::Span from = cmds.tailspan(used); for (ice::u32 idx = 0; idx < required; ++idx) { out_buffers[idx] = from[idx]; diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.hxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.hxx index 835b2db8..f553558b 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.hxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx index d152bdc7..f996c53a 100644 --- a/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx +++ b/source/code/iceshard/iceshard/private/gfx/iceshard_gfx_queue_group.cxx @@ -112,7 +112,7 @@ namespace ice::gfx { for (IceGfxQueue* queue : _gfx_queues) { - ice::array::push_back(out_names, ice::stringid_hash(queue->name())); + out_names.push_back(ice::stringid_hash(queue->name())); } } @@ -135,8 +135,7 @@ namespace ice::gfx ice::render::RenderQueue* render_queue = queue->render_queue(); if (has_queue(queues_out, render_queue) == false) { - ice::array::push_back( - queues_out, + queues_out.push_back( render_queue ); } diff --git a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx index 007cae75..3888bc45 100644 --- a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx +++ b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_gfx_image_storage_trait.hxx" @@ -51,7 +51,7 @@ namespace ice::gfx ice::String const preview = selected < 0 ? "" : ice::stringid_hint(images[selected].asset.name()); - if (ImGui::BeginCombo("Loaded Image", ice::string::begin(preview))) + if (ImGui::BeginCombo("Loaded Image", preview.begin())) { if (ImGui::Selectable("##empty")) { diff --git a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.hxx b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.hxx index 8418cd5e..95d903aa 100644 --- a/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.hxx +++ b/source/code/iceshard/iceshard/private/gfx/traits/iceshard_gfx_image_storage_trait.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx b/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx index a87ada29..4a6994c7 100644 --- a/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_data_storage.hxx @@ -74,7 +74,7 @@ namespace ice auto do_allocate(ice::AllocRequest request) noexcept -> ice::AllocResult override { ice::AllocResult const r = _backing.allocate(request); - ice::array::push_back(_allocated, r.memory); + _allocated.push_back(r.memory); return r; } diff --git a/source/code/iceshard/iceshard/private/iceshard_frame.cxx b/source/code/iceshard/iceshard/private/iceshard_frame.cxx index b22eff31..19e69540 100644 --- a/source/code/iceshard/iceshard/private/iceshard_frame.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_frame.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_frame.hxx" @@ -20,7 +20,7 @@ namespace ice } , _task_groups{ _frame_data._fwd_allocator } { - ice::array::reserve(_task_groups, 32); + _task_groups.reserve(32); } IceshardEngineFrame::~IceshardEngineFrame() noexcept @@ -30,7 +30,7 @@ namespace ice ICE_ASSERT_CORE(group.barrier->is_set() == true); _frame_data._fwd_allocator.deallocate(group.barrier); } - ice::array::clear(_task_groups); + _task_groups.clear(); ice::hashmap::clear(_data._values); _frame_data._fwd_allocator.reset(); @@ -45,14 +45,14 @@ namespace ice { if (count == 0) return { }; - ice::array::push_back(_task_groups, + _task_groups.push_back( TaskGroup{ .tasks = ice::Array>{ _frame_data._fwd_allocator }, .barrier = _frame_data._fwd_allocator.create() } ); - ice::Array>& result = ice::array::back(_task_groups).tasks; - ice::array::resize(result, count); + ice::Array>& result = _task_groups.last().tasks; + result.resize(count); return result; } @@ -61,55 +61,55 @@ namespace ice ice::u32 task_count = 0; for (TaskGroup& group : _task_groups) { - task_count += ice::count(group.tasks); + task_count += group.tasks.size().u32(); } if (task_count > 0) { ice::Array> final_task_list{ _frame_data._fwd_allocator }; - ice::array::reserve(final_task_list, task_count); + final_task_list.reserve(task_count); for (TaskGroup& group : _task_groups) { for (ice::Task<>& task : group.tasks) { - ice::array::push_back(final_task_list, ice::move(task)); + final_task_list.push_back(ice::move(task)); } - ice::array::clear(group.tasks); + group.tasks.clear(); } co_await ice::await_scheduled_on(final_task_list, scheduler, resumer); } } - auto IceshardEngineFrame::execute_tasks() noexcept -> ice::ucount + auto IceshardEngineFrame::execute_tasks() noexcept -> ice::u32 { - ice::ucount total_count = 0; + ice::u32 total_count = 0; for (TaskGroup& group : _task_groups) { - ice::ucount const current_count = ice::count(group.tasks); + ice::u32 const current_count = group.tasks.size().u32(); // Only reset the barrier if we actual have tasks to execute. if (current_count > 0) { total_count += current_count; - ICE_ASSERT_CORE(ice::count(group.tasks) < ice::u8_max); + ICE_ASSERT_CORE(group.tasks.size() < ice::u8_max); - group.barrier->reset(ice::u8(ice::count(group.tasks))); + group.barrier->reset(group.tasks.size().u8()); ice::manual_wait_for(*group.barrier, group.tasks); - ice::array::clear(group.tasks); + group.tasks.clear(); } } return total_count; } - auto IceshardEngineFrame::running_tasks() const noexcept -> ice::ucount + auto IceshardEngineFrame::running_tasks() const noexcept -> ice::u32 { - ice::ucount result = 0; + ice::u32 result = 0; for (TaskGroup const& group : _task_groups) { - result += ice::ucount(group.barrier->is_set() == false); + result += ice::u32(group.barrier->is_set() == false); } return result; } diff --git a/source/code/iceshard/iceshard/private/iceshard_frame.hxx b/source/code/iceshard/iceshard/private/iceshard_frame.hxx index aa1fbf48..38a3a304 100644 --- a/source/code/iceshard/iceshard/private/iceshard_frame.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_frame.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -37,8 +37,8 @@ namespace ice auto create_tasks(ice::u32 count, ice::ShardID id) noexcept -> ice::Span> override; auto await_tasks_scheduled_on(ice::TaskScheduler& scheduler, ice::TaskScheduler& resumer) noexcept -> ice::Task<> override; - auto execute_tasks() noexcept -> ice::ucount override; - auto running_tasks() const noexcept -> ice::ucount override; + auto execute_tasks() noexcept -> ice::u32 override; + auto running_tasks() const noexcept -> ice::u32 override; void wait_tasks() noexcept override; auto extract_tasks() noexcept -> ice::Array> override; diff --git a/source/code/iceshard/iceshard/private/iceshard_runner.hxx b/source/code/iceshard/iceshard/private/iceshard_runner.hxx index 37ad19dc..387a501e 100644 --- a/source/code/iceshard/iceshard/private/iceshard_runner.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_runner.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -100,7 +100,7 @@ namespace ice void execute(ice::Task<> task) noexcept override { - ice::array::push_back(_pending_tasks, ice::move(task)); + _pending_tasks.push_back(ice::move(task)); } auto execute_internal(ice::Task<> task) noexcept -> ice::Task<> @@ -111,15 +111,15 @@ namespace ice void execute_all() noexcept { - ice::ucount const num_tasks = ice::array::count(_pending_tasks); - _running_tasks.fetch_add(num_tasks, std::memory_order_relaxed); + ice::ncount const num_tasks = _pending_tasks.size(); + _running_tasks.fetch_add(num_tasks.u32(), std::memory_order_relaxed); for (ice::Task<>& pending_task : _pending_tasks) { // We schedule the task on the given scheduler. ice::schedule_task(execute_internal(ice::move(pending_task)), _scheduler); } - ice::array::clear(_pending_tasks); + _pending_tasks.clear(); } void wait_all() noexcept diff --git a/source/code/iceshard/iceshard/private/iceshard_task_executor.cxx b/source/code/iceshard/iceshard/private/iceshard_task_executor.cxx index a0ae6b8a..da731ad5 100644 --- a/source/code/iceshard/iceshard/private/iceshard_task_executor.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_task_executor.cxx @@ -4,7 +4,7 @@ #include #include "iceshard_task_executor.hxx" #include -#include +#include namespace ice { @@ -14,7 +14,7 @@ namespace ice IceshardTaskExecutor::TaskList tasks ) noexcept : _allocator{ alloc } - , _task_count{ ice::count(tasks) } + , _task_count{ tasks.size().u32() } , _tasks{ ice::move(tasks) } , _sync_sem{ 0 } { @@ -55,10 +55,10 @@ namespace ice void IceshardTaskExecutor::wait_ready() noexcept { - if (ice::array::any(_tasks)) + if (_tasks.not_empty()) { _sync_sem.wait(); - ice::array::clear(_tasks); + _tasks.clear(); } } diff --git a/source/code/iceshard/iceshard/private/iceshard_task_executor.hxx b/source/code/iceshard/iceshard/private/iceshard_task_executor.hxx index ab9a24fa..7ff033cf 100644 --- a/source/code/iceshard/iceshard/private/iceshard_task_executor.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_task_executor.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -34,7 +34,7 @@ namespace ice private: ice::Allocator& _allocator; - ice::ucount _task_count; + ice::u32 _task_count; ice::Array, ice::ContainerLogic::Complex> _tasks; ice::ManualResetBarrier _sync_sem; }; diff --git a/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx b/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx index 0a20c8bd..2feaa4ef 100644 --- a/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_trait_context.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_world.hxx" @@ -46,14 +46,14 @@ namespace ice void IceshardTraitContext::send(ice::detail::TraitEvent event) noexcept { - ice::ucount idx = 0; + ice::u32 idx = 0; if (event.mode == TraitSendMode::Replace && ice::search(ice::Span{ _events }, event, detail::is_same_event, idx)) { _events[idx] = event; } else { - ice::array::push_back(_events, event); + _events.push_back(event); } } @@ -71,7 +71,7 @@ namespace ice // Copy all current events into the _expired events list. // We use copy+clean so we don't allocate one of the arrays every time. _events_expired = _events; - ice::array::clear(_events); + _events.clear(); // Push shards into the out container. (ice::detail::TraitEvent decays into ice::Shard) for (ice::Shard shard : _events_expired) diff --git a/source/code/iceshard/iceshard/private/iceshard_world.cxx b/source/code/iceshard/iceshard/private/iceshard_world.cxx index d888d638..a1db37cd 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world.cxx @@ -23,7 +23,7 @@ namespace ice , _entity_query_storage{ _allocator, _entity_storage } , _entity_operations{ _allocator, entities, entity_storage.archetypes(), 16 } , _traits{ ice::move(traits) } - , _tasks_launcher{ context, ice::array::slice(_traits), task_tracker } + , _tasks_launcher{ context, _traits, task_tracker } , _devui{ create_devui(_allocator, context) } { } diff --git a/source/code/iceshard/iceshard/private/iceshard_world_context.cxx b/source/code/iceshard/iceshard/private/iceshard_world_context.cxx index 19a86c7a..1a9b02e7 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_context.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_context.cxx @@ -8,7 +8,8 @@ namespace ice { IceshardWorldContext::IceshardWorldContext(ice::Allocator& alloc, ice::StringID_Arg worldid) noexcept - : _allocator{ alloc, ice::stringid_hint(worldid) } + : _world_name{ alloc, ice::stringid_hint(worldid) } + , _allocator{ alloc, ice::String{ _world_name } } , _always_reached_checkpoint{ true } , _checkpoints{ alloc } , _frame_handlers{ diff --git a/source/code/iceshard/iceshard/private/iceshard_world_context.hxx b/source/code/iceshard/iceshard/private/iceshard_world_context.hxx index 55085046..b490995b 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_context.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_context.hxx @@ -40,6 +40,7 @@ namespace ice void close_checkpoints() noexcept; private: + ice::HeapString<> _world_name; ice::ProxyAllocator _allocator; ice::UniquePtr _world; diff --git a/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx b/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx index 6bc0870c..bd5bbb67 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_manager.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "iceshard_world_manager.hxx" @@ -81,10 +81,10 @@ namespace ice IceshardWorldManager::~IceshardWorldManager() noexcept { - ice::ucount active_worlds = 0; + ice::u32 active_worlds = 0; for (Entry const& entry : _worlds) { - active_worlds += ice::ucount(entry.is_active); + active_worlds += ice::u32(entry.is_active); } ICE_ASSERT( @@ -120,13 +120,13 @@ namespace ice if (desc != nullptr) { ice::UniquePtr trait_context = ice::make_unique( - world_context->allocator(), *world_context.get(), ice::array::count(world_traits) + world_context->allocator(), *world_context.get(), world_traits.size().u32() ); ice::UniquePtr trait = desc->fn_factory(world_context->allocator(), *trait_context.get(), desc->fn_factory_userdata); if (trait != nullptr) { trait_context->trait = ice::move(trait); - ice::array::push_back(world_traits, ice::move(trait_context)); + world_traits.push_back(ice::move(trait_context)); } } } @@ -190,14 +190,14 @@ namespace ice { if (entry.is_active) { - ice::array::push_back(out_worlds, entry.world->worldID); + out_worlds.push_back(entry.world->worldID); } } } void IceshardWorldManager::query_pending_events(ice::ShardContainer& out_events) noexcept { - ice::shards::push_back(out_events, ice::array::slice(_pending_events._data)); + ice::shards::push_back(out_events, _pending_events._data); ice::shards::clear(_pending_events); } diff --git a/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx b/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx index 4c6551f1..40a25662 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_manager_devui.cxx @@ -43,7 +43,7 @@ namespace ice // Always ensure same size - ice::array::resize(_entries, ice::hashmap::count(_manager._worlds)); + _entries.resize(ice::hashmap::count(_manager._worlds)); [[maybe_unused]] ImVec2 const avail = ImGui::GetContentRegionAvail(); diff --git a/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.cxx b/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.cxx index 4513175b..0d5fe4bb 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.cxx @@ -17,13 +17,13 @@ namespace ice , _snapshots{ _allocator } { ice::devui_register_widget(this); - ice::array::resize(_tracked_task_events, 500); + _tracked_task_events.resize(500); } auto TraitTasksTrackerDevUI::report_resume(ice::u32 id) noexcept -> ice::u32 { ice::u32 const eventidx = _current_event_count.fetch_add(1, std::memory_order_relaxed); - if (eventidx >= ice::count(_tracked_task_events)) + if (eventidx >= _tracked_task_events.size()) { return 0; } @@ -45,7 +45,7 @@ namespace ice void TraitTasksTrackerDevUI::report_finish(ice::u32 id) noexcept { ice::u32 const eventidx = _current_event_count.fetch_add(1, std::memory_order_relaxed); - if (eventidx >= ice::count(_tracked_task_events)) + if (eventidx >= _tracked_task_events.size()) { return; } @@ -60,10 +60,10 @@ namespace ice void TraitTasksTrackerDevUI::update_state(ice::DevUIWidgetState &state) noexcept { _stat_events = _current_event_count.exchange(1, std::memory_order_relaxed); - if (_stat_events >= ice::count(_tracked_task_events)) + if (_stat_events >= _tracked_task_events.size()) { - ice::array::grow(_tracked_task_events, _stat_events); - ice::array::resize(_tracked_task_events, _stat_events); + _tracked_task_events.grow(_stat_events); + _tracked_task_events.resize(_stat_events); } } @@ -72,7 +72,9 @@ namespace ice ImGui::TextT("Collected events: {}", _stat_events - 1); if (ImGui::Button("Take snapshot")) { - ice::array::push_back(_snapshots, TraitTasksSnapshot{ _allocator, ice::array::slice(_tracked_task_events, 0, _stat_events) }); + _snapshots.push_back( + TraitTasksSnapshot{ _allocator, _tracked_task_events.headspan(_stat_events) } + ); } for (ice::TraitTasksSnapshot& snapshot : _snapshots) @@ -80,9 +82,9 @@ namespace ice if (snapshot._release == true) { snapshot._release = false; - ice::array::clear(snapshot._events); + snapshot._events.clear(); } - else if (ice::array::any(snapshot._events)) + else if (snapshot._events.not_empty()) { snapshot.draw(); } @@ -97,8 +99,8 @@ namespace ice ImVec2 const region = ImGui::GetWindowContentRegionMax(); ice::u32 first_entry = 1; - ice::u32 const last_entry = ice::count(_events); - EventEntry const* entries = ice::begin(_events); + ice::u32 const last_entry = _events.size().u32(); + EventEntry const* entries = _events.begin(); ice::u32 running = 0; EventEntry const* concurrent[32]{}; diff --git a/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.hxx b/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.hxx index fed88295..0e431fa0 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.hxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_tasks_devui.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include #include "iceshard_world_tasks_launcher.hxx" @@ -27,7 +27,7 @@ namespace ice : _events{ alloc } , _release{ false } { - ice::array::push_back(_events, events); + _events.push_back(events); } void draw() noexcept; diff --git a/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx b/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx index 336782ea..583adef2 100644 --- a/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx +++ b/source/code/iceshard/iceshard/private/iceshard_world_tasks_launcher.cxx @@ -45,7 +45,7 @@ namespace ice shard.id ); - auto out_it = ice::begin(tasks); + auto out_it = tasks.begin(); auto it = ice::multi_hashmap::find_first(handlers, ice::hash(shard.id)); while (it != nullptr) { @@ -98,8 +98,7 @@ namespace ice : _traits[handler.trait_idx]->trait.get(); //ICE_ASSERT(ice::array::count(out_tasks) < ice::array::capacity(out_tasks), "Maximum number of tasks suppored by default launcher reached!"); - ice::array::push_back( - out_tasks, + out_tasks.push_back( handler.procedure(userdata, params, shard) ); diff --git a/source/code/modules/iceshard_pipelines/private/asset_font.cxx b/source/code/modules/iceshard_pipelines/private/asset_font.cxx index ab7f3d05..82abfc0f 100644 --- a/source/code/modules/iceshard_pipelines/private/asset_font.cxx +++ b/source/code/modules/iceshard_pipelines/private/asset_font.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "asset_font.hxx" @@ -57,10 +57,10 @@ namespace ice gfx_font->atlases = { gfx_atlas, 1 }; gfx_font->ranges = { gfx_glyph_range, 1 }; - gfx_font->glyphs = { font_glyphs, ice::ucount(glyphs.size()) }; + gfx_font->glyphs = { font_glyphs, ice::u32(glyphs.size()) }; gfx_glyph_range->type = ice::GlyphRangeType::Explicit; - gfx_glyph_range->glyph_count = ice::ucount(glyphs.size()); + gfx_glyph_range->glyph_count = ice::u32(glyphs.size()); gfx_glyph_range->glyph_index = 0; gfx_glyph_range->glyph_atlas = 0; diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx index bc6df30f..4b02faef 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_asset.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -56,10 +56,10 @@ namespace ice ice::UIRawInfo const& raw_info ) noexcept -> ice::UISizeInfo { - ice::u32 const count_elements = ice::count(raw_info.elements); - ice::u32 const count_shards = ice::count(raw_info.shards); - ice::u32 const count_resources = ice::count(raw_info.resources); - ice::u32 const count_styles = ice::count(raw_info.styles); + ice::u32 const count_elements = raw_info.elements.size().u32(); + ice::u32 const count_shards = raw_info.shards.size().u32(); + ice::u32 const count_resources = raw_info.resources.size().u32(); + ice::u32 const count_styles = raw_info.styles.size().u32(); ice::u32 count_fonts = 0; ice::u32 count_actions = 0; @@ -81,7 +81,7 @@ namespace ice if (button_data->text.data_type == ice::ui::DataSource::ValueConstant) { count_constants += 1; - additional_data_size += ice::string::size(button_data->text.data_source); + additional_data_size += button_data->text.data_source.size().u32(); } } else if (element.type == ElementType::Label) @@ -90,7 +90,7 @@ namespace ice if (label_data->text.data_type == ice::ui::DataSource::ValueConstant) { count_constants += 1; - additional_data_size += ice::string::size(label_data->text.data_source); + additional_data_size += label_data->text.data_source.size().u32(); } } } @@ -100,7 +100,7 @@ namespace ice if (resource.type == ice::ui::ResourceType::Font) { count_fonts += 1; - additional_data_size += ice::string::size(resource.font_data.font_name); + additional_data_size += resource.font_data.font_name.size().u32(); } } @@ -155,10 +155,10 @@ namespace ice auto find_resource_idx( ice::Span resources, ice::String name - ) noexcept -> ice::u16 + ) noexcept -> ice::nindex { - ice::u16 idx = 0; - ice::u16 const count = ice::u16(ice::count(resources)); + ice::nindex idx = 0; + ice::ncount const count = resources.size(); for (; idx < count; ++idx) { if (resources[idx].ui_name == name) @@ -166,7 +166,7 @@ namespace ice break; } } - return idx == count ? ice::u16{ 0xffff } : idx; + return idx == count ? ice::nindex{ 0xffff } : idx; } struct ConstantData @@ -191,22 +191,22 @@ namespace ice { out_ref.source_i = constants.idx; - ice::ucount const text_size = ice::string::size(raw_data_ref.data_source); + ice::ncount const text_size = raw_data_ref.data_source.size(); constants.data[constants.idx].offset = constants.data_storage_offset; - constants.data[constants.idx].size = text_size; + constants.data[constants.idx].size = text_size.u32(); ice::memcpy( constants.data_storage, - ice::string::begin(raw_data_ref.data_source), - text_size + raw_data_ref.data_source.begin(), + text_size.bytes() ); - constants.data_storage = ice::ptr_add(constants.data_storage, { text_size }); - constants.data_storage_offset += text_size; + constants.data_storage = ice::ptr_add(constants.data_storage, text_size); + constants.data_storage_offset += text_size.u32(); constants.idx += 1; } else if (out_ref.source == DataSource::ValueResource) { - out_ref.source_i = find_resource_idx(resources, raw_data_ref.data_source); + out_ref.source_i = find_resource_idx(resources, raw_data_ref.data_source).u16(); } } @@ -223,8 +223,8 @@ namespace ice static auto store_span_info = [base_ptr = result.location](auto& span_value) noexcept { void* span_address = std::addressof(span_value); - ice::u32 const span_size = ice::count(span_value); - ice::u32 const span_offset = ice::u32(ice::ptr_distance(base_ptr, ice::span::data(span_value)).value); + ice::u32 const span_size = span_value.size().u32(); + ice::u32 const span_offset = ice::u32(ice::ptr_distance(base_ptr, span_value.data()).value); ice::u32* values = reinterpret_cast(span_address); values[0] = span_offset; @@ -279,8 +279,8 @@ namespace ice auto const find_font_idx = [&raw_info](ice::String font_name) noexcept -> ice::u16 { ice::u16 font_idx = 0; - ice::u32 idx = 0; - ice::u32 const count = ice::count(raw_info.resources); + ice::u64 idx = 0; + ice::u64 const count = raw_info.resources.size(); for (; idx < count; ++idx) { if (raw_info.resources[idx].type == ResourceType::Font) @@ -298,7 +298,7 @@ namespace ice auto const find_shard_idx = [&raw_info](ice::String resource_name) noexcept -> ice::u16 { ice::u16 idx = 0; - ice::u32 const count = ice::count(raw_info.shards); + ice::u64 const count = raw_info.shards.size(); for (; idx < count; ++idx) { if (raw_info.shards[idx].ui_name == resource_name) @@ -424,7 +424,7 @@ namespace ice for (ice::RawResource const& resource : raw_info.resources) { // TODO: Force it to ? - resources[idx_res].id = ice::stringid(std::string_view{ resource.ui_name._data, resource.ui_name._size }); + resources[idx_res].id = ice::stringid(resource.ui_name); resources[idx_res].type = resource.type; resources[idx_res].type_data = resource.type_data; @@ -433,9 +433,9 @@ namespace ice fonts[idx_font].resource_i = idx_res; fonts[idx_font].font_size = resource.font_data.font_size; fonts[idx_font].font_name_offset = additional_data_offset; - fonts[idx_font].font_name_size = ice::string::size(resource.font_data.font_name); + fonts[idx_font].font_name_size = resource.font_data.font_name.size().u32(); - ice::memcpy(additional_data, ice::string::begin(resource.font_data.font_name), fonts[idx_font].font_name_size); + ice::memcpy(additional_data, resource.font_data.font_name.begin(), fonts[idx_font].font_name_size); additional_data = ice::ptr_add(additional_data, { fonts[idx_font].font_name_size }); additional_data_offset += fonts[idx_font].font_name_size; @@ -447,7 +447,7 @@ namespace ice } void* aligned_ptr = ice::align_to(additional_data, ice::ualign::b_4).value; - additional_data_offset += ice::ucount(ice::ptr_distance(additional_data, aligned_ptr).value); + additional_data_offset += ice::u32(ice::ptr_distance(additional_data, aligned_ptr).value); additional_data = aligned_ptr; ice::u32 idx_style = 0; @@ -525,18 +525,18 @@ namespace ice { ice::Array uishards{ alloc }; - ice::array::reserve(uishards, 25); - ice::array::push_back(uishards, RawShard{ }); + uishards.reserve(25); + uishards.push_back(RawShard{ }); ice::Array uires{ alloc }; - ice::array::reserve(uires, 25); + uires.reserve(25); ice::Array styles{ alloc }; - ice::array::reserve(styles, 25); - ice::array::push_back(styles, RawStyle{ .flags = ice::ui::StyleFlags::None }); + styles.reserve(25); + styles.push_back(RawStyle{ .flags = ice::ui::StyleFlags::None }); ice::Array elements{ alloc }; - ice::array::reserve(elements, 50); + elements.reserve(50); rapidxml_ns::xml_document* doc = alloc.create>(); doc->parse(reinterpret_cast(data_copy.location)); diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven.hxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven.hxx index f2e68ae7..1d99f160 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven.hxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven.hxx @@ -1,10 +1,10 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include "ip_ui_oven_types.hxx" -#include -#include +#include +#include #include #include diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_elements.cxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_elements.cxx index 8c57ea9a..5fcd81c6 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_elements.cxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_elements.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "ip_ui_oven_elements.hxx" @@ -15,27 +15,27 @@ namespace ice bool trim(ice::String& inout_str, char character) noexcept { - ice::ucount const left_bracket = ice::string::find_first_not_of(inout_str, character); - ice::ucount const right_bracket = ice::string::find_last_not_of(inout_str, character); - if (left_bracket == ice::String_NPos && right_bracket == ice::String_NPos) + ice::nindex const left_bracket = inout_str.find_first_not_of(character); + ice::nindex const right_bracket = inout_str.find_last_not_of(character); + if (left_bracket == ice::nindex_none && right_bracket == ice::nindex_none) { return false; } - inout_str = ice::string::substr(inout_str, left_bracket, (right_bracket - left_bracket) + 1); + inout_str = inout_str.substr(left_bracket, (right_bracket - left_bracket) + 1); return true; } bool remove_brackets(ice::String& inout_str) noexcept { - ice::ucount const left_bracket = ice::string::find_first_of(inout_str, '{'); - ice::ucount const right_bracket = ice::string::find_last_of(inout_str, '}'); - if (left_bracket == ice::String_NPos || right_bracket == ice::String_NPos) + ice::nindex const left_bracket = inout_str.find_first_of('{'); + ice::nindex const right_bracket = inout_str.find_last_of('}'); + if (left_bracket == ice::nindex_none || right_bracket == ice::nindex_none) { return false; } - inout_str = ice::string::substr(inout_str, left_bracket + 1, (right_bracket - left_bracket) - 1); + inout_str = inout_str.substr(left_bracket + 1, (right_bracket - left_bracket) - 1); return true; } @@ -44,12 +44,12 @@ namespace ice ice::RawAction& out_action ) noexcept { - ice::ucount const type_end = ice::string::find_first_of(inout_str, ' '); + ice::nindex const type_end = inout_str.find_first_of(' '); bool result = false; - if (type_end != ice::String_NPos) + if (type_end != ice::nindex_none) { - ice::String const action_type = ice::string::substr(inout_str, 0, type_end); + ice::String const action_type = inout_str.substr(0, type_end); if (action_type == RawAction::Constant_ActionType_Shard) { out_action.action_type = ice::ui::ActionType::Shard; @@ -67,14 +67,14 @@ namespace ice result = out_action.action_type != ice::ui::ActionType::None; if (result) { - inout_str = ice::string::substr(inout_str, type_end + 1); + inout_str = inout_str.substr(type_end + 1); - ice::ucount const action_value_end = ice::string::find_first_of(inout_str, ",} "_str); - out_action.action_value = ice::string::substr(inout_str, 0, action_value_end); - result = ice::string::empty(out_action.action_value) == false; + ice::nindex const action_value_end = inout_str.find_first_of(",} "_str); + out_action.action_value = inout_str.substr(0, action_value_end); + result = out_action.action_value.not_empty(); // Move to the next expected token. - inout_str = ice::string::substr(inout_str, action_value_end + 1); + inout_str = inout_str.substr(action_value_end + 1); } } return result; @@ -87,18 +87,18 @@ namespace ice if (remove_brackets(str)) { - ice::ucount const type_end = ice::string::find_first_of(str, ' '); - ice::String const data_type = ice::string::substr(str, 0, type_end); + ice::nindex const type_end = str.find_first_of(' '); + ice::String const data_type = str.substr(0, type_end); if (data_type == RawAction::Constant_ActionDataType_Resource) { out_action.data_type = ice::ui::DataSource::ValueResource; - out_action.data_source = ice::string::substr(str, type_end + 1); + out_action.data_source = str.substr(type_end + 1); } else if (data_type == RawAction::Constant_ActionDataType_Property) { out_action.data_type = ice::ui::DataSource::ValueProperty; - out_action.data_source = ice::string::substr(str, type_end + 1); + out_action.data_source = str.substr(type_end + 1); } ice::trim(out_action.data_source, ' '); } @@ -110,15 +110,15 @@ namespace ice out_action.data.data_source = {}; bool result = true; - ice::ucount const data_start = ice::string::find_first_of(inout_str, '='); - if (data_start != ice::String_NPos) + ice::nindex const data_start = inout_str.find_first_of('='); + if (data_start != ice::nindex_none) { - ice::ucount const data_arg_start = ice::string::find_last_of(inout_str, " ,"_str, data_start); + ice::nindex const data_arg_start = inout_str.find_last_of(" ,"_str, data_start); [[maybe_unused]] - ice::String const data_arg = ice::string::substr(inout_str, data_arg_start + 1, (data_start - data_arg_start) - 1); + ice::String const data_arg = inout_str.substr(data_arg_start + 1, (data_start - data_arg_start) - 1); - inout_str = ice::string::substr(inout_str, data_start + 1); + inout_str = inout_str.substr(data_start + 1); if (remove_brackets(inout_str)) { ICE_ASSERT(false, "TODO!"); // Was here before memsys refactor. Needs a ticket! @@ -249,7 +249,7 @@ namespace ice ICE_ASSERT( action_parse_result != false, "Failed to parse action value '{}'", - ice::String{ attribute->value(), ice::ucount(attribute->value_size()) } + ice::String{ attribute->value(), attribute->value_size() } ); } diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.cxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.cxx index cea1a3c2..1cfb7be3 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.cxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "ip_ui_oven_page.hxx" @@ -47,7 +47,7 @@ namespace ice using ice::ui::ElementState; ElementState result = ElementState::None; - if (ice::string::empty(element_state)) + if (element_state.is_empty()) { result |= ElementState::Any; } @@ -122,7 +122,7 @@ namespace ice xml_prop = ice::xml_next_sibling(xml_prop); } - ice::array::push_back(styles, style); + styles.push_back(style); } xml_child = ice::xml_next_sibling( @@ -187,13 +187,13 @@ namespace ice { res.type = ResourceType::String; } - else if (ice::string::starts_with(type_str, Constant_UIResourceType_String)) + else if (type_str.starts_with(Constant_UIResourceType_String)) { - ice::ucount const arrval_beg = ice::string::find_first_of(type_str, '['); - ice::ucount const arrval_end = ice::string::find_last_of(type_str, ']'); + ice::nindex const arrval_beg = type_str.find_first_of('['); + ice::nindex const arrval_end = type_str.find_last_of(']'); if (arrval_beg < arrval_end) { - ice::String arrval_str = ice::string::substr(type_str, arrval_beg + 1, (arrval_end - arrval_beg) - 1); + ice::String arrval_str = type_str.substr(arrval_beg + 1, (arrval_end - arrval_beg) - 1); if (ice::from_chars(arrval_str, res.type_data)) { res.type = ResourceType::String; @@ -212,10 +212,7 @@ namespace ice if (uiref && res.type != ResourceType::None) { - ice::array::push_back( - shards, - res - ); + shards.push_back(res); } xml_child = ice::xml_next_sibling( @@ -252,12 +249,11 @@ namespace ice if (uiref && attr_name) { - ice::array::push_back( - shards, + shards.push_back( ice::RawShard { .ui_name = ice::xml_value(uiref), - .shard_name = ice::shardid(ice::String{ attr_name->value(), ice::ucount(attr_name->value_size()) }) + .shard_name = ice::shardid(ice::String{ attr_name->value(), attr_name->value_size() }) } ); } @@ -277,14 +273,9 @@ namespace ice ice::Array& elements ) noexcept { - ice::u16 const element_index = static_cast( - ice::array::count(elements) - ); + ice::u16 const element_index = elements.size().u16(); - ice::array::push_back( - elements, - ice::RawElement{ .parent = parent_idx } - ); + elements.push_back(ice::RawElement{ .parent = parent_idx }); parse_element_attribs( alloc, diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.hxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.hxx index 986e62c6..2029af9d 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.hxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_page.hxx @@ -4,7 +4,7 @@ #pragma once #include #include -#include +#include #include #include "ip_ui_oven.hxx" diff --git a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_utils.cxx b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_utils.cxx index aabe7666..7bdfc4ef 100644 --- a/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_utils.cxx +++ b/source/code/modules/iceshard_pipelines/private/pipeline_ui/ip_ui_oven_utils.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "ip_ui_oven_utils.hxx" @@ -16,31 +16,20 @@ namespace ice ice::String name ) noexcept -> rapidxml_ns::xml_node const* { - if (ice::string::any(ns)) + if (ns.not_empty()) { - if (ice::string::any(name)) + if (name.not_empty()) { - return parent->first_node_ns( - ice::string::begin(ns), - ice::string::size(ns), - ice::string::begin(name), - ice::string::size(name) - ); + return parent->first_node_ns(ns.begin(), ns.size(), name.begin(), name.size()); } else { - return parent->first_node_ns( - ice::string::begin(ns), - ice::string::size(ns) - ); + return parent->first_node_ns(ns.begin(), ns.size()); } } else { - return parent->first_node( - ice::string::begin(name), - ice::string::size(name) - ); + return parent->first_node(name.begin(), name.size()); } } @@ -50,30 +39,30 @@ namespace ice ice::String name ) noexcept -> rapidxml_ns::xml_node const* { - if (ice::string::any(ns)) + if (ns.not_empty()) { - if (ice::string::any(name)) + if (name.not_empty()) { return parent->next_sibling_ns( - ice::string::begin(ns), - ice::string::size(ns), - ice::string::begin(name), - ice::string::size(name) + ns.begin(), + ns.size(), + name.begin(), + name.size() ); } else { return parent->next_sibling_ns( - ice::string::begin(ns), - ice::string::size(ns) + ns.begin(), + ns.size() ); } } else { return parent->next_sibling( - ice::string::begin(name), - ice::string::size(name) + name.begin(), + name.size() ); } } @@ -84,8 +73,8 @@ namespace ice ) noexcept -> rapidxml_ns::xml_attribute const* { return node->first_attribute( - ice::string::begin(name), - ice::string::size(name) + name.begin(), + name.size() ); } @@ -95,8 +84,8 @@ namespace ice ) noexcept -> rapidxml_ns::xml_attribute const* { return attrib->next_attribute( - ice::string::begin(name), - ice::string::size(name) + name.begin(), + name.size() ); } @@ -104,35 +93,35 @@ namespace ice rapidxml_ns::xml_node const* node ) noexcept -> ice::String { - return { node->local_name(), ice::ucount(node->local_name_size()) }; + return { node->local_name(), node->local_name_size() }; } auto xml_name( rapidxml_ns::xml_attribute const* attrib ) noexcept -> ice::String { - return { attrib->name(), ice::ucount(attrib->name_size()) }; + return { attrib->name(), attrib->name_size() }; } auto xml_value( rapidxml_ns::xml_node const* node ) noexcept -> ice::String { - return { node->value(), ice::ucount(node->value_size()) }; + return { node->value(), node->value_size() }; } auto xml_value( rapidxml_ns::xml_attribute const* attrib ) noexcept -> ice::String { - return attrib == nullptr ? "" : ice::String{ attrib->value(), ice::ucount(attrib->value_size()) }; + return attrib == nullptr ? "" : ice::String{ attrib->value(), attrib->value_size() }; } auto xml_value_noutf8( rapidxml_ns::xml_attribute const* attrib ) noexcept -> ice::String { - return attrib == nullptr ? "" : ice::String{ attrib->value(), ice::ucount(attrib->value_size()) }; + return attrib == nullptr ? "" : ice::String{ attrib->value(), attrib->value_size() }; } void parse_element_size( @@ -143,13 +132,13 @@ namespace ice { using ice::ui::ElementFlags; - ice::ucount const separator = ice::string::find_first_of(value, ','); + ice::nindex const separator = value.find_first_of(','); bool valid_values = true; - if (separator != ice::String_NPos) + if (separator != ice::nindex_none) { - ice::String left = ice::string::substr(value, 0, separator); - ice::String right = ice::string::substr(value, separator + 1); + ice::String left = value.substr(0, separator); + ice::String right = value.substr(separator + 1); if (ice::from_chars(left, left, out_size.width) == false) { @@ -200,7 +189,7 @@ namespace ice } ICE_ASSERT( - valid_values || ice::string::empty(value), + valid_values || value.is_empty(), "Invalid value in 'size' attribute! Valid values are: {}, {}, .", ice::Constant_UIAttributeKeyword_Auto, ice::Constant_UIAttributeKeyword_Stretch @@ -215,13 +204,13 @@ namespace ice { using ice::ui::ElementFlags; - ice::ucount const separator = ice::string::find_first_of(value, ','); + ice::nindex const separator = value.find_first_of(','); bool valid_values = true; - if (separator != ice::String_NPos) + if (separator != ice::nindex_none) { - ice::String left = ice::string::substr(value, 0, separator); - ice::String right = ice::string::substr(value, separator + 1); + ice::String left = value.substr(0, separator); + ice::String right = value.substr(separator + 1); if (ice::from_chars(left, left, out_pos.x) == false) { @@ -268,7 +257,7 @@ namespace ice } ICE_ASSERT( - valid_values || ice::string::empty(value), + valid_values || value.is_empty(), "Invalid value in 'position' attribute! Valid values are: {}, .", ice::Constant_UIAttributeKeyword_Auto ); @@ -282,17 +271,17 @@ namespace ice { using ice::ui::ElementFlags; - ice::ucount const sep1 = ice::string::find_first_of(value, ',', 0); - ice::ucount const sep2 = ice::string::find_first_of(value, ',', sep1 + 1); - ice::ucount const sep3 = ice::string::find_first_of(value, ',', sep2 + 1); + ice::nindex const sep1 = value.find_first_of(',', 0); + ice::nindex const sep2 = value.find_first_of(',', sep1 + 1); + ice::nindex const sep3 = value.find_first_of(',', sep2 + 1); bool valid_values = true; - if (sep3 != ice::String_NPos && sep2 != ice::String_NPos && sep1 != ice::String_NPos) + if (sep3 != ice::nindex_none && sep2 != ice::nindex_none && sep1 != ice::nindex_none) { - ice::String first = ice::string::substr(value, 0, sep1); - ice::String second = ice::string::substr(value, sep1 + 1, (sep2 - sep1) - 1); - ice::String third = ice::string::substr(value, sep2 + 1, (sep3 - sep2) - 1); - ice::String fourth = ice::string::substr(value, sep3 + 1); + ice::String first = value.substr(0, sep1); + ice::String second = value.substr(sep1 + 1, (sep2 - sep1) - 1); + ice::String third = value.substr(sep2 + 1, (sep3 - sep2) - 1); + ice::String fourth = value.substr(sep3 + 1); if (ice::from_chars(first, first, out_offset.left) == false) { @@ -339,10 +328,10 @@ namespace ice } } } - else if (sep1 != ice::String_NPos) + else if (sep1 != ice::nindex_none) { - ice::String first = ice::string::substr(value, 0, sep1); - ice::String second = ice::string::substr(value, sep1 + 1); + ice::String first = value.substr(0, sep1); + ice::String second = value.substr(sep1 + 1); if (ice::from_chars(first, first, out_offset.left) == false) { @@ -396,7 +385,7 @@ namespace ice } ICE_ASSERT( - valid_values || ice::string::empty(value), + valid_values || value.is_empty(), "Invalid value in 'padding' / 'margin' attribute! Valid values are: {}, .", ice::Constant_UIAttributeKeyword_Auto ); @@ -409,22 +398,22 @@ namespace ice { using ice::ui::ElementFlags; - ice::ucount const sep1 = ice::string::find_first_of(value, ',', 0); - ice::ucount const sep2 = ice::string::find_first_of(value, ',', sep1 + 1); + ice::nindex const sep1 = value.find_first_of(',', 0); + ice::nindex const sep2 = value.find_first_of(',', sep1 + 1); bool valid_values = false; - if (sep1 != ice::String_NPos && sep2 != ice::String_NPos) + if (sep1 != ice::nindex_none && sep2 != ice::nindex_none) { - ice::String first = ice::string::substr(value, 0, sep1); - ice::String second = ice::string::substr(value, sep1 + 1, (sep2 - sep1) - 1); - ice::String third = ice::string::substr(value, sep2 + 1); + ice::String first = value.substr(0, sep1); + ice::String second = value.substr(sep1 + 1, (sep2 - sep1) - 1); + ice::String third = value.substr(sep2 + 1); ice::from_chars(first, out_color.red); ice::from_chars(second, out_color.green); ice::from_chars(third, out_color.blue); valid_values = true; } - else if (sep1 == ice::String_NPos && sep2 == ice::String_NPos) + else if (sep1 == ice::nindex_none && sep2 == ice::nindex_none) { ice::from_chars(value, out_color.red); out_color.green = out_color.red; diff --git a/source/code/modules/imgui_module/private/imgui_gfx_stage.cxx b/source/code/modules/imgui_module/private/imgui_gfx_stage.cxx index acc017dd..d2774fd9 100644 --- a/source/code/modules/imgui_module/private/imgui_gfx_stage.cxx +++ b/source/code/modules/imgui_module/private/imgui_gfx_stage.cxx @@ -188,14 +188,8 @@ namespace ice::devui _pipeline = device.create_pipeline(pipeline_info); _index_buffer_host = _index_buffers._allocator->allocate(1024 * 1024 * 32); - ice::array::push_back( - _index_buffers, - device.create_buffer(BufferType::Index, 1024 * 1024 * 64) - ); - ice::array::push_back( - _vertex_buffers, - device.create_buffer(BufferType::Vertex, 1024 * 1024 * 64) - ); + _index_buffers.push_back(device.create_buffer(BufferType::Index, 1024 * 1024 * 64)); + _vertex_buffers.push_back(device.create_buffer(BufferType::Vertex, 1024 * 1024 * 64)); co_return; } @@ -215,8 +209,8 @@ namespace ice::devui { device.destroy_buffer(buffer); } - ice::array::clear(_index_buffers); - ice::array::clear(_vertex_buffers); + _index_buffers.clear(); + _vertex_buffers.clear(); device.destroy_buffer(_uniform_buffer); device.destroy_pipeline(_pipeline); @@ -236,7 +230,7 @@ namespace ice::devui using namespace ice::render; ImDrawData* draw_data = ImGui::GetDrawData(); - if (draw_data == nullptr || ice::array::empty(draw_commands)) + if (draw_data == nullptr || draw_commands.is_empty()) { return; } diff --git a/source/code/modules/imgui_module/private/imgui_system.cxx b/source/code/modules/imgui_module/private/imgui_system.cxx index d402b98d..b56b6272 100644 --- a/source/code/modules/imgui_module/private/imgui_system.cxx +++ b/source/code/modules/imgui_module/private/imgui_system.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "imgui_system.hxx" @@ -7,8 +7,7 @@ #include #include -#include -#include +#include #if ISP_WINDOWS #include @@ -22,22 +21,22 @@ namespace ice::devui void build_mainmenu(ice::StaticString<32>& temp, ice::String path, ice::String name, bool& state) noexcept { - ice::ucount const separator_pos = ice::string::find_first_of(path, '/'); - if (separator_pos != ice::String_NPos) + ice::nindex const separator_pos = path.find_first_of('/'); + if (separator_pos != ice::nindex_none) { - temp = ice::string::substr(path, 0, separator_pos); + temp = path.substr(0, separator_pos); - if (ImGui::BeginMenu(ice::string::begin(temp))) + if (ImGui::BeginMenu(temp.begin())) { - build_mainmenu(temp, ice::string::substr(path, separator_pos + 1), name, state); + build_mainmenu(temp, path.substr(separator_pos + 1), name, state); ImGui::EndMenu(); } } else { - if (ImGui::BeginMenu(ice::string::begin(path))) + if (ImGui::BeginMenu(path.begin())) { - ImGui::MenuItem(ice::string::begin(name), nullptr, &state); + ImGui::MenuItem(name.begin(), nullptr, &state); ImGui::EndMenu(); } } @@ -48,20 +47,20 @@ namespace ice::devui void ImGuiWidgetFrame::mainmenu(ice::DevUIWidgetInfo const& widget, ice::DevUIWidgetState& state) noexcept { - ice::ucount const separator_pos = ice::string::find_first_of(widget.category, '/'); - if (separator_pos == ice::String_NPos) + ice::nindex const separator_pos = widget.category.find_first_of('/'); + if (separator_pos == ice::nindex_none) { - ImGui::MenuItem(ice::string::begin(widget.name), nullptr, &state.active); + ImGui::MenuItem(widget.name.begin(), nullptr, &state.active); return; } ice::StaticString<32> helper; - detail::build_mainmenu(helper, ice::string::substr(widget.category, separator_pos + 1), widget.name, state.active); + detail::build_mainmenu(helper, widget.category.substr(separator_pos + 1), widget.name, state.active); } bool ImGuiWidgetFrame::begin(ice::DevUIWidgetInfo const& widget, ice::DevUIWidgetState& state) noexcept { - return ImGui::Begin(ice::string::begin(widget.name), &state.active); + return ImGui::Begin(widget.name.begin(), &state.active); } void ImGuiWidgetFrame::end() noexcept @@ -78,7 +77,7 @@ namespace ice::devui , _widget_logger{ _allocator } , _widget_style{ _allocator } { - ice::array::push_back(_builtin_widgets, create_allocator_tree_widget(_allocator)); + _builtin_widgets.push_back(create_allocator_tree_widget(_allocator)); // ice::array::push_back(_builtin_widgets, (ice::UniquePtr) ice::make_unique(_allocator, _allocator)); // Register all built-in's @@ -101,10 +100,10 @@ namespace ice::devui void ImGuiSystem::setup_mainmenu(ice::Span categories) noexcept { - ice::array::clear(_menu_categories); + _menu_categories.clear(); for (ice::String category : categories) { - ice::array::push_back(_menu_categories, ice::HeapString<>{ _allocator, category }); + _menu_categories.push_back({ _allocator, category }); } } @@ -144,12 +143,12 @@ namespace ice::devui { for (ice::String category : _menu_categories) { - if (ImGui::BeginMenu(ice::string::begin(category))) + if (ImGui::BeginMenu(category.begin())) { for (auto const& runtime : _widget_manager.widgets()) { ice::DevUIWidgetInfo const& info = runtime->widget->widget_info; - if (ice::string::starts_with(info.category, category) && runtime->widget->build_mainmenu(runtime->state)) + if (info.category.starts_with(category) && runtime->widget->build_mainmenu(runtime->state)) { _widget_frame.mainmenu(info, runtime->state); } @@ -206,7 +205,7 @@ namespace ice::devui // ImGui::NewLine(); ImGui::SeparatorText("Info"); ImGui::NewLine(); ImGui::Separator(); - ImGui::TextT("Widgets: {}", ice::count(_widget_manager.widgets())); + ImGui::TextT("Widgets: {}", _widget_manager.widgets().size()); ImGui::NewLine(); ImGui::Separator(); ImGui::TextT("Draw calls: {} ({:p})", stats.draw_calls, stats.draw_datasize); diff --git a/source/code/modules/imgui_module/private/imgui_system.hxx b/source/code/modules/imgui_module/private/imgui_system.hxx index 36788474..cd705b0f 100644 --- a/source/code/modules/imgui_module/private/imgui_system.hxx +++ b/source/code/modules/imgui_module/private/imgui_system.hxx @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include "widgets/imgui_devui_manager.hxx" diff --git a/source/code/modules/imgui_module/private/imgui_trait.cxx b/source/code/modules/imgui_module/private/imgui_trait.cxx index 1fc0581c..b9fdb713 100644 --- a/source/code/modules/imgui_module/private/imgui_trait.cxx +++ b/source/code/modules/imgui_module/private/imgui_trait.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "imgui_trait.hxx" @@ -483,7 +483,7 @@ namespace ice::devui IPT_ZONE_SCOPED; _stats = {}; // reset stats - ice::array::clear(_imgui_gfx_stage->draw_commands); + _imgui_gfx_stage->draw_commands.clear(); ImDrawData* draw_data = ImGui::GetDrawData(); if (draw_data == nullptr) @@ -492,8 +492,7 @@ namespace ice::devui } // Reserve enough space for all possible commands - ice::array::reserve( - _imgui_gfx_stage->draw_commands, + _imgui_gfx_stage->draw_commands.reserve( detail::total_command_count(*draw_data) ); @@ -529,8 +528,8 @@ namespace ice::devui curr_resource_idx += 1; } - ice::array::push_back(out_draw_cmds, ImGuiGfxStage::DrawCommand{}); - ImGuiGfxStage::DrawCommand& cmd = ice::array::back(out_draw_cmds); + out_draw_cmds.push_back(ImGuiGfxStage::DrawCommand{}); + ImGuiGfxStage::DrawCommand& cmd = out_draw_cmds.last(); cmd.resource_set_idx = curr_resource_idx; ImVec4 clip_rect; diff --git a/source/code/modules/imgui_module/private/widgets/imgui_allocator_tree.cxx b/source/code/modules/imgui_module/private/widgets/imgui_allocator_tree.cxx index ee779b86..129f4d8c 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_allocator_tree.cxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_allocator_tree.cxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "imgui_allocator_tree.hxx" #include -#include +#include #include #include @@ -56,13 +56,13 @@ namespace ice::devui { if (ImGui::TableNextColumn()) { - ice::ucount const current_count = allocator.allocation_count(); + ice::u32 const current_count = allocator.allocation_count(); ImGui::Text(current_count == Allocator::CountNotTracked ? "- not tracked -" : "%d", current_count); } if (ImGui::TableNextColumn()) { - ice::ucount const total_count = allocator.allocation_total_count(); + ice::u32 const total_count = allocator.allocation_total_count(); ImGui::Text(total_count == Allocator::CountNotTracked ? "- not tracked -" : "%d", total_count); } diff --git a/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx b/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx index c0d9499d..d4497a39 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "imgui_devui_manager.hxx" @@ -11,7 +11,7 @@ namespace ImGui { void StringUnformatted(ice::String str) noexcept { - TextUnformatted(ice::string::begin(str), ice::string::end(str)); + TextUnformatted(str.begin(), str.end()); } } // namespace ImGui @@ -23,8 +23,8 @@ namespace ice::devui , _allocator{ alloc } , _widgets{ alloc } { - ice::array::reserve(_widgets, 100); - ice::array::push_back(_widgets, ice::make_unique(_allocator)); + _widgets.reserve(100); + _widgets.push_back(ice::make_unique(_allocator)); } ImGuiDevUIManager::~ImGuiDevUIManager() noexcept @@ -42,13 +42,13 @@ namespace ice::devui }; ice::DevUIWidgetState const* owner_state = nullptr; - ice::ucount owner_idx = 0; + ice::u32 owner_idx = 0; if (ice::search(ice::Span{ _widgets }, owning_widget, fn_compare, owner_idx)) { owner_state = ice::addressof(_widgets[owner_idx]->state); } - ice::array::push_back(_widgets, + _widgets.push_back( ice::make_unique(_allocator, ImGuiDevUIWidget{ .state = {.owner = owner_state }, @@ -63,7 +63,7 @@ namespace ice::devui { // TODO: ice::array::remove_at - ice::u32 const count = ice::array::count(_widgets); + ice::u32 const count = _widgets.size().u32(); if (count == 0) { return; @@ -78,7 +78,7 @@ namespace ice::devui } _widgets[idx] = ice::move(_widgets[count - 1]); - ice::array::pop_back(_widgets); + _widgets.pop_back(); } void ImGuiDevUIManager::build_content() noexcept @@ -104,7 +104,7 @@ namespace ice::devui ImGui::TableSetupColumn("Visible"); ImGui::TableHeadersRow(); - for (auto const& widget : ice::array::slice(_widgets, 1)) + for (auto const& widget : _widgets.tailspan()) { ImGui::TableNextRow(); diff --git a/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.hxx b/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.hxx index fd63d55a..1d42ac9a 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.hxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_devui_manager.hxx @@ -4,7 +4,7 @@ #pragma once #include #include -#include +#include #include namespace ice::devui @@ -29,7 +29,7 @@ namespace ice::devui ) noexcept; void remove_widget(ice::DevUIWidget* widget) noexcept; - auto widgets() noexcept -> ice::Span const> { return ice::array::slice(_widgets, 1); } + auto widgets() noexcept -> ice::Span const> { return _widgets.tailspan(); } void build_content() noexcept override; diff --git a/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx b/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx index c20e249a..9cd4c269 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_logger.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "imgui_logger.hxx" @@ -9,8 +9,7 @@ #include #include #include -#include -#include +#include #include #include @@ -66,8 +65,8 @@ namespace ice::devui , _entries{ LoggerAlloc } , _entries_visible{ LoggerAlloc } { - ice::array::reserve(_entries, 2000); - ice::array::reserve(_entries_visible, 2000); + _entries.reserve(2000); + _entries_visible.reserve(2000); } ImGuiLogger::~ImGuiLogger() noexcept @@ -79,8 +78,8 @@ namespace ice::devui void ImGuiLogger::add_entry(ice::LogSinkMessage const& message) noexcept { std::lock_guard lk{ mtx }; - ice::array::push_back(_entries_visible, ice::array::count(_entries)); - ice::array::push_back(_entries, { message.severity, message.tag, message.tag_name, {LoggerAlloc,message.message} }); + _entries_visible.push_back(_entries.size().u32()); + _entries.push_back({ message.severity, message.tag, message.tag_name, {LoggerAlloc,message.message} }); } static inline auto severity_color(ice::LogSeverity sev) noexcept -> ImGuiColorCtx @@ -211,8 +210,8 @@ namespace ice::devui ice::f64 const max_match = _entries[_entries_visible[0]].filter_match; ice::sort_indices( - ice::array::slice(_entries), - ice::array::slice(_entries_visible), + _entries.tailspan(0), + _entries_visible.tailspan(0), [max_match](ImGuiLogEntry const& l, ImGuiLogEntry const& r) noexcept { if (l.filter_match == r.filter_match && r.filter_match >= max_match) diff --git a/source/code/modules/imgui_module/private/widgets/imgui_logger.hxx b/source/code/modules/imgui_module/private/widgets/imgui_logger.hxx index 976878db..86faf7ea 100644 --- a/source/code/modules/imgui_module/private/widgets/imgui_logger.hxx +++ b/source/code/modules/imgui_module/private/widgets/imgui_logger.hxx @@ -5,7 +5,7 @@ #pragma once #include #include -#include +#include #include namespace ice::devui diff --git a/source/code/modules/shader_tools/private/shader_tools.cxx b/source/code/modules/shader_tools/private/shader_tools.cxx index 96c9ae00..81b647a3 100644 --- a/source/code/modules/shader_tools/private/shader_tools.cxx +++ b/source/code/modules/shader_tools/private/shader_tools.cxx @@ -52,8 +52,7 @@ namespace ice { ice::ShaderTargetPlatform const target = param_shader_target(params); static ice::String supported_extensions[]{ ".asl", ".glsl", ".asl", ".hlsl" }; - return ice::span::subspan( - ice::Span{ supported_extensions }, + return ice::Span{ supported_extensions }.subspan( // Select GLSL [0, 1] or HLSL span [2, 3] target == ShaderTargetPlatform::GLSL ? 0 : 2, // If we target 'WGSL' we only want to accept 'asl' files [0] diff --git a/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx b/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx index 503af543..e63a37c1 100644 --- a/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_asl_importer.cxx @@ -92,12 +92,12 @@ namespace ice void ASLImportTracker::track_script(ASLScriptFile* file) noexcept { // Store the tracker pointer in a list. - ice::array::push_back(_global, file); + _global.push_back(file); } void ASLImportTracker::add_visitor(arctic::SyntaxVisitor* visitor) noexcept { - ice::array::push_back(_script_visitors, visitor); + _script_visitors.push_back(visitor); } auto ASLImportTracker::find(arctic::String identifier) noexcept -> arctic::SyntaxNode<> @@ -182,7 +182,7 @@ namespace ice } // Store the tracker pointer in a list. - ice::array::push_back(_global, import_entry.file.get()); + _global.push_back(import_entry.file.get()); // Store the whole entry. ice::multi_hashmap::insert(_imports, detail::arc_hash(node.data().path), ice::move(import_entry)); @@ -216,8 +216,8 @@ namespace ice result = ice::make_unique(alloc._backing, alloc, asl_alias); ice::Array final_visitors{ alloc._backing, visitors }; - ice::array::push_back(final_visitors, &imports); - ice::array::push_back(final_visitors, result.get()); + final_visitors.push_back(&imports); + final_visitors.push_back(result.get()); if (parser->parse(lexer, alloc, final_visitors) == false) { diff --git a/source/code/modules/shader_tools/private/shader_tools_asl_shader.cxx b/source/code/modules/shader_tools/private/shader_tools_asl_shader.cxx index 56f1c2b9..17102287 100644 --- a/source/code/modules/shader_tools/private/shader_tools_asl_shader.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_asl_shader.cxx @@ -77,7 +77,7 @@ namespace ice prev = std::exchange(member, member.sibling()); } - ice::array::push_back(_structs, ice::move(node)); + _structs.push_back(ice::move(node)); } } @@ -146,7 +146,7 @@ namespace ice } } - ice::array::push_back(_functions, node); + _functions.push_back(node); } void ASLShader::visit(arctic::SyntaxNode node) noexcept @@ -181,7 +181,7 @@ namespace ice else if (detail::arc_annotation(var, "uniform", annotation)) { ICE_ASSERT_CORE(var.data().is_reference == false); // not supported in shaders - ice::array::push_back(_uniforms, var); + _uniforms.push_back(var); } else { diff --git a/source/code/modules/shader_tools/private/shader_tools_asl_utils.hxx b/source/code/modules/shader_tools/private/shader_tools_asl_utils.hxx index c7f8dd05..63e73506 100644 --- a/source/code/modules/shader_tools/private/shader_tools_asl_utils.hxx +++ b/source/code/modules/shader_tools/private/shader_tools_asl_utils.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -48,7 +48,7 @@ namespace ice constexpr auto arc_str(arctic::String str) noexcept -> ice::String { - return ice::String{ str.data(), static_cast(str.size()) }; + return ice::String{ str.data(), static_cast(str.size()) }; } constexpr auto arc_hash(arctic::String str) noexcept -> ice::u64 diff --git a/source/code/modules/shader_tools/private/shader_tools_glsl.cxx b/source/code/modules/shader_tools/private/shader_tools_glsl.cxx index ecf4d2f2..2008f425 100644 --- a/source/code/modules/shader_tools/private/shader_tools_glsl.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_glsl.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "shader_tools_glsl.hxx" @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include #include @@ -115,9 +115,9 @@ namespace ice syntax::Atom const& atom = node.to().data(); if (atom.is_parenthized) { - ice::string::push_back(result, "("); + result.push_back("("); generate_expression(result, subs, func, arg, node.child()); - ice::string::push_back(result, ")"); + result.push_back(")"); } else { @@ -130,7 +130,7 @@ namespace ice generate_expression(result, subs, func, arg, node.child()); if (node.sibling()) { - ice::string::push_back(result, ", "); + result.push_back(", "); } break; } @@ -156,12 +156,12 @@ namespace ice ice::string::push_format(result, "{}(", node.to().data().name.value); // Call children groups generate_expression(result, subs, func, arg, node.child()); - ice::string::push_back(result, ")"); + result.push_back(")"); break; case SyntaxEntity::E_IndexOperator: - ice::string::push_back(result, "["); + result.push_back("["); generate_expression(result, subs, func, arg, node.child()); - ice::string::push_back(result, "]"); + result.push_back("]"); break; default: break; @@ -191,7 +191,7 @@ namespace ice if (SyntaxNode assignnode = typenode.sibling(); assignnode) { - ice::string::push_back(result, " = "); + result.push_back(" = "); generate_expression(result, subs, func, arg, assignnode.child()); } @@ -210,17 +210,17 @@ namespace ice while (fnentry) { - ice::string::push_back(result, " "); + result.push_back(" "); if (SyntaxNode var = fnentry.to(); var) { generate_variable(result, subs, func, arg, ret, var); - ice::string::push_back(result, ";\n"); + result.push_back(";\n"); } else if (SyntaxNode exp = fnentry.to(); exp) { generate_expression(result, subs, func, arg, exp.child()); - ice::string::push_back(result, ";\n"); + result.push_back(";\n"); } fnentry = fnentry.sibling<>(); } @@ -261,7 +261,7 @@ namespace ice ice::string::push_format(result, " {} {};\n", type.name.value, member.data().name.value); member = member.sibling(); } - ice::string::push_back(result, "};\n\n"); + result.push_back("};\n\n"); } // Generate function definitions @@ -291,7 +291,7 @@ namespace ice member = member.sibling(); } - ice::string::push_back(result, "\n"); + result.push_back("\n"); member = shader._outputs.child(); while (member) @@ -308,7 +308,7 @@ namespace ice member = member.sibling(); } - ice::string::push_back(result, "\n"); + result.push_back("\n"); // Generate uniforms for (SyntaxNode variable : shader._uniforms) @@ -342,7 +342,7 @@ namespace ice { ice::string::push_format(result, "[{}]", vartype.size_array.value); } - ice::string::push_back(result, ";\n\n"); + result.push_back(";\n\n"); } else { @@ -382,7 +382,7 @@ namespace ice ice::string::push_format(result, "in {} _a_inputs, ", shader._inputs.data().name.value, arg.data().name.value); ice::string::push_format(result, "out {} _a_outputs) {{\n", shader._outputs.data().name.value, shader._mainfunc.data().name.value); generate_function(result, subs, shader._mainfunc.data(), arg.data(), ret.data(), body.child<>()); - ice::string::push_back(result, "}\n"); + result.push_back("}\n"); ice::string::push_format(result, "\nvoid {}() {{\n", "main"); // GLSL requires 'main' as the function name ice::string::push_format(result, " {0} inputs = {0}(", shader._inputs.data().name.value); @@ -395,7 +395,7 @@ namespace ice { if (builtin == "position") { - ice::string::push_back(result, "gl_FragCoord, "); + result.push_back("gl_FragCoord, "); } } else @@ -404,9 +404,9 @@ namespace ice } member = member.sibling(); } - ice::string::pop_back(result, 2); + result.pop_back(2); } - ice::string::push_back(result, ");\n"); + result.push_back(");\n"); ice::string::push_format(result, " {} outputs;\n", shader._outputs.data().name.value); ice::string::push_format(result, " asl_proxy_{}(inputs, outputs);\n", shader._mainfunc.data().name.value); { @@ -428,7 +428,7 @@ namespace ice member = member.sibling(); } } - ice::string::push_back(result, "}\n"); + result.push_back("}\n"); return result; }; @@ -517,7 +517,7 @@ namespace ice ); // Failed to transpile - if (ice::string::empty(out_result)) + if (out_result.is_empty()) { co_return E_FailedToTranspileASLShaderToGLSL; } @@ -527,10 +527,7 @@ namespace ice { out_entry_point = "main"; - co_return ice::String{ - (char const*)result.data.location, - (ice::ucount)result.data.size.value - }; + co_return ice::string_from_data(result.data); } } @@ -547,7 +544,7 @@ namespace ice ice::String const path = ice::resource_origin(source); ice::String const ext = ice::path::extension(path); - bool const is_vertex_shader = ice::string::substr(path, ice::string::size(path) - (4 + ice::size(ext)), ice::size(ext)) == "vert"; + bool const is_vertex_shader = path.substr(path.size() - (4 + ext.size()), ext.size()) == "vert"; ice::render::ShaderStageFlags const shader_stage = is_vertex_shader ? ice::render::ShaderStageFlags::VertexStage @@ -579,11 +576,11 @@ namespace ice shaderc::Compiler compiler{}; shaderc::SpvCompilationResult const spv_result = compiler.CompileGlslToSpv( - ice::string::begin(glsl_source), - ice::string::size(glsl_source), + glsl_source.begin(), + glsl_source.size(), is_vertex_shader ? shaderc_shader_kind::shaderc_vertex_shader : shaderc_shader_kind::shaderc_fragment_shader, - ice::string::begin(path), - ice::string::begin(entry_point), + path.begin(), + entry_point.begin(), compile_options ); @@ -608,11 +605,11 @@ namespace ice else { // Keep the string size so we can adjust the memory block result - ice::ucount const string_size = ice::size(transpiled_result); - result_mem = ice::string::extract_memory(transpiled_result); + ice::ncount const string_size = transpiled_result.size(); + result_mem = transpiled_result.extract_memory(); // Ensure memory size is equal to string size not its capacity. - result_mem.size.value = string_size; + result_mem.size = string_size; } // Unload resource before continuing diff --git a/source/code/modules/shader_tools/private/shader_tools_glsl.hxx b/source/code/modules/shader_tools/private/shader_tools_glsl.hxx index a1e6edf0..85f371d2 100644 --- a/source/code/modules/shader_tools/private/shader_tools_glsl.hxx +++ b/source/code/modules/shader_tools/private/shader_tools_glsl.hxx @@ -1,10 +1,10 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include -#include +#include #if ISP_WINDOWS || ISP_LINUX diff --git a/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx b/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx index 10c1c67c..0e3a10bc 100644 --- a/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx +++ b/source/code/modules/shader_tools/private/shader_tools_wgsl.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "shader_tools_wgsl.hxx" @@ -6,7 +6,7 @@ #if ISP_WINDOWS || ISP_LINUX || ISP_WEBAPP #include #include -#include +#include #include #include #include @@ -108,9 +108,9 @@ namespace ice syntax::Atom const& atom = node.to().data(); if (atom.is_parenthized) { - ice::string::push_back(result, "("); + result.push_back("("); generate_expression(result, subs, func, arg, node.child()); - ice::string::push_back(result, ")"); + result.push_back(")"); } else { @@ -123,7 +123,7 @@ namespace ice generate_expression(result, subs, func, arg, node.child()); if (node.sibling()) { - ice::string::push_back(result, ", "); + result.push_back(", "); } break; } @@ -149,12 +149,12 @@ namespace ice ice::string::push_format(result, "{}(", node.to().data().name.value); // Call children groups generate_expression(result, subs, func, arg, node.child()); - ice::string::push_back(result, ")"); + result.push_back(")"); break; case SyntaxEntity::E_IndexOperator: - ice::string::push_back(result, "["); + result.push_back("["); generate_expression(result, subs, func, arg, node.child()); - ice::string::push_back(result, "]"); + result.push_back("]"); break; default: break; @@ -184,7 +184,7 @@ namespace ice if (SyntaxNode assignnode = typenode.sibling(); assignnode) { - ice::string::push_back(result, " = "); + result.push_back(" = "); generate_expression(result, subs, func, arg, assignnode.child()); } @@ -203,17 +203,17 @@ namespace ice while (fnentry) { - ice::string::push_back(result, " "); + result.push_back(" "); if (SyntaxNode var = fnentry.to(); var) { generate_variable(result, subs, func, arg, ret, var); - ice::string::push_back(result, ";\n"); + result.push_back(";\n"); } else if (SyntaxNode exp = fnentry.to(); exp) { generate_expression(result, subs, func, arg, exp.child()); - ice::string::push_back(result, ";\n"); + result.push_back(";\n"); } fnentry = fnentry.sibling<>(); } @@ -262,7 +262,7 @@ namespace ice } else { - ice::string::push_back(result, " "); + result.push_back(" "); } wgsl::generate_type(result, member.data().name.value, type); @@ -270,7 +270,7 @@ namespace ice //ice::string::push_format(result, " {} {};\n", type.name.value, member.data().name.value); member = member.sibling(); } - ice::string::push_back(result, "};\n\n"); + result.push_back("};\n\n"); ICE_LOG_IF( is_uniform && is_inout, @@ -320,7 +320,7 @@ namespace ice } } - ice::string::push_back(result, "\n"); + result.push_back("\n"); // Generate shader main SyntaxNode arg = shader._mainfunc.child(); @@ -339,8 +339,8 @@ namespace ice ice::string::push_format(result, " var out: {};\n", shader._outputs.data().name.value); ice::hashmap::set(subs, detail::arc_hash(shader._mainfunc.data().name.value), arctic::String{ "out" }); generate_function(result, subs, shader._mainfunc.data(), arg.data(), ret.data(), body.child()); - ice::string::push_back(result, " return out;\n"); - ice::string::push_back(result, "}\n"); + result.push_back(" return out;\n"); + result.push_back("}\n"); return result; }; @@ -419,7 +419,7 @@ namespace ice ); // Failed to transpile - if (ice::string::empty(out_result)) + if (out_result.is_empty()) { co_return E_FailedToTranspileASLShaderToWGSL; } @@ -429,7 +429,7 @@ namespace ice { co_return ice::String{ (char const*) result.data.location, - (ice::ucount) result.data.size.value + (ice::u32) result.data.size.value }; } } @@ -447,7 +447,7 @@ namespace ice ice::String const path = ice::resource_origin(source); ice::String const ext = ice::path::extension(path); - bool const is_vertex_shader = ice::string::substr(path, ice::string::size(path) - (4 + ice::size(ext)), ice::size(ext)) == "vert"; + bool const is_vertex_shader = path.substr(path.size() - (4 + ext.size()), ext.size()) == "vert"; ice::render::ShaderStageFlags const shader_stage = is_vertex_shader ? ice::render::ShaderStageFlags::VertexStage @@ -475,13 +475,13 @@ namespace ice sctx.shader_main = entry_point; sctx.shader_type = static_cast(shader_stage); - ice::ucount const string_size = ice::size(transpiled_result); - ice::Memory memory = ice::string::extract_memory(transpiled_result); + ice::ncount const string_size = transpiled_result.size(); + ice::Memory memory = transpiled_result.extract_memory(); // Set the memory size to the final string size. Add '1' if the results has to be "compiled". // The added '1' is there because WebGPU shader loading functions to accept a size, so we need to ensure the loaded // data is '0' terminated. Returning memory with that '0' character ensure it's valid when loaded into memory. - memory.size.value = string_size + ice::u32(sctx.stage == ice::ShaderStage::Compiled); + memory.size = string_size + ice::u32(sctx.stage == ice::ShaderStage::Compiled); // Move the memory from the heapstring to Memory co_return ResourceCompilerResult{ .result = memory }; diff --git a/source/code/modules/shader_tools/private/shader_tools_wgsl.hxx b/source/code/modules/shader_tools/private/shader_tools_wgsl.hxx index 9334d27c..e524ec7d 100644 --- a/source/code/modules/shader_tools/private/shader_tools_wgsl.hxx +++ b/source/code/modules/shader_tools/private/shader_tools_wgsl.hxx @@ -1,9 +1,9 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #if ISP_WINDOWS || ISP_LINUX || ISP_WEBAPP #include diff --git a/source/code/modules/vulkan_renderer/private/vk_device.cxx b/source/code/modules/vulkan_renderer/private/vk_device.cxx index eb153449..b739e74e 100644 --- a/source/code/modules/vulkan_renderer/private/vk_device.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_device.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "vk_device.hxx" @@ -102,7 +102,7 @@ namespace ice::render::vk ); ICE_ASSERT( - ice::array::empty(surface_formats) == false, + surface_formats.not_empty(), "No supported image formats found for given surface!" ); @@ -118,7 +118,7 @@ namespace ice::render::vk "Failed to query surface capabilities!" ); - VkSurfaceFormatKHR selected_format = ice::array::front(surface_formats); + VkSurfaceFormatKHR selected_format = surface_formats.first(); if constexpr (ice::build::is_linux) { // If possible select UNORM istead of SRGB @@ -212,13 +212,13 @@ namespace ice::render::vk auto VulkanRenderDevice::create_renderpass(ice::render::RenderpassInfo const& info) noexcept -> ice::render::Renderpass { ice::Array attachments{ _allocator }; - ice::array::reserve(attachments, ice::count(info.attachments)); + attachments.reserve(info.attachments.size().u32()); ice::Array subpass_list{ _allocator }; - ice::array::reserve(subpass_list, ice::count(info.subpasses)); + subpass_list.reserve(info.subpasses.size().u32()); ice::Array dependencies { _allocator }; - ice::array::reserve(dependencies, ice::count(info.dependencies)); + dependencies.reserve(info.dependencies.size().u32()); ice::Array attachment_references{ _allocator }; @@ -244,29 +244,29 @@ namespace ice::render::vk attachment.initialLayout = native_enum_value(attachment_info.initial_layout);; attachment.finalLayout = native_enum_value(attachment_info.final_layout); - ice::array::push_back(attachments, attachment); + attachments.push_back(attachment); } ice::u64 reference_count = 0; for (RenderSubPass const& subpass_info : info.subpasses) { - reference_count += ice::count(subpass_info.color_attachments) - + ice::count(subpass_info.input_attachments) + reference_count += subpass_info.color_attachments.size() + + subpass_info.input_attachments.size() + 1; } - ice::array::reserve(attachment_references, static_cast(reference_count)); + attachment_references.reserve(static_cast(reference_count)); auto store_references = [&attachment_references](ice::Span references) noexcept -> ice::u32 { - ice::u32 ref_index = ice::count(attachment_references); + ice::u32 ref_index = attachment_references.size().u32(); for (AttachmentReference const& attachment_ref : references) { VkAttachmentReference reference{ }; // VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2 }; reference.attachment = attachment_ref.attachment_index; reference.layout = native_enum_value(attachment_ref.layout); - ice::array::push_back(attachment_references, reference); + attachment_references.push_back(reference); } return ref_index; }; @@ -278,12 +278,12 @@ namespace ice::render::vk VkSubpassDescription subpass{ }; // VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2 }; subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; - subpass.inputAttachmentCount = ice::count(subpass_info.input_attachments); + subpass.inputAttachmentCount = subpass_info.input_attachments.size().u32(); if (subpass.inputAttachmentCount > 0) { subpass.pInputAttachments = std::addressof(attachment_references[input_ref_idx]); } - subpass.colorAttachmentCount = ice::count(subpass_info.color_attachments); + subpass.colorAttachmentCount = subpass_info.color_attachments.size().u32(); if (subpass.colorAttachmentCount > 0) { subpass.pColorAttachments = std::addressof(attachment_references[color_ref_idx]); @@ -294,7 +294,7 @@ namespace ice::render::vk subpass.pDepthStencilAttachment = std::addressof(attachment_references[depth_ref_idx]); } - ice::array::push_back(subpass_list, subpass); + subpass_list.push_back(subpass); } for (SubpassDependency const& dependency_info : info.dependencies) @@ -308,16 +308,16 @@ namespace ice::render::vk dependency.dstAccessMask = native_enum_value(dependency_info.destination_access); dependency.dependencyFlags = VkDependencyFlagBits::VK_DEPENDENCY_BY_REGION_BIT; - ice::array::push_back(dependencies, dependency); + dependencies.push_back(dependency); } VkRenderPassCreateInfo renderpass_info{ VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO }; - renderpass_info.attachmentCount = ice::array::count(attachments); - renderpass_info.pAttachments = ice::array::begin(attachments); - renderpass_info.subpassCount = ice::array::count(subpass_list); - renderpass_info.pSubpasses = ice::array::begin(subpass_list); - renderpass_info.dependencyCount = ice::array::count(dependencies); - renderpass_info.pDependencies = ice::array::begin(dependencies); + renderpass_info.attachmentCount = attachments.size().u32(); + renderpass_info.pAttachments = attachments.begin(); + renderpass_info.subpassCount = subpass_list.size().u32(); + renderpass_info.pSubpasses = subpass_list.begin(); + renderpass_info.dependencyCount = dependencies.size().u32(); + renderpass_info.pDependencies = dependencies.begin(); VkRenderPass renderpass; VkResult result = vkCreateRenderPass(_vk_device, &renderpass_info, nullptr, &renderpass); @@ -343,12 +343,11 @@ namespace ice::render::vk ) noexcept -> ice::render::ResourceSetLayout { ice::Array vk_bindings{ _allocator }; - ice::array::reserve(vk_bindings, ice::count(bindings)); + vk_bindings.reserve(bindings.size().u32()); for (ResourceSetLayoutBinding const& binding : bindings) { - ice::array::push_back( - vk_bindings, + vk_bindings.push_back( VkDescriptorSetLayoutBinding{ .binding = binding.binding_index, .descriptorType = native_enum_value(binding.resource_type), @@ -360,8 +359,8 @@ namespace ice::render::vk } VkDescriptorSetLayoutCreateInfo layout_info{ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO }; - layout_info.bindingCount = ice::count(bindings); - layout_info.pBindings = ice::begin(vk_bindings); + layout_info.bindingCount = bindings.size().u32(); + layout_info.pBindings = vk_bindings.begin(); VkDescriptorSetLayout vk_descriptor_set_layout = vk_nullptr; VkResult result = vkCreateDescriptorSetLayout( @@ -402,7 +401,7 @@ namespace ice::render::vk ); ICE_ASSERT( - ice::count(resource_set_layouts) == ice::count(resource_sets_out), + resource_set_layouts.size() == resource_sets_out.size(), "The output span size does not match the size of provided layouts span." ); @@ -410,7 +409,7 @@ namespace ice::render::vk VkDescriptorSetAllocateInfo descriptorset_info{ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO }; descriptorset_info.descriptorPool = _vk_descriptor_pool; - descriptorset_info.descriptorSetCount = ice::count(resource_set_layouts); + descriptorset_info.descriptorSetCount = resource_set_layouts.size().u32(); descriptorset_info.pSetLayouts = reinterpret_cast(&resource_set_layouts[0]); VkResult result = vkAllocateDescriptorSets( @@ -421,7 +420,7 @@ namespace ice::render::vk ICE_ASSERT( result == VkResult::VK_SUCCESS, "Couldn't allocate new {} descriptor sets.", - ice::count(resource_set_layouts) + resource_set_layouts.size() ); return true; } @@ -433,13 +432,13 @@ namespace ice::render::vk VkResult result = vkFreeDescriptorSets( _vk_device, _vk_descriptor_pool, - ice::count(resource_sets), + resource_sets.size().u32(), reinterpret_cast(&resource_sets[0]) ); ICE_ASSERT( result == VkResult::VK_SUCCESS, "Failed to free given {} descriptor sets.", - ice::count(resource_sets) + resource_sets.size() ); } @@ -448,7 +447,7 @@ namespace ice::render::vk ) noexcept { ice::Array vk_writes{ _allocator }; - ice::array::reserve(vk_writes, ice::count(update_infos)); + vk_writes.reserve(update_infos.size().u32()); ice::Array write_image_info{ _allocator }; ice::Array write_buffer_info{ _allocator }; @@ -468,7 +467,7 @@ namespace ice::render::vk image_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; image_info.imageView = image_ptr->vk_image_view; - ice::array::push_back(write_image_info, image_info); + write_image_info.push_back(image_info); } } @@ -481,7 +480,7 @@ namespace ice::render::vk VkDescriptorImageInfo sampler_info; sampler_info.sampler = vk_sampler; - ice::array::push_back(write_image_info, sampler_info); + write_image_info.push_back(sampler_info); } } @@ -498,7 +497,7 @@ namespace ice::render::vk buffer_info.offset = resource_info.uniform_buffer.offset; buffer_info.range = resource_info.uniform_buffer.size; - ice::array::push_back(write_buffer_info, buffer_info); + write_buffer_info.push_back(buffer_info); } } } @@ -511,34 +510,34 @@ namespace ice::render::vk descriptor_set_write.dstBinding = update_info.binding_index; descriptor_set_write.dstArrayElement = update_info.array_element; descriptor_set_write.dstSet = native_handle(update_info.resource_set); - descriptor_set_write.descriptorCount = ice::count(update_info.resources); + descriptor_set_write.descriptorCount = update_info.resources.size().u32(); descriptor_set_write.descriptorType = native_enum_value(update_info.resource_type); if (update_info.resource_type == ResourceType::SampledImage || update_info.resource_type == ResourceType::InputAttachment) { - descriptor_set_write.pImageInfo = ice::array::begin(write_image_info) + images_offset; - images_offset += ice::count(update_info.resources); + descriptor_set_write.pImageInfo = write_image_info.begin() + images_offset; + images_offset += update_info.resources.size().u32(); } if (update_info.resource_type == ResourceType::Sampler) { - descriptor_set_write.pImageInfo = ice::array::begin(write_image_info) + images_offset; - images_offset += ice::count(update_info.resources); + descriptor_set_write.pImageInfo = write_image_info.begin() + images_offset; + images_offset += update_info.resources.size().u32(); } if (update_info.resource_type == ResourceType::UniformBuffer) { - descriptor_set_write.pBufferInfo = ice::array::begin(write_buffer_info) + buffers_offset; - buffers_offset += ice::count(update_info.resources); + descriptor_set_write.pBufferInfo = write_buffer_info.begin() + buffers_offset; + buffers_offset += update_info.resources.size().u32(); } - ice::array::push_back(vk_writes, descriptor_set_write); + vk_writes.push_back(descriptor_set_write); } vkUpdateDescriptorSets( _vk_device, - ice::count(vk_writes), - ice::begin(vk_writes), + vk_writes.size().u32(), + vk_writes.begin(), 0, nullptr ); } @@ -548,15 +547,14 @@ namespace ice::render::vk ) noexcept -> ice::render::PipelineLayout { ice::Array vk_push_constants{ _allocator }; - ice::array::reserve(vk_push_constants, ice::count(info.push_constants)); + vk_push_constants.reserve(info.push_constants.size().u32()); ice::Array vk_descriptorset_layouts{ _allocator }; - ice::array::reserve(vk_descriptorset_layouts, ice::count(info.resource_layouts)); + vk_descriptorset_layouts.reserve(info.resource_layouts.size().u32()); for (PipelinePushConstant const& push_constant : info.push_constants) { - ice::array::push_back( - vk_push_constants, + vk_push_constants.push_back( VkPushConstantRange{ .stageFlags = native_enum_flags(push_constant.shader_stage_flags), .offset = push_constant.offset, @@ -567,17 +565,16 @@ namespace ice::render::vk for (ResourceSetLayout layout : info.resource_layouts) { - ice::array::push_back( - vk_descriptorset_layouts, + vk_descriptorset_layouts.push_back( native_handle(layout) ); } VkPipelineLayoutCreateInfo pipeline_info{ VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO }; - pipeline_info.pushConstantRangeCount = ice::count(info.push_constants); - pipeline_info.pPushConstantRanges = ice::begin(vk_push_constants); - pipeline_info.setLayoutCount = ice::count(info.resource_layouts); - pipeline_info.pSetLayouts = ice::begin(vk_descriptorset_layouts); + pipeline_info.pushConstantRangeCount = info.push_constants.size().u32(); + pipeline_info.pPushConstantRanges = vk_push_constants.begin(); + pipeline_info.setLayoutCount = info.resource_layouts.size().u32(); + pipeline_info.pSetLayouts = vk_descriptorset_layouts.begin(); VkPipelineLayout pipeline_layout = vk_nullptr; VkResult result = vkCreatePipelineLayout( @@ -644,7 +641,7 @@ namespace ice::render::vk ) noexcept -> ice::render::Pipeline { VkPipelineShaderStageCreateInfo shader_stages[10]; - ice::u32 const stage_count = ice::count(info.shaders); + ice::u32 const stage_count = info.shaders.size().u32(); uint32_t stage_idx = 0; for (; stage_idx < stage_count; ++stage_idx) @@ -656,9 +653,9 @@ namespace ice::render::vk shader_stage.flags = 0; shader_stage.stage = native_enum_value(info.shaders[stage_idx].stage); shader_stage.module = native_handle(info.shaders[stage_idx].shader); - if (ice::string::any(info.shaders[stage_idx].entry_point)) + if (info.shaders[stage_idx].entry_point.not_empty()) { - shader_stage.pName = ice::string::begin(info.shaders[stage_idx].entry_point); + shader_stage.pName = info.shaders[stage_idx].entry_point.begin(); } else { @@ -695,8 +692,8 @@ namespace ice::render::vk ice::Array vertex_input_bindings{ _allocator }; ice::Array vertex_input_attributes{ _allocator }; - ice::array::reserve(vertex_input_bindings, ice::count(info.vertex_bindings)); - ice::array::reserve(vertex_input_attributes, ice::count(info.vertex_bindings) * 4); + vertex_input_bindings.reserve(info.vertex_bindings.size().u32()); + vertex_input_attributes.reserve(info.vertex_bindings.size().u32() * 4); for (ice::render::ShaderInputBinding const& binding : info.vertex_bindings) { @@ -704,7 +701,7 @@ namespace ice::render::vk vk_binding.binding = binding.binding; vk_binding.stride = binding.stride; vk_binding.inputRate = static_cast(binding.instanced); - ice::array::push_back(vertex_input_bindings, vk_binding); + vertex_input_bindings.push_back(vk_binding); for (ice::render::ShaderInputAttribute const& attrib : binding.attributes) { @@ -713,15 +710,15 @@ namespace ice::render::vk vk_attrib.location = attrib.location; vk_attrib.offset = attrib.offset; vk_attrib.binding = binding.binding; - ice::array::push_back(vertex_input_attributes, vk_attrib); + vertex_input_attributes.push_back(vk_attrib); } } VkPipelineVertexInputStateCreateInfo vertex_input{ VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO }; - vertex_input.vertexBindingDescriptionCount = ice::array::count(vertex_input_bindings); - vertex_input.pVertexBindingDescriptions = ice::array::begin(vertex_input_bindings); - vertex_input.vertexAttributeDescriptionCount = ice::array::count(vertex_input_attributes); - vertex_input.pVertexAttributeDescriptions = ice::array::begin(vertex_input_attributes); + vertex_input.vertexBindingDescriptionCount = vertex_input_bindings.size().u32(); + vertex_input.pVertexBindingDescriptions = vertex_input_bindings.begin(); + vertex_input.vertexAttributeDescriptionCount= vertex_input_attributes.size().u32(); + vertex_input.pVertexAttributeDescriptions = vertex_input_attributes.begin(); VkPipelineInputAssemblyStateCreateInfo input_assembly{ VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO }; input_assembly.primitiveRestartEnable = VK_FALSE; @@ -734,8 +731,9 @@ namespace ice::render::vk case CullMode::Disabled: rasterization.cullMode = VK_CULL_MODE_NONE; // [issue #34] Needs to be properly available in the creation API. - if (ice::count(info.shaders) == 5) + if (info.shaders.size() == 5) { + ICE_ASSERT(false, "Old workaround to play with geometry shaders!"); rasterization.polygonMode = VK_POLYGON_MODE_LINE; } break; @@ -910,12 +908,12 @@ namespace ice::render::vk ice::Span update_infos ) noexcept { - ice::ucount const update_count = ice::count(update_infos); + ice::u32 const update_count = update_infos.size().u32(); - ice::ucount update_offset = 0; + ice::u32 update_offset = 0; while(update_offset < update_count) { - ice::ucount const current_update_count = ice::min(update_count - update_offset, 16u); + ice::u32 const current_update_count = ice::min(update_count - update_offset, 16u); // We map up to 16 pointers at one time so VMA does not continously call vkMap and vkUnmap for each object entry. void* data_pointers[16]; @@ -956,18 +954,18 @@ namespace ice::render::vk VkRenderPass vk_renderpass = reinterpret_cast(static_cast(renderpass)); ice::Array vk_images{ _allocator }; - ice::array::reserve(vk_images, ice::count(images)); + vk_images.reserve(images.size().u32()); for (Image image : images) { VulkanImage* const image_ptr = reinterpret_cast(static_cast(image)); - ice::array::push_back(vk_images, image_ptr->vk_image_view); + vk_images.push_back(image_ptr->vk_image_view); } VkFramebufferCreateInfo fb_info{ VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO }; fb_info.renderPass = vk_renderpass; - fb_info.attachmentCount = ice::array::count(vk_images); - fb_info.pAttachments = ice::array::begin(vk_images); + fb_info.attachmentCount = vk_images.size().u32(); + fb_info.pAttachments = vk_images.begin(); fb_info.width = extent.x; fb_info.height = extent.y; fb_info.layers = 1; @@ -1094,7 +1092,7 @@ namespace ice::render::vk vkGetDeviceQueue(_vk_device, queue_family_index, queue_index, &queue); ice::Array cmd_pools{ _allocator }; - ice::array::reserve(cmd_pools, command_pools); + cmd_pools.reserve(command_pools); for (ice::u32 idx = 0; idx < command_pools; ++idx) { @@ -1109,7 +1107,7 @@ namespace ice::render::vk "Failed to create command pool for device!" ); - ice::array::push_back(cmd_pools, vk_cmd_pool); + cmd_pools.push_back(vk_cmd_pool); } const bool profiled = ice::has_any(flags, QueueFlags::Compute | QueueFlags::Graphics); diff --git a/source/code/modules/vulkan_renderer/private/vk_device.hxx b/source/code/modules/vulkan_renderer/private/vk_device.hxx index 1a00999c..db9ab19d 100644 --- a/source/code/modules/vulkan_renderer/private/vk_device.hxx +++ b/source/code/modules/vulkan_renderer/private/vk_device.hxx @@ -2,8 +2,8 @@ /// SPDX-License-Identifier: MIT #pragma once +#include #include -#include #include #include diff --git a/source/code/modules/vulkan_renderer/private/vk_driver.cxx b/source/code/modules/vulkan_renderer/private/vk_driver.cxx index 80c71f03..4f391a72 100644 --- a/source/code/modules/vulkan_renderer/private/vk_driver.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_driver.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "vk_driver.hxx" @@ -7,7 +7,7 @@ #include "vk_include.hxx" #include "vk_utility.hxx" -#include +#include #include extern "C" @@ -103,7 +103,7 @@ namespace ice::render::vk if (enumerate_objects(_vk_queue_family_properties, vkGetPhysicalDeviceQueueFamilyProperties, _vk_physical_device)) { - VK_LOG(ice::LogSeverity::Debug, "Device has {} queue families", count(_vk_queue_family_properties)); + VK_LOG(ice::LogSeverity::Debug, "Device has {} queue families", _vk_queue_family_properties.size()); } } @@ -310,7 +310,7 @@ namespace ice::render::vk } ice::u32 queue_index = 0; - ice::array::reserve(queue_info, queue_count); + queue_info.reserve(queue_count); for (VkQueueFamilyProperties const& queue_family_props : _vk_queue_family_properties) { QueueFlags flags = QueueFlags::None; @@ -332,8 +332,7 @@ namespace ice::render::vk flags = flags | QueueFlags::Present; } - ice::array::push_back( - queue_info, + queue_info.push_back( QueueFamilyInfo{ .id = QueueID{ queue_index }, .flags = flags, @@ -357,7 +356,7 @@ namespace ice::render::vk }; ice::Array queue_create_infos{ _allocator }; - ice::array::reserve(queue_create_infos, 3); + queue_create_infos.reserve(3); for (QueueInfo const& queue_info : queue_infos) { @@ -368,10 +367,10 @@ namespace ice::render::vk queue_create_info.queueCount = queue_info.count; queue_create_info.pQueuePriorities = queue_priorities; - ice::array::push_back(queue_create_infos, queue_create_info); + queue_create_infos.push_back(queue_create_info); } - ice::ucount count_extensions = 0; + ice::u32 count_extensions = 0; ice::Array extension_names{ _allocator }; Extension const device_extensions = extensions_gather_names(extension_names, count_extensions, _vk_physical_device); ICE_ASSERT_CORE(ice::has_all(device_extensions, Extension::VkD_Swapchain)); @@ -387,9 +386,9 @@ namespace ice::render::vk VkDeviceCreateInfo device_create_info{ .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO }; device_create_info.pEnabledFeatures = &enabled_device_features; device_create_info.enabledExtensionCount = count_extensions; - device_create_info.ppEnabledExtensionNames = ice::array::begin(extension_names); - device_create_info.pQueueCreateInfos = ice::array::begin(queue_create_infos); - device_create_info.queueCreateInfoCount = ice::array::count(queue_create_infos); + device_create_info.ppEnabledExtensionNames = extension_names.begin(); + device_create_info.pQueueCreateInfos = queue_create_infos.begin(); + device_create_info.queueCreateInfoCount = queue_create_infos.size().u32(); VkDevice vk_device; VkResult result = vkCreateDevice( diff --git a/source/code/modules/vulkan_renderer/private/vk_driver.hxx b/source/code/modules/vulkan_renderer/private/vk_driver.hxx index 6e625f6f..55542d21 100644 --- a/source/code/modules/vulkan_renderer/private/vk_driver.hxx +++ b/source/code/modules/vulkan_renderer/private/vk_driver.hxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include "vk_allocator.hxx" #include "vk_memory_allocator.hxx" #include "vk_extensions.hxx" diff --git a/source/code/modules/vulkan_renderer/private/vk_extensions.cxx b/source/code/modules/vulkan_renderer/private/vk_extensions.cxx index 3fb0b6b4..39c16cce 100644 --- a/source/code/modules/vulkan_renderer/private/vk_extensions.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_extensions.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "vk_extensions.hxx" @@ -31,7 +31,7 @@ namespace ice::render::vk { ExtensionTarget::VmaExtension, Extension::Vma_MemoryBudget, VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT, "" }, }; - auto gather_instance_layers(ice::Array& out_names, ice::ucount& out_count) noexcept -> Extension + auto gather_instance_layers(ice::Array& out_names, ice::u32& out_count) noexcept -> Extension { Extension result = Extension::None; @@ -58,7 +58,7 @@ namespace ice::render::vk { result |= supported.extension; out_count += 1; - ice::array::push_back(out_names, supported.identifier); + out_names.push_back(supported.identifier); } } } @@ -67,7 +67,7 @@ namespace ice::render::vk return result; } - auto gather_instance_extensions(ice::Array& out_names, ice::ucount& out_count) noexcept -> Extension + auto gather_instance_extensions(ice::Array& out_names, ice::u32& out_count) noexcept -> Extension { Extension result = Extension::None; @@ -94,7 +94,7 @@ namespace ice::render::vk { result |= supported.extension; out_count += 1; - ice::array::push_back(out_names, supported.identifier); + out_names.push_back(supported.identifier); } } } @@ -103,7 +103,7 @@ namespace ice::render::vk return result; } - auto gather_device_extensions(ice::Array& out_names, ice::ucount& out_count, VkPhysicalDevice physical_device) noexcept -> Extension + auto gather_device_extensions(ice::Array& out_names, ice::u32& out_count, VkPhysicalDevice physical_device) noexcept -> Extension { Extension result = Extension::None; @@ -130,7 +130,7 @@ namespace ice::render::vk { result |= supported.extension; out_count += 1; - ice::array::push_back(out_names, supported.identifier); + out_names.push_back(supported.identifier); } } } @@ -139,7 +139,7 @@ namespace ice::render::vk return result; } - auto extensions_gather_names(ice::Array& out_names, ice::ucount& out_count, ExtensionTarget target) noexcept -> Extension + auto extensions_gather_names(ice::Array& out_names, ice::u32& out_count, ExtensionTarget target) noexcept -> Extension { switch(target) { @@ -152,7 +152,7 @@ namespace ice::render::vk } } - auto extensions_gather_names(ice::Array& out_names, ice::ucount &out_count, VkPhysicalDevice physical_device) noexcept -> Extension + auto extensions_gather_names(ice::Array& out_names, ice::u32 &out_count, VkPhysicalDevice physical_device) noexcept -> Extension { return gather_device_extensions(out_names, out_count, physical_device); } diff --git a/source/code/modules/vulkan_renderer/private/vk_extensions.hxx b/source/code/modules/vulkan_renderer/private/vk_extensions.hxx index ae267243..415b437e 100644 --- a/source/code/modules/vulkan_renderer/private/vk_extensions.hxx +++ b/source/code/modules/vulkan_renderer/private/vk_extensions.hxx @@ -1,8 +1,8 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include "vk_include.hxx" namespace ice::render::vk @@ -56,13 +56,13 @@ namespace ice::render::vk auto extensions_gather_names( ice::Array& out_names, - ice::ucount& out_count, + ice::u32& out_count, ExtensionTarget target ) noexcept -> Extension; auto extensions_gather_names( ice::Array& out_names, - ice::ucount& out_count, + ice::u32& out_count, VkPhysicalDevice physical_device ) noexcept -> Extension; diff --git a/source/code/modules/vulkan_renderer/private/vk_module.cxx b/source/code/modules/vulkan_renderer/private/vk_module.cxx index 554f69cc..ab043073 100644 --- a/source/code/modules/vulkan_renderer/private/vk_module.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_module.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -23,11 +23,11 @@ namespace ice::render::vk app_info.engineVersion = 1; app_info.apiVersion = VK_API_VERSION_1_3; - ice::ucount layer_count = 0; + ice::u32 layer_count = 0; ice::Array names{ alloc }; Extension extensions = extensions_gather_names(names, layer_count, ExtensionTarget::InstanceLayer); - ice::ucount extension_count = 0; + ice::u32 extension_count = 0; extensions |= extensions_gather_names(names, extension_count, ExtensionTarget::InstanceExtension); ICE_ASSERT_CORE(ice::has_all(extensions, Extension::VkI_Surface)); ICE_ASSERT_CORE(ice::has_any(extensions, Extension::VkI_AndroidSurface | Extension::VkI_Win32Surface)); @@ -36,16 +36,16 @@ namespace ice::render::vk instance_create_info.flags = 0; instance_create_info.pApplicationInfo = &app_info; instance_create_info.enabledLayerCount = layer_count; - instance_create_info.ppEnabledLayerNames = ice::array::begin(names); + instance_create_info.ppEnabledLayerNames = names.begin(); instance_create_info.enabledExtensionCount = extension_count; - instance_create_info.ppEnabledExtensionNames = ice::array::begin(names) + layer_count; + instance_create_info.ppEnabledExtensionNames = names.begin() + layer_count; VkInstance vk_instance; VkResult const vk_create_result = vkCreateInstance(&instance_create_info, vk_alloc->vulkan_callbacks(), &vk_instance); ICE_ASSERT(vk_create_result == VkResult::VK_SUCCESS, "Creation of Vulkan instance failed!"); // Release the array backing data - ice::array::set_capacity(names, 0); + names.set_capacity(0); return alloc.create(alloc, ice::move(vk_alloc), vk_instance, extensions); } diff --git a/source/code/modules/vulkan_renderer/private/vk_queue.cxx b/source/code/modules/vulkan_renderer/private/vk_queue.cxx index a8e37ebf..177df7ff 100644 --- a/source/code/modules/vulkan_renderer/private/vk_queue.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_queue.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "vk_queue.hxx" @@ -51,7 +51,7 @@ namespace ice::render::vk VkCommandBufferAllocateInfo alloc_info{ VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO }; alloc_info.level = type == CommandBufferType::Primary ? VK_COMMAND_BUFFER_LEVEL_PRIMARY : VK_COMMAND_BUFFER_LEVEL_SECONDARY; alloc_info.commandPool = _vk_cmd_pools[pool_index]; - alloc_info.commandBufferCount = ice::count(buffers); + alloc_info.commandBufferCount = buffers.size().u32(); ICE_ASSERT_CORE(alloc_info.commandBufferCount < 16); VkResult result = vkAllocateCommandBuffers( @@ -95,7 +95,7 @@ namespace ice::render::vk ice::Span buffers ) noexcept { - if (ice::span::empty(buffers)) + if (buffers.is_empty()) { return; } @@ -137,9 +137,9 @@ namespace ice::render::vk ) noexcept { VkCommandBuffer vk_temp_buffers[16]; - ICE_ASSERT_CORE(ice::count(buffers) < 16); + ICE_ASSERT_CORE(buffers.size() < 16); - ice::ucount count = 0; + ice::u32 count = 0; for (ice::render::CommandBuffer handle : buffers) { vk_temp_buffers[count] = VulkanCommandBuffer::native(handle)->buffer; diff --git a/source/code/modules/vulkan_renderer/private/vk_queue.hxx b/source/code/modules/vulkan_renderer/private/vk_queue.hxx index 30544331..3ae6bada 100644 --- a/source/code/modules/vulkan_renderer/private/vk_queue.hxx +++ b/source/code/modules/vulkan_renderer/private/vk_queue.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include "vk_command_buffer.hxx" #include "vk_swapchain.hxx" #include "vk_include.hxx" diff --git a/source/code/modules/vulkan_renderer/private/vk_swapchain.cxx b/source/code/modules/vulkan_renderer/private/vk_swapchain.cxx index 7b075bc5..dcda147c 100644 --- a/source/code/modules/vulkan_renderer/private/vk_swapchain.cxx +++ b/source/code/modules/vulkan_renderer/private/vk_swapchain.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "vk_swapchain.hxx" @@ -126,7 +126,7 @@ namespace ice::render::vk // TODO: Can we do this differently? if (result != VK_SUCCESS) { - return ice::ucount_max; + return ice::u32_max; } //ICE_ASSERT( diff --git a/source/code/modules/vulkan_renderer/private/vk_utility.hxx b/source/code/modules/vulkan_renderer/private/vk_utility.hxx index 205ffe4b..560e2162 100644 --- a/source/code/modules/vulkan_renderer/private/vk_utility.hxx +++ b/source/code/modules/vulkan_renderer/private/vk_utility.hxx @@ -1,8 +1,8 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include #include @@ -86,8 +86,8 @@ namespace ice::render::vk fn(args..., &obj_count, nullptr); if (obj_count > 0) { - ice::array::resize(objects_out, obj_count); - fn(args..., &obj_count, ice::array::begin(objects_out)); + objects_out.resize(obj_count); + fn(args..., &obj_count, objects_out.begin()); } return true; } @@ -97,9 +97,9 @@ namespace ice::render::vk VkResult result = fn(args..., &obj_count, nullptr); if (result == VkResult::VK_SUCCESS && obj_count > 0) { - ice::array::resize(objects_out, obj_count); + objects_out.resize(obj_count); - result = fn(args..., &obj_count, ice::array::begin(objects_out)); + result = fn(args..., &obj_count, objects_out.begin()); } return result == VK_SUCCESS; } diff --git a/source/code/modules/webgpu_renderer/private/webgpu_framebuffer.hxx b/source/code/modules/webgpu_renderer/private/webgpu_framebuffer.hxx index 1f7b6de3..3469061d 100644 --- a/source/code/modules/webgpu_renderer/private/webgpu_framebuffer.hxx +++ b/source/code/modules/webgpu_renderer/private/webgpu_framebuffer.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include "webgpu_utils.hxx" #include "webgpu_image.hxx" diff --git a/source/code/modules/webgpu_renderer/private/webgpu_renderpass.hxx b/source/code/modules/webgpu_renderer/private/webgpu_renderpass.hxx index f46e6200..ddf87d5c 100644 --- a/source/code/modules/webgpu_renderer/private/webgpu_renderpass.hxx +++ b/source/code/modules/webgpu_renderer/private/webgpu_renderpass.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include "webgpu_utils.hxx" #include "webgpu_image.hxx" diff --git a/source/code/platforms/application/private/app_info.cxx b/source/code/platforms/application/private/app_info.cxx index bea93d8c..d6cc3190 100644 --- a/source/code/platforms/application/private/app_info.cxx +++ b/source/code/platforms/application/private/app_info.cxx @@ -1,10 +1,9 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include #include #include -#include #include namespace ice::app @@ -26,8 +25,8 @@ namespace ice::app static ice::StaticString<256> app_location = []() noexcept { ice::StaticString<256, ice::wchar> location_wide{ L"" }; - DWORD const path_size = GetModuleFileNameW(NULL, ice::string::begin(location_wide), ice::string::capacity(location_wide)); - ice::string::resize(location_wide, path_size); + DWORD const path_size = GetModuleFileNameW(NULL, location_wide.begin(), location_wide.capacity().u32()); + location_wide.resize(path_size); ice::StackAllocator_1024 stack_alloc; ice::HeapString<> location_utf8{ stack_alloc }; @@ -50,8 +49,8 @@ namespace ice::app static ice::StaticString<256> working_dir = []() noexcept { ice::StaticString<256, ice::wchar> location_wide{ L"" }; - DWORD const path_size = GetCurrentDirectoryW(ice::string::capacity(location_wide), ice::string::begin(location_wide)); - ice::string::resize(location_wide, path_size); + DWORD const path_size = GetCurrentDirectoryW(location_wide.capacity().u32(), location_wide.begin()); + location_wide.resize(path_size); ice::StackAllocator_1024 stack_alloc; ice::HeapString<> location_utf8{ stack_alloc }; diff --git a/source/code/platforms/platform/public/ice/platform_event.hxx b/source/code/platforms/platform/public/ice/platform_event.hxx index 799153ea..a61e5e3e 100644 --- a/source/code/platforms/platform/public/ice/platform_event.hxx +++ b/source/code/platforms/platform/public/ice/platform_event.hxx @@ -1,11 +1,11 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include #include -#include +#include namespace ice::platform { diff --git a/source/code/platforms/platform/public/ice/platform_render_surface.hxx b/source/code/platforms/platform/public/ice/platform_render_surface.hxx index d6c400d4..239ec28d 100644 --- a/source/code/platforms/platform/public/ice/platform_render_surface.hxx +++ b/source/code/platforms/platform/public/ice/platform_render_surface.hxx @@ -1,9 +1,9 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include #include diff --git a/source/code/platforms/platform/public/ice/platform_storage.hxx b/source/code/platforms/platform/public/ice/platform_storage.hxx index 91ed9482..d83c3240 100644 --- a/source/code/platforms/platform/public/ice/platform_storage.hxx +++ b/source/code/platforms/platform/public/ice/platform_storage.hxx @@ -1,9 +1,9 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include namespace ice::platform diff --git a/source/code/platforms/platform_android/private/android_app.cxx b/source/code/platforms/platform_android/private/android_app.cxx index d3138fd3..f8a06630 100644 --- a/source/code/platforms/platform_android/private/android_app.cxx +++ b/source/code/platforms/platform_android/private/android_app.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "android_app.hxx" @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/source/code/platforms/platform_linux/private/linux_sdl2_utils.cxx b/source/code/platforms/platform_linux/private/linux_sdl2_utils.cxx index c7786940..8a7fb1cc 100644 --- a/source/code/platforms/platform_linux/private/linux_sdl2_utils.cxx +++ b/source/code/platforms/platform_linux/private/linux_sdl2_utils.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "linux_sdl2_utils.hxx" diff --git a/source/code/platforms/platform_linux/private/linux_storage.cxx b/source/code/platforms/platform_linux/private/linux_storage.cxx index 91e8d239..5e8d5b04 100644 --- a/source/code/platforms/platform_linux/private/linux_storage.cxx +++ b/source/code/platforms/platform_linux/private/linux_storage.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "linux_storage.hxx" @@ -45,7 +45,7 @@ namespace ice::platform::linux } ice::ucount const idassignment = ice::string::find_first_of(line, '='); - if (idassignment == ice::String_NPos) + if (idassignment == ice::none_index) { ICE_LOG(LogSeverity::Warning, LogTag::Core, "Improperly formatted line: {}", line); return true; diff --git a/source/code/platforms/platform_linux/private/linux_storage.hxx b/source/code/platforms/platform_linux/private/linux_storage.hxx index 877093f8..77fa09ac 100644 --- a/source/code/platforms/platform_linux/private/linux_storage.hxx +++ b/source/code/platforms/platform_linux/private/linux_storage.hxx @@ -1,9 +1,9 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include #include diff --git a/source/code/platforms/platform_webasm/private/webasm_core_app.hxx b/source/code/platforms/platform_webasm/private/webasm_core_app.hxx index 2e8090f9..b4d23b8c 100644 --- a/source/code/platforms/platform_webasm/private/webasm_core_app.hxx +++ b/source/code/platforms/platform_webasm/private/webasm_core_app.hxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/source/code/platforms/platform_win32/private/win32_sdl2_platform.cxx b/source/code/platforms/platform_win32/private/win32_sdl2_platform.cxx index 7ffa5dd0..e7c4e852 100644 --- a/source/code/platforms/platform_win32/private/win32_sdl2_platform.cxx +++ b/source/code/platforms/platform_win32/private/win32_sdl2_platform.cxx @@ -20,7 +20,7 @@ namespace ice::platform::win32::sdl2 , _render_surface{ } { ice::shards::reserve(_system_events, 32); - ice::array::reserve(_input_events._events, 512); + _input_events._events.reserve(512); SDL_InitSubSystem(SDL_INIT_EVENTS); diff --git a/source/code/platforms/platform_win32/private/win32_sdl2_platform.hxx b/source/code/platforms/platform_win32/private/win32_sdl2_platform.hxx index 8531a006..d4598da8 100644 --- a/source/code/platforms/platform_win32/private/win32_sdl2_platform.hxx +++ b/source/code/platforms/platform_win32/private/win32_sdl2_platform.hxx @@ -26,7 +26,7 @@ namespace ice::platform::win32::sdl2 auto refresh_events() noexcept -> ice::Result override; auto system_events() noexcept -> ice::ShardContainer const& override { return _system_events; } - auto input_events() noexcept -> ice::Span override { return ice::array::slice(_input_events._events); } + auto input_events() noexcept -> ice::Span override { return _input_events._events; } auto allocator() noexcept -> ice::Allocator& { return _alloc.backing_allocator(); } diff --git a/source/code/platforms/platform_win32/private/win32_sdl2_platform_render_surface.cxx b/source/code/platforms/platform_win32/private/win32_sdl2_platform_render_surface.cxx index b8798365..ed1140de 100644 --- a/source/code/platforms/platform_win32/private/win32_sdl2_platform_render_surface.cxx +++ b/source/code/platforms/platform_win32/private/win32_sdl2_platform_render_surface.cxx @@ -1,9 +1,8 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "win32_sdl2_platform_render_surface.hxx" #include -#include #include #include @@ -46,7 +45,7 @@ namespace ice::platform::win32::sdl2 using ice::render::RenderDriverAPI; ice::i32 creation_flags = SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE; ice::StaticString<64> window_title{ surface_params.window_title }; - if (ice::string::empty(window_title)) + if (window_title.is_empty()) { if (surface_params.driver == RenderDriverAPI::Vulkan) { @@ -61,7 +60,7 @@ namespace ice::platform::win32::sdl2 } _window = SDL_CreateWindow( - ice::string::data(window_title), + window_title.data(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, surface_params.dimensions.x, diff --git a/source/code/platforms/platform_win32/private/win32_sdl2_utils.cxx b/source/code/platforms/platform_win32/private/win32_sdl2_utils.cxx index 6874a6e3..10637a02 100644 --- a/source/code/platforms/platform_win32/private/win32_sdl2_utils.cxx +++ b/source/code/platforms/platform_win32/private/win32_sdl2_utils.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "win32_sdl2_utils.hxx" diff --git a/source/code/platforms/platform_win32/private/win32_storage.cxx b/source/code/platforms/platform_win32/private/win32_storage.cxx index ee064c63..914ee54d 100644 --- a/source/code/platforms/platform_win32/private/win32_storage.cxx +++ b/source/code/platforms/platform_win32/private/win32_storage.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "win32_storage.hxx" @@ -17,7 +17,7 @@ namespace ice::platform::win32 { - static constexpr ice::ucount Constant_AppNameReservedLength = 24; + static constexpr ice::u32 Constant_AppNameReservedLength = 24; namespace detail { @@ -27,15 +27,15 @@ namespace ice::platform::win32 PWSTR path; if (SHGetKnownFolderPath(known_path_guid, KF_FLAG_CREATE, NULL, &path) == S_OK) { - ice::ucount const path_len = ice::ucount(lstrlenW(path)); + ice::u32 const path_len = ice::u32(lstrlenW(path)); // Reserve additional space for the app name, so we don't need to resize buffers if that happens. - ice::string::reserve(out_path, path_len + Constant_AppNameReservedLength); - ice::wide_to_utf8_append({ path, ice::ucount(lstrlenW(path)) }, out_path); - ice::string::push_back(out_path, '\\'); - if (ice::string::any(appname)) + out_path.reserve(path_len + Constant_AppNameReservedLength); + ice::wide_to_utf8_append({ path, ice::u32(lstrlenW(path)) }, out_path); + out_path.push_back('\\'); + if (appname.not_empty()) { - ice::string::push_back(out_path, appname); - ice::string::push_back(out_path, '\\'); + out_path.push_back(appname); + out_path.push_back('\\'); } ice::path::normalize(out_path); CoTaskMemFree(path); @@ -46,9 +46,9 @@ namespace ice::platform::win32 { ice::StackAllocator<512_B> temp_alloc; ice::HeapString temp_paths{ temp_alloc }; - ice::string::reserve(temp_paths, 256); + temp_paths.reserve(256); ice::utf8_to_wide_append(path, temp_paths); - return CreateDirectoryW(ice::string::begin(temp_paths), NULL); + return CreateDirectoryW(temp_paths.begin(), NULL); } } // namespace detail @@ -104,11 +104,11 @@ namespace ice::platform::win32 void win32::Win32Storage::reload_paths(ice::String appname) noexcept { - ice::string::clear(_save_location); - ice::string::clear(_cache_location); - ice::string::clear(_temp_location); - ice::string::clear(_pictures_location); - ice::string::clear(_other_location); + _save_location.clear(); + _cache_location.clear(); + _temp_location.clear(); + _pictures_location.clear(); + _other_location.clear(); detail::get_known_path(_save_location, FOLDERID_SavedGames, appname); detail::get_known_path(_cache_location, FOLDERID_LocalAppData, appname); @@ -123,7 +123,7 @@ namespace ice::platform::win32 WCHAR tempbuff[256]; // GetTempPathW already returns a path ending with a slash character. DWORD const len = GetTempPathW(256, tempbuff); - ice::wide_to_utf8_append({ tempbuff, ice::ucount(len) }, _temp_location); + ice::wide_to_utf8_append({ tempbuff, ice::u32(len) }, _temp_location); ice::path::normalize(_temp_location); } diff --git a/source/code/platforms/platform_win32/private/win32_storage.hxx b/source/code/platforms/platform_win32/private/win32_storage.hxx index b87737f8..03c40a50 100644 --- a/source/code/platforms/platform_win32/private/win32_storage.hxx +++ b/source/code/platforms/platform_win32/private/win32_storage.hxx @@ -1,9 +1,9 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include #if ISP_WINDOWS diff --git a/source/code/platforms/platform_win32/private/win32_threads.cxx b/source/code/platforms/platform_win32/private/win32_threads.cxx index 5ba5e38d..02793fcb 100644 --- a/source/code/platforms/platform_win32/private/win32_threads.cxx +++ b/source/code/platforms/platform_win32/private/win32_threads.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "win32_threads.hxx" @@ -9,7 +9,7 @@ namespace ice::platform::win32 { - auto get_num_cores(ice::Allocator& alloc) noexcept -> ice::ucount + auto get_num_cores(ice::Allocator& alloc) noexcept -> ice::u32 { DWORD byte_size = 0; GetLogicalProcessorInformationEx(RelationProcessorCore, nullptr, &byte_size); @@ -24,7 +24,7 @@ namespace ice::platform::win32 ); ICE_ASSERT_CORE(result == TRUE); - ice::ucount num_procs = 0; + ice::u32 num_procs = 0; ice::usize byte_size_processed = 0_B; for (; byte_size_processed.value < byte_size;) { @@ -68,8 +68,8 @@ namespace ice::platform::win32 , _threads{ } , _aioport{ ice::native_aio::aio_open(alloc, { .worker_limit = 2, .debug_name = "ice.aio-port" }) } { - ice::ucount const hw_concurrency = ice::min(get_num_cores(alloc), 8u); - ice::ucount tp_size = ice::max(hw_concurrency, 2u); // min 2 task threads + ice::u32 const hw_concurrency = ice::min(get_num_cores(alloc), 8u); + ice::u32 tp_size = ice::max(hw_concurrency, 2u); // min 2 task threads for (ice::Shard const option : params) { diff --git a/source/code/systems/asset_system/private/asset_data.hxx b/source/code/systems/asset_system/private/asset_data.hxx index 3f657706..d6dfa65f 100644 --- a/source/code/systems/asset_system/private/asset_data.hxx +++ b/source/code/systems/asset_system/private/asset_data.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/systems/asset_system/private/asset_module.cxx b/source/code/systems/asset_system/private/asset_module.cxx index c3d18f91..5dae0d81 100644 --- a/source/code/systems/asset_system/private/asset_module.cxx +++ b/source/code/systems/asset_system/private/asset_module.cxx @@ -3,7 +3,7 @@ #include #include -#include +#include #include namespace ice diff --git a/source/code/systems/asset_system/private/asset_request_awaitable.cxx b/source/code/systems/asset_system/private/asset_request_awaitable.cxx index accb49c9..f1355731 100644 --- a/source/code/systems/asset_system/private/asset_request_awaitable.cxx +++ b/source/code/systems/asset_system/private/asset_request_awaitable.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "asset_request_awaitable.hxx" diff --git a/source/code/systems/asset_system/private/asset_shelve.cxx b/source/code/systems/asset_system/private/asset_shelve.cxx index f955deb3..7cdc60eb 100644 --- a/source/code/systems/asset_system/private/asset_shelve.cxx +++ b/source/code/systems/asset_system/private/asset_shelve.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "asset_shelve.hxx" @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include namespace ice diff --git a/source/code/systems/asset_system/private/asset_shelve_devui.cxx b/source/code/systems/asset_system/private/asset_shelve_devui.cxx index 351fe2e2..ae6c620d 100644 --- a/source/code/systems/asset_system/private/asset_shelve_devui.cxx +++ b/source/code/systems/asset_system/private/asset_shelve_devui.cxx @@ -1,12 +1,11 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "asset_shelve_devui.hxx" #include #include -#include -#undef assert +#include namespace ice { @@ -46,7 +45,7 @@ namespace ice { ImGui::TableNextRow(); ImGui::TableNextColumn(); - ImGui::TextUnformatted(ice::string::begin(entry->debug_name), ice::string::end(entry->debug_name)); + ImGui::TextUnformatted(entry->debug_name.cbegin(), entry->debug_name.cend()); if (ImGui::TableNextColumn()) // Status { @@ -54,16 +53,13 @@ namespace ice "Invalid", "Unknown", "Exists", "Raw", "Baked", "Loaded", "Runtime" }; - ImGui::TextUnformatted( - ice::string::begin(Constant_StateNames[static_cast(entry->state())]), - ice::string::end(Constant_StateNames[static_cast(entry->state())]) - ); + ImGui::TextUnformatted(Constant_StateNames[static_cast(entry->state())]); } if (ImGui::TableNextColumn()) // Resource { ice::ResourceHandle const handle = ice::asset_data_resource(entry->_data); ice::String const origin = handle != nullptr ? handle->origin() : "???"; - ImGui::TextUnformatted(ice::string::begin(origin), ice::string::end(origin)); + ImGui::TextUnformatted(origin); } } diff --git a/source/code/systems/asset_system/private/asset_storage.cxx b/source/code/systems/asset_system/private/asset_storage.cxx index 0ebb7900..cc0a34b0 100644 --- a/source/code/systems/asset_system/private/asset_storage.cxx +++ b/source/code/systems/asset_system/private/asset_storage.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "asset_storage.hxx" @@ -45,13 +45,13 @@ namespace ice ice::ResourceHandle resource; ice::u32 ext_idx = 0; - ice::u32 const ext_count = ice::count(definition.resource_extensions); - ice::u32 const temp_name_len = ice::size(temp_name); + ice::u32 const ext_count = definition.resource_extensions.size().u32(); + ice::u32 const temp_name_len = temp_name.size().u32(); while (resource == nullptr && ext_idx < ext_count) { ice::String const extension = definition.resource_extensions[ext_idx++]; - ice::string::resize(temp_name, temp_name_len); - ice::string::push_back(temp_name, extension); + temp_name.resize(temp_name_len); + temp_name.push_back(extension); ice::URI const uri{ Scheme_URN, temp_name }; resource = resource_tracker.find_resource(uri, ice::ResourceFlags::None); @@ -91,13 +91,13 @@ namespace ice } // If empty we add our own handle to the list - if (ice::array::empty(sources)) + if (sources.is_empty()) { - ice::array::push_back(sources, resource); + sources.push_back(resource); } ice::Array> tasks{ alloc }; - ice::array::reserve(tasks, ice::array::count(sources)); + tasks.reserve(sources.size()); auto fn_validate = [&ctx]( ice::ResourceCompiler const& compiler, @@ -116,12 +116,12 @@ namespace ice std::atomic_bool all_sources_valid = true; for (ice::ResourceHandle const& source : sources) { - ice::array::push_back(tasks, fn_validate(compiler, source, resource_tracker, all_sources_valid)); + tasks.push_back(fn_validate(compiler, source, resource_tracker, all_sources_valid)); } co_await ice::await_tasks(tasks); - ice::array::clear(tasks); + tasks.clear(); // Validation failed if (all_sources_valid == false) @@ -130,7 +130,7 @@ namespace ice } ice::Array compiled_sources{ alloc }; - ice::array::resize(compiled_sources, ice::array::count(sources)); + compiled_sources.resize(sources.size()); auto fn_compile = [&ctx]( ice::ResourceCompiler const& compiler, @@ -156,8 +156,7 @@ namespace ice ice::u32 source_idx = 0; for (ice::ResourceHandle const& source : sources) { - ice::array::push_back( - tasks, + tasks.push_back( fn_compile( compiler, source, @@ -241,7 +240,7 @@ namespace ice , _devui_widget{ } { ice::Span categories = _asset_archive->categories(); - ice::hashmap::reserve(_asset_shelves, ice::count(categories)); + ice::hashmap::reserve(_asset_shelves, categories.size().u32()); ice::Array> shelves{ _allocator }; for (ice::AssetCategory_Arg category : categories) @@ -256,7 +255,7 @@ namespace ice if constexpr (ice::build::is_debug || ice::build::is_develop) { - ice::array::push_back(shelves, ice::make_unique(_allocator, *shelve)); + shelves.push_back(ice::make_unique(_allocator, *shelve)); } } diff --git a/source/code/systems/asset_system/private/asset_storage.hxx b/source/code/systems/asset_system/private/asset_storage.hxx index 74020572..ad039ef3 100644 --- a/source/code/systems/asset_system/private/asset_storage.hxx +++ b/source/code/systems/asset_system/private/asset_storage.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/source/code/systems/asset_system/private/asset_storage_devui.cxx b/source/code/systems/asset_system/private/asset_storage_devui.cxx index 3739b598..d7c98bf1 100644 --- a/source/code/systems/asset_system/private/asset_storage_devui.cxx +++ b/source/code/systems/asset_system/private/asset_storage_devui.cxx @@ -1,13 +1,11 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "asset_entry.hxx" #include "asset_storage_devui.hxx" #include #include - -#include -#undef assert +#include namespace ice { @@ -73,14 +71,14 @@ namespace ice { ImGui::TableNextRow(); ImGui::TableNextColumn(); - ImGui::TextUnformatted(ice::string::begin(category.name), ice::string::end(category.name)); + ImGui::TextUnformatted(category.name); ice::AssetCategoryDefinition const& def = _storage._asset_archive->find_definition(category); if (ImGui::TableNextColumn()) { for (ice::String ext : def.resource_extensions) { - ImGui::TextUnformatted(ice::string::begin(ext), ice::string::end(ext)); ImGui::SameLine(); + ImGui::TextUnformatted(ext); ImGui::SameLine(); } } diff --git a/source/code/systems/asset_system/private/asset_type_archive.cxx b/source/code/systems/asset_system/private/asset_type_archive.cxx index 4705d643..ed0a06b6 100644 --- a/source/code/systems/asset_system/private/asset_type_archive.cxx +++ b/source/code/systems/asset_system/private/asset_type_archive.cxx @@ -103,7 +103,7 @@ namespace ice } } - ice::array::push_back(_types, category); + _types.push_back(category); ice::hashmap::set( _definitions, type_hash, diff --git a/source/code/systems/asset_system/public/ice/asset_category.hxx b/source/code/systems/asset_system/public/ice/asset_category.hxx index fb028648..56cf7998 100644 --- a/source/code/systems/asset_system/public/ice/asset_category.hxx +++ b/source/code/systems/asset_system/public/ice/asset_category.hxx @@ -1,10 +1,10 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include -#include +#include #include #include diff --git a/source/code/systems/asset_system/public/ice/asset_category_archive.hxx b/source/code/systems/asset_system/public/ice/asset_category_archive.hxx index 79d614ea..be5f18d8 100644 --- a/source/code/systems/asset_system/public/ice/asset_category_archive.hxx +++ b/source/code/systems/asset_system/public/ice/asset_category_archive.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -12,7 +12,7 @@ namespace ice struct AssetCategoryDefinition { - constexpr auto valid() const noexcept { return ice::span::any(resource_extensions); } + constexpr auto valid() const noexcept { return resource_extensions.not_empty(); } ice::String name; ice::Span asset_params; diff --git a/source/code/systems/font_system/private/font_utils.cxx b/source/code/systems/font_system/private/font_utils.cxx index 32ba6db2..bfdc8350 100644 --- a/source/code/systems/font_system/private/font_utils.cxx +++ b/source/code/systems/font_system/private/font_utils.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -74,8 +74,8 @@ namespace ice ice::u32& out_glyph_count ) noexcept -> ice::vec2f { - char const* text_it = ice::string::begin(text); - char const* const text_end = ice::string::end(text); + char const* text_it = text.begin(); + char const* const text_end = text.end(); ice::f32 last_advance_offset = 0.f; diff --git a/source/code/systems/font_system/public/ice/font_utils.hxx b/source/code/systems/font_system/public/ice/font_utils.hxx index ad40edb4..cd4b902f 100644 --- a/source/code/systems/font_system/public/ice/font_utils.hxx +++ b/source/code/systems/font_system/public/ice/font_utils.hxx @@ -1,9 +1,9 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include namespace ice { diff --git a/source/code/systems/input_action_system/private/input_action_layer.cxx b/source/code/systems/input_action_system/private/input_action_layer.cxx index 4793db15..c09169d0 100644 --- a/source/code/systems/input_action_system/private/input_action_layer.cxx +++ b/source/code/systems/input_action_system/private/input_action_layer.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -35,10 +35,15 @@ namespace ice }; template - auto load_field_from_data(ice::Span& out_span, ice::Data data, ice::usize offset, ice::ucount count) noexcept + auto load_field_from_data( + ice::Span& out_span, + ice::Data data, + ice::usize offset, + ice::ncount count + ) noexcept -> ice::usize { - out_span = ice::span::from_data(data, count, offset); - return ice::span::data_view(out_span).size; + ice::data::read_span(ice::ptr_add(data, offset), count, out_span); + return out_span.size(); } auto load_from_data(ice::Data data) noexcept -> ice::Expected @@ -61,12 +66,12 @@ namespace ice offset += load_field_from_data(result.constants, data, offset, header.count_constants); ICE_ASSERT_CORE(offset == ice::usize{ header.offset_strings }); - result.strings = ice::string::from_data( + result.strings = ice::string_from_data( data, - ice::usize{ header.offset_strings }, - ice::ucount( data.size.value - header.offset_strings ) + header.offset_strings, + data.size.value - header.offset_strings ); - result.name = ice::string::substr(result.strings, 0, header.size_name); + result.name = result.strings.substr(0, header.size_name); return result; } @@ -108,7 +113,7 @@ namespace ice auto source_name(ice::InputActionSourceInputInfo const& source) const noexcept -> ice::String override { - return ice::string::substr(_strings, source.name); + return _strings.substr(source.name); } auto actions() const noexcept -> ice::Span override @@ -118,24 +123,24 @@ namespace ice auto action_name(ice::InputActionInfo const& action) const noexcept -> ice::String override { - return ice::string::substr(_strings, action.name); + return _strings.substr(action.name); } - auto load_constants(ice::Span constants_span) const noexcept -> ice::ucount override + auto load_constants(ice::Span constants_span) const noexcept -> ice::u32 override { - ICE_ASSERT_CORE(ice::count(constants_span) >= Constant_CountInputActionConstants); + ICE_ASSERT_CORE(constants_span.size() >= Constant_CountInputActionConstants); for (ice::InputActionConstantInfo const constant : _constants) { ice::u32 const idx = ice::u32(constant.identifier); constants_span[idx] = _constant_values[constant.offset]; } - return ice::count(_constants); + return _constants.size().u32(); } auto process_inputs( ice::Span input_events, ice::Span source_values - ) const noexcept -> ice::ucount override + ) const noexcept -> ice::u32 override { IPT_ZONE_SCOPED; @@ -145,8 +150,8 @@ namespace ice return ev.identifier == id; }; - ice::ucount count_processed = 0; - ice::ucount const count_events = ice::count(input_events); + ice::u32 count_processed = 0; + ice::u32 const count_events = input_events.size().u32(); // Reset the temporary events. for (ice::InputActionSourceInputInfo const& src : _sources) @@ -165,7 +170,7 @@ namespace ice ice::InputActionSource* const values = source_values[src.storage_offset]; ice::u32 const count_values = 1 + ice::u32(src.type == InputActionSourceType::Axis2d); - ice::ucount event_index = 0; + ice::u32 event_index = 0; if (ice::search(input_events, src.input, comp_event_id, event_index) == false) { // Reset any event that was a key-release event previously @@ -253,7 +258,7 @@ namespace ice for (ice::InputActionInfo const& action : _actions) { - ice::String const action_name = ice::string::substr(_strings, action.name); + ice::String const action_name = _strings.substr(action.name); ice::InputActionRuntime* const runtime = ice::hashmap::try_get(actions, ice::hash(action_name)); // TODO: Check if we need this @@ -263,7 +268,7 @@ namespace ice } bool series_success = false; - ice::Span const conditions = ice::span::subspan(_conditions, action.conditions); + ice::Span const conditions = _conditions.subspan(action.conditions); for (ice::InputActionConditionData const& cond : conditions) { bool cond_result = false; @@ -273,7 +278,7 @@ namespace ice if (cond.source.source_index != InputActionIndex::SelfIndex) { ice::InputActionInfo const checked_action_info = _actions[cond.source.source_index]; - ice::String const checked_action_name = ice::string::substr(_strings, checked_action_info.name); + ice::String const checked_action_name = _strings.substr(checked_action_info.name); checked_action = ice::hashmap::try_get(actions, ice::hash(checked_action_name)); } ICE_ASSERT_CORE(checked_action != nullptr); @@ -310,7 +315,7 @@ namespace ice if (ice::has_all(cond.flags, RunSteps) && check_success) { - ice::Span const steps = ice::span::subspan(_steps, cond.steps); + ice::Span const steps = _steps.subspan(cond.steps); for (ice::InputActionStepData const& step : steps) { if (step.id < InputActionStep::Set) @@ -373,7 +378,7 @@ namespace ice for (ice::InputActionInfo const& action : _actions) { - ice::String const action_name = ice::string::substr(_strings, action.name); + ice::String const action_name = _strings.substr(action.name); ice::InputActionRuntime* const runtime = ice::hashmap::try_get(actions, ice::hash(action_name)); // Handles 'Toggle'. We only activate of the first press, which is `state == 1`. @@ -409,7 +414,7 @@ namespace ice // Update the final value and run modifiers over it. runtime->value = { runtime->raw_value.x, runtime->raw_value.y }; - ice::Span const mods = ice::span::subspan(_modifiers, action.mods); + ice::Span const mods = _modifiers.subspan(action.mods); for (ice::InputActionModifierData const& mod : mods) { executor.execute_modifier(mod.id, runtime->value.v[0][mod.axis], mod.param); @@ -481,7 +486,7 @@ namespace ice void on_layer_parsed(ice::UniquePtr layer) noexcept override { - ice::array::push_back(results, ice::move(layer)); + results.push_back(ice::move(layer)); } } parser{ alloc }; diff --git a/source/code/systems/input_action_system/private/input_action_layer_builder.cxx b/source/code/systems/input_action_system/private/input_action_layer_builder.cxx index 254f57e4..bd53635a 100644 --- a/source/code/systems/input_action_system/private/input_action_layer_builder.cxx +++ b/source/code/systems/input_action_system/private/input_action_layer_builder.cxx @@ -1,11 +1,11 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "input_action_internal_types.hxx" #include #include #include -#include +#include #include namespace ice @@ -17,7 +17,7 @@ namespace ice auto parse_source(ice::String source) noexcept -> std::tuple { ice::u8 read_from = 0; - ice::ucount source_size = ice::size(source); + ice::ncount source_size = source.size(); // We want to parse the following cases: (.[xyz]) if (source_size > 1 && source[source_size - 2] == '.') { @@ -25,7 +25,7 @@ namespace ice read_from = source[source_size + 1] - 'x'; ICE_ASSERT_CORE(read_from >= 0 && read_from < 3); } - return { ice::string::substr(source, 0, source_size), read_from }; + return { source.substr(0, source_size), read_from }; } } // namespace detail @@ -125,25 +125,22 @@ namespace ice : allocator{ alloc } , conditions{ alloc } { - ice::array::reserve(conditions, 4); + conditions.reserve(4); } void add_step(ActionBuilderStep&& step) noexcept { - ice::array::push_back( - ice::array::back(conditions).steps, - ice::move(step) - ); + conditions.last().steps.push_back(ice::move(step)); } void add_condition(ActionBuilderCondition&& condition) noexcept { - ice::array::push_back(conditions, ice::move(condition)); + conditions.push_back(ice::move(condition)); } void finalize() noexcept { - ActionBuilderCondition& final_condition = ice::array::back(conditions); + ActionBuilderCondition& final_condition = conditions.last(); // Ensure this series is finished after this condition. final_condition.flags |= InputActionConditionFlags::SeriesFinish; @@ -168,8 +165,8 @@ namespace ice , cond_series{ alloc } , modifiers{ alloc } { - ice::array::reserve(cond_series, 3); - ice::array::reserve(modifiers, 2); + cond_series.reserve(3); + modifiers.reserve(2); } ice::Allocator& allocator; @@ -181,8 +178,8 @@ namespace ice auto add_condition_series() noexcept -> InputActionBuilder::ConditionSeries { - ice::array::push_back(cond_series, Internal{ allocator }); - Internal* const series_ptr = ice::addressof(ice::array::back(cond_series)); + cond_series.push_back(Internal{ allocator }); + Internal* const series_ptr = ice::addressof(cond_series.last()); return { series_ptr }; } @@ -212,7 +209,7 @@ namespace ice { ice::hashmap::reserve(_sources, 16); ice::hashmap::reserve(_actions, 10); - ice::array::push_back(_constants, { InputActionConstant::Nil, 0.0f }); + _constants.push_back({ InputActionConstant::Nil, 0.0f }); } ~SimpleInputActionLayerBuilder() @@ -233,7 +230,7 @@ namespace ice ice::f32 value ) noexcept override { - ice::array::push_back(_constants, { constant, value }); + _constants.push_back({ constant, value }); } auto define_source( @@ -266,17 +263,17 @@ namespace ice ice::Array final_actions{ _allocator }; // Insert layer name as the first string - ice::string::push_back(strings, _name); - ice::string::push_back(strings, '\0'); + strings.push_back(_name); + strings.push_back('\0'); // Prepare data of all sources for (Internal const& source : _sources) { if (ice::hashmap::empty(source.events)) { - ice::array::push_back(final_sources, + final_sources.push_back( InputActionSourceInputInfo{ - .name = { ice::u16(ice::size(strings)), ice::u16(ice::size(source.name)) }, + .name = { strings.size().u16(), source.name.size().u16() }, .input = ice::input::InputID::Invalid, .type = source.type, .storage_offset = count_storage_values, @@ -287,9 +284,9 @@ namespace ice for (ice::input::InputID input_event : source.events) { - ice::array::push_back(final_sources, + final_sources.push_back( InputActionSourceInputInfo{ - .name = { ice::u16(ice::size(strings)), ice::u16(ice::size(source.name)) }, + .name = { strings.size().u16(), source.name.size().u16() }, .input = input_event, .type = source.type, .storage_offset = count_storage_values, @@ -297,7 +294,7 @@ namespace ice } ); } - ice::string::push_back(strings, source.name); + strings.push_back(source.name); // ice::string::push_back(strings, '\0'); switch(source.type) @@ -314,42 +311,42 @@ namespace ice auto find_source_storage_index = [&strings, &final_sources](ice::String source_name) noexcept -> ice::u16 { - ice::ucount idx_found = ice::ucount_max; + ice::u32 idx_found = ice::u32_max; bool const found = ice::search( - ice::array::slice(final_sources), + final_sources.tailspan(0), source_name, [&strings](ice::InputActionSourceInputInfo const& source, ice::String expected) noexcept { - ice::String const source_name = ice::string::substr( - strings, source.name.offset, source.name.size + ice::String const source_name = strings.substr( + source.name.offset, source.name.size ); return expected == source_name; }, idx_found ); - ICE_ASSERT_CORE(found && idx_found < ice::array::count(final_sources)); + ICE_ASSERT_CORE(found && idx_found < final_sources.size()); ice::u16 const source_storage_idx = final_sources[idx_found].storage_offset; return source_storage_idx; }; auto find_action_storage_index = [&strings, &final_actions](ice::String source_name) noexcept -> ice::u16 { - ice::ucount idx_found = ice::ucount_max; + ice::u32 idx_found = ice::u32_max; bool const found = ice::search( - ice::array::slice(final_actions), + final_actions.tailspan(0), source_name, [&strings](ice::InputActionInfo const& action, ice::String expected) noexcept { - ice::String const source_name = ice::string::substr( - strings, action.name.offset, action.name.size + ice::String const source_name = strings.substr( + action.name.offset, action.name.size ); return expected == source_name; }, idx_found ); - ICE_ASSERT_CORE(found && idx_found < ice::array::count(final_actions)); + ICE_ASSERT_CORE(found && idx_found < final_actions.size()); return ice::u16(idx_found); }; @@ -374,7 +371,7 @@ namespace ice { if (step.step < InputActionStep::Set) { - ice::array::push_back(final_steps, + final_steps.push_back( InputActionStepData{ .source = { 0, 0 }, .id = step.step, @@ -384,7 +381,7 @@ namespace ice } else { - ice::array::push_back(final_steps, + final_steps.push_back( InputActionStepData{ .source = { .source_index = find_source_storage_index(step.source), @@ -404,7 +401,7 @@ namespace ice if (condition.from_action) { // If we are empty, it's a "self reference" - if (ice::string::any(condition.source)) + if (condition.source.not_empty()) { source_index.source_index = find_action_storage_index(condition.source); source_index.source_axis = condition.axis; @@ -422,7 +419,7 @@ namespace ice source_index.source_axis = condition.axis; } - ice::array::push_back(final_conditions, + final_conditions.push_back( InputActionConditionData{ .source = source_index, .id = condition.condition, @@ -437,12 +434,12 @@ namespace ice } } // for (ConditionSeries& series : ...) - modifier_count = ice::u8(ice::count(action.modifiers)); - ice::array::push_back(final_modifiers, action.modifiers); + modifier_count = action.modifiers.size().u8(); + final_modifiers.push_back(action.modifiers); - ice::array::push_back(final_actions, + final_actions.push_back( InputActionInfo{ - .name = { ice::u16(ice::size(strings)), ice::u16(ice::size(action.name)) }, + .name = { strings.size().u16(), action.name.size().u16() }, .type = action.type, .behavior = action.behavior, .conditions = { condition_offset, condition_count }, @@ -450,7 +447,7 @@ namespace ice } ); - ice::string::push_back(strings, action.name); + strings.push_back(action.name); modifier_offset += modifier_count; condition_offset += ice::exchange(condition_count, ice::u16_0); @@ -460,44 +457,44 @@ namespace ice ice::Array final_constants{ alloc }; for (auto [constant, value] : _constants) { - ice::u8 const offset = (ice::u8) ice::count(final_constant_values); - ice::array::push_back(final_constants, { .identifier = constant, .offset = offset }); - ice::array::push_back(final_constant_values, value); + ice::u8 const offset = final_constant_values.size().u8(); + final_constants.push_back({ .identifier = constant, .offset = offset }); + final_constant_values.push_back(value); } ice::InputActionLayerInfoHeader final_info{ - .size_name = ice::u8(ice::size(_name)), - .count_constants = ice::u8(ice::count(final_constants)), - .count_sources = ice::u16(ice::count(final_sources)), - .count_actions = ice::u16(ice::count(final_actions)), - .count_conditions = ice::u16(ice::count(final_conditions)), - .count_steps = ice::u16(ice::count(final_steps)), - .count_modifiers = ice::u16(ice::count(final_modifiers)), + .size_name = _name.size().u8(), + .count_constants = final_constants.size().u8(), + .count_sources = final_sources.size().u16(), + .count_actions = final_actions.size().u16(), + .count_conditions = final_conditions.size().u16(), + .count_steps = final_steps.size().u16(), + .count_modifiers = final_modifiers.size().u16(), .offset_strings = 0, }; // Allocate memory and copy all data ice::meminfo minfo_layer = ice::meminfo_of; - ice::usize const offset_sources = minfo_layer += ice::array::meminfo(final_sources); - ice::usize const offset_actions = minfo_layer += ice::array::meminfo(final_actions); - ice::usize const offset_conditions = minfo_layer += ice::array::meminfo(final_conditions); - ice::usize const offset_steps = minfo_layer += ice::array::meminfo(final_steps); - ice::usize const offset_modifiers = minfo_layer += ice::array::meminfo(final_modifiers); - ice::usize const offset_constant_values = minfo_layer += ice::meminfo_of * ice::count(final_constant_values); - ice::usize const offset_constants = minfo_layer += ice::array::meminfo(final_constants); - ice::usize const offset_strings = minfo_layer += ice::string::meminfo(ice::String{strings}); + ice::usize const offset_sources = minfo_layer += final_sources.meminfo(); + ice::usize const offset_actions = minfo_layer += final_actions.meminfo(); + ice::usize const offset_conditions = minfo_layer += final_conditions.meminfo(); + ice::usize const offset_steps = minfo_layer += final_steps.meminfo(); + ice::usize const offset_modifiers = minfo_layer += final_modifiers.meminfo(); + ice::usize const offset_constant_values = minfo_layer += final_constant_values.meminfo(); + ice::usize const offset_constants = minfo_layer += final_constants.meminfo(); + ice::usize const offset_strings = minfo_layer += strings.meminfo(); final_info.offset_strings = ice::u32(offset_strings.value); ice::Memory const final_memory = alloc.allocate(minfo_layer); ice::memcpy(final_memory, ice::data_view(final_info)); - ice::memcpy(ice::ptr_add(final_memory, offset_sources), ice::array::data_view(final_sources)); - ice::memcpy(ice::ptr_add(final_memory, offset_actions), ice::array::data_view(final_actions)); - ice::memcpy(ice::ptr_add(final_memory, offset_conditions), ice::array::data_view(final_conditions)); - ice::memcpy(ice::ptr_add(final_memory, offset_steps), ice::array::data_view(final_steps)); - ice::memcpy(ice::ptr_add(final_memory, offset_modifiers), ice::array::data_view(final_modifiers)); - ice::memcpy(ice::ptr_add(final_memory, offset_constant_values), ice::array::data_view(final_constant_values)); - ice::memcpy(ice::ptr_add(final_memory, offset_constants), ice::array::data_view(final_constants)); - ice::memcpy(ice::ptr_add(final_memory, offset_strings), ice::string::data_view(strings)); + ice::memcpy(ice::ptr_add(final_memory, offset_sources), final_sources.data_view()); + ice::memcpy(ice::ptr_add(final_memory, offset_actions), final_actions.data_view()); + ice::memcpy(ice::ptr_add(final_memory, offset_conditions), final_conditions.data_view()); + ice::memcpy(ice::ptr_add(final_memory, offset_steps), final_steps.data_view()); + ice::memcpy(ice::ptr_add(final_memory, offset_modifiers), final_modifiers.data_view()); + ice::memcpy(ice::ptr_add(final_memory, offset_constant_values), final_constant_values.data_view()); + ice::memcpy(ice::ptr_add(final_memory, offset_constants), final_constants.data_view()); + ice::memcpy(ice::ptr_add(final_memory, offset_strings), strings.data_view()); return ice::create_input_action_layer(alloc, final_memory); } @@ -592,11 +589,11 @@ namespace ice { if (can_finalize_condition_checks) { - ice::array::back(internal().conditions).flags |= InputActionConditionFlags::Final; + internal().conditions.last().flags |= InputActionConditionFlags::Final; } else { - ice::array::back(internal().conditions).flags |= InputActionConditionFlags::SeriesFinish; + internal().conditions.last().flags |= InputActionConditionFlags::SeriesFinish; } } @@ -673,18 +670,18 @@ namespace ice ice::String target_axis /*= ".x"*/ ) noexcept -> Action& { - ICE_ASSERT_CORE(ice::size(target_axis) >= 2 && target_axis[0] == '.'); - if (ice::size(target_axis) < 2 || target_axis[0] != '.') + ICE_ASSERT_CORE(target_axis.size() >= 2 && target_axis[0] == '.'); + if (target_axis.size() < 2 || target_axis[0] != '.') { return *this; } - for (char axis_component : ice::string::substr(target_axis, 1, 3)) + for (char axis_component : target_axis.substr(1, 3)) { ICE_ASSERT_CORE(axis_component >= 'x' && axis_component <= 'z'); // .xyz ice::u8 const axis = axis_component - 'x'; - ice::array::push_back(internal().modifiers, { .id = modifier, .axis = axis, .param = param }); + internal().modifiers.push_back({ .id = modifier, .axis = axis, .param = param }); } return *this; } diff --git a/source/code/systems/input_action_system/private/input_action_script.cxx b/source/code/systems/input_action_system/private/input_action_script.cxx index a546ee68..4f911bb7 100644 --- a/source/code/systems/input_action_system/private/input_action_script.cxx +++ b/source/code/systems/input_action_system/private/input_action_script.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "input_action_script.hxx" @@ -68,9 +68,9 @@ namespace ice::asl .location = location }; - ice::ucount idx; + ice::u32 idx; ice::asl::TokenDefinition const needle{ .value = word.value }; - if (ice::binary_search(ice::span::from_std_const(Constant_TokenDefinitions), needle, idx)) + if (ice::binary_search(ice::make_span(Constant_TokenDefinitions), needle, idx)) { result.type = Constant_TokenDefinitions[idx].type; word = processor.next(); diff --git a/source/code/systems/input_action_system/private/input_action_stack.cxx b/source/code/systems/input_action_system/private/input_action_stack.cxx index dd15f768..fb613f1e 100644 --- a/source/code/systems/input_action_system/private/input_action_stack.cxx +++ b/source/code/systems/input_action_system/private/input_action_stack.cxx @@ -1,14 +1,13 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include #include #include #include -#include -#include +#include #include -#include +#include #include #include #include @@ -38,7 +37,7 @@ namespace ice auto registered_layers( ice::Array& out_layers - ) const noexcept -> ice::ucount override; + ) const noexcept -> ice::u32 override; auto register_layer( ice::InputActionLayer const* layer @@ -47,7 +46,7 @@ namespace ice auto active_layers( ice::Array& out_layers - ) const noexcept -> ice::ucount override; + ) const noexcept -> ice::u32 override; void push_layer( ice::InputActionLayer const* layer @@ -135,13 +134,13 @@ namespace ice auto SimpleInputActionStack::registered_layers( ice::Array& out_layers - ) const noexcept -> ice::ucount + ) const noexcept -> ice::u32 { for (StackLayer const& layer : _layers) { - ice::array::push_back(out_layers, layer.layer); + out_layers.push_back(layer.layer); } - return ice::count(_layers); + return _layers.size().u32(); } auto SimpleInputActionStack::register_layer( @@ -154,23 +153,23 @@ namespace ice return E_NullPointer; } - ice::ucount layer_idx; + ice::u32 layer_idx; if (ice::search(ice::Span{ _layers }, layer, compare_layers, layer_idx)) { return S_LayerAlreadyRegistered; } - layer_idx = ice::count(_layers); + layer_idx = _layers.size().u32(); // We reserve enough space to store all actual indices for accessed layer sources. - ice::u32 const layer_sources_count = ice::count(layer->sources()); - ice::u32 const layer_sources_offset = ice::count(_layers_sources_indices); - ice::array::reserve(_layers_sources_indices, layer_sources_offset + layer_sources_count); + ice::ncount const layer_sources_count = layer->sources().size().u32(); + ice::ncount const layer_sources_offset = _layers_sources_indices.size(); + _layers_sources_indices.reserve(layer_sources_offset + layer_sources_count); // Go through each resource and set the indices ice::u64 prev_name_hash = 0; ice::Span sources = layer->sources(); - ice::ucount const count_sources = ice::count(sources); + ice::u32 const count_sources = sources.size().u32(); for (ice::u32 idx = 0; idx < count_sources; ++idx) { ice::InputActionSourceInputInfo const& source = sources[idx]; @@ -187,36 +186,36 @@ namespace ice values_index = ice::hashmap::try_get(_sources, source_name_hash)->index; // Stores the index for the source - ice::array::push_back(_layers_sources_indices, values_index); + _layers_sources_indices.push_back(values_index); if (source.type == InputActionSourceType::Axis2d) { // Stores the index for the source - ice::array::push_back(_layers_sources_indices, values_index); + _layers_sources_indices.push_back(values_index); } } } else { - values_index = ice::array::count(_sources_runtime_values); + values_index = _sources_runtime_values.size().u32(); - ice::array::push_back(_sources_runtime_values, InputActionSource{}); + _sources_runtime_values.push_back(InputActionSource{}); // If we have an Axis2d source, we need to actually push back two values for both axis if (source.type == InputActionSourceType::Axis2d) { - ice::array::push_back(_sources_runtime_values, InputActionSource{}); + _sources_runtime_values.push_back(InputActionSource{}); } // Save the index where we store the runtime value(s) ice::hashmap::set(_sources, source_name_hash, { values_index }); // Stores the index for the source - ice::array::push_back(_layers_sources_indices, values_index); + _layers_sources_indices.push_back(values_index); if (source.type == InputActionSourceType::Axis2d) { // Stores the index for the source - ice::array::push_back(_layers_sources_indices, values_index); + _layers_sources_indices.push_back(values_index); } } @@ -234,7 +233,7 @@ namespace ice // Create the final name with the prefix and store it so the pointer reimains valid. // #TODO: Consider using refs instead? ice::HeapString<> final_name = _idprefix; - ice::string::push_back(final_name, action_name); + final_name.push_back(action_name); ice::hashmap::set(_action_names, action_name_hash, ice::move(final_name)); ice::HeapString<> const* final_name_ptr = ice::hashmap::try_get(_action_names, action_name_hash); @@ -246,33 +245,32 @@ namespace ice } // Stores the layer along with a ref where it's indices for all sources are stored. - ice::array::push_back( - _layers, - StackLayer{ layer, { ice::u16(layer_sources_offset), ice::u16(ice::count(_layers_sources_indices) - layer_sources_offset) } } + _layers.push_back( + StackLayer{ layer, { layer_sources_offset.u16(), (_layers_sources_indices.size() - layer_sources_offset).u16() } } ); return S_Ok; } auto SimpleInputActionStack::active_layers( ice::Array& out_layers - ) const noexcept -> ice::ucount + ) const noexcept -> ice::u32 { - auto it = ice::array::rbegin(_layers_active); - auto const end = ice::array::rend(_layers_active); + auto it = _layers_active.rbegin(); + auto const end = _layers_active.rend(); while (it != end) { - ice::array::push_back(out_layers, _layers[it->index].layer); + out_layers.push_back(_layers[it->index].layer); it += 1; } - return ice::count(_layers_active); + return _layers_active.size().u32(); } void SimpleInputActionStack::push_layer( ice::InputActionLayer const* layer ) noexcept { - ice::ucount idx; + ice::u32 idx; if (ice::search(ice::Span{ _layers }, layer, compare_layers, idx) == false) { // #TODO: Create a proper error return value. @@ -280,38 +278,38 @@ namespace ice } // Check if we are already at the top of the stack. - if (ice::array::any(_layers_active) && ice::array::back(_layers_active).index == idx) + if (_layers_active.not_empty() && _layers_active.last().index == idx) { return; // #TODO: Implement success with info. } // Push back the new active layer. - ice::array::push_back(_layers_active, { idx }); + _layers_active.push_back({ idx }); } void SimpleInputActionStack::pop_layer( ice::InputActionLayer const* layer ) noexcept { - ice::ucount idx; + ice::u32 idx; if (ice::search(ice::Span{ _layers }, layer, compare_layers, idx)) { // We just cut anything below this index, because we want to pop everything up to this layer - ice::array::resize(_layers, idx); - ice::array::pop_back(_layers); // And pop the item itself + _layers.resize(idx); + _layers.pop_back(); // And pop the item itself } } auto SimpleInputActionStack::action(ice::String action_name) const noexcept -> ice::Expected { ice::InputActionRuntime const* action = ice::hashmap::try_get(_actions, ice::hash(action_name)); - if (action == nullptr && ice::string::starts_with(action_name, _idprefix)) + if (action == nullptr && action_name.starts_with(_idprefix)) { // Try again after removing the prefix action = ice::hashmap::try_get( _actions, ice::hash( - ice::string::substr(action_name, ice::size(_idprefix)) + action_name.substr(_idprefix.size()) ) ); } @@ -404,30 +402,30 @@ namespace ice IPT_ZONE_SCOPED; using Iterator = ice::Array::ConstReverseIterator; - ice::ucount remaining_events = ice::count(events); + ice::u32 remaining_events = events.size().u32(); ice::Array events_copy{ _allocator, events }; ice::Array source_values{ _allocator }; // We go in reverse order since, the recently pushed layers should be processed first as they might override inputs. - Iterator const start = ice::array::rbegin(_layers_active); - Iterator const end = ice::array::rend(_layers_active); + Iterator const start = _layers_active.rbegin(); + Iterator const end = _layers_active.rend(); for (Iterator it = start; it != end; ++it) { StackLayer const& layer = _layers[it->index]; - for (ice::u32 offset : ice::array::slice(_layers_sources_indices, layer.sources_indices)) + for (ice::u32 offset : _layers_sources_indices.subspan(layer.sources_indices)) { - ice::array::push_back(source_values, ice::addressof(_sources_runtime_values[offset])); + source_values.push_back(ice::addressof(_sources_runtime_values[offset])); } - ice::ucount const processed_events = layer.layer->process_inputs( - ice::array::slice(events_copy, 0, remaining_events), + ice::u32 const processed_events = layer.layer->process_inputs( + events_copy.headspan(remaining_events), source_values ); ICE_ASSERT_CORE(processed_events <= remaining_events); remaining_events -= processed_events; - ice::array::clear(source_values); + source_values.clear(); // TODO: Should we change how this loop is finishing? if (remaining_events == 0) @@ -440,15 +438,15 @@ namespace ice for (Iterator it = start; it != end; ++it) { StackLayer const& layer = _layers[it->index]; - for (ice::u32 offset : ice::array::slice(_layers_sources_indices, layer.sources_indices)) + for (ice::u32 offset : _layers_sources_indices.subspan(layer.sources_indices)) { - ice::array::push_back(source_values, ice::addressof(_sources_runtime_values[offset])); + source_values.push_back(ice::addressof(_sources_runtime_values[offset])); } ex.prepare_constants(*layer.layer); layer.layer->update_actions(ex, source_values, _actions); - ice::array::clear(source_values); + source_values.clear(); } } diff --git a/source/code/systems/input_action_system/public/ice/input_action.hxx b/source/code/systems/input_action_system/public/ice/input_action.hxx index f9151b10..43766bc6 100644 --- a/source/code/systems/input_action_system/public/ice/input_action.hxx +++ b/source/code/systems/input_action_system/public/ice/input_action.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -9,6 +9,8 @@ namespace ice { + static constexpr auto ab = ice::String{ "asd" }; + static constexpr ice::AssetCategory AssetCategory_InputActionsScript = ice::make_asset_category("ice/input_actions/script"); } // namespace ice diff --git a/source/code/systems/input_action_system/public/ice/input_action_layer.hxx b/source/code/systems/input_action_system/public/ice/input_action_layer.hxx index ff4912d0..2f867296 100644 --- a/source/code/systems/input_action_system/public/ice/input_action_layer.hxx +++ b/source/code/systems/input_action_system/public/ice/input_action_layer.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -43,7 +43,7 @@ namespace ice //! \note The span needs to hold at least `ice::Constant_CountInputActionConstants` number of entries. //! \param[in,out] constants_span The span into which individual constant values will be loaded. //! \returns Number of loaded constants or `0` if no constants are defined in this layer. - virtual auto load_constants(ice::Span constants_span) const noexcept -> ice::ucount = 0; + virtual auto load_constants(ice::Span constants_span) const noexcept -> ice::u32 = 0; //! \brief Updates all layer sources based on the input events passed. //! \param[in,out] events List of input events to be processed. If an event was processed it will be swapped with an @@ -53,7 +53,7 @@ namespace ice virtual auto process_inputs( ice::Span events, ice::Span source_values - ) const noexcept -> ice::ucount = 0; + ) const noexcept -> ice::u32 = 0; //! \brief Runs updates on all defined actions by this layer. //! \param[in] executor Executor object with context data, used to execute conditions, steps and modifiers. diff --git a/source/code/systems/input_action_system/public/ice/input_action_stack.hxx b/source/code/systems/input_action_system/public/ice/input_action_stack.hxx index 8dae781f..2663e4ed 100644 --- a/source/code/systems/input_action_system/public/ice/input_action_stack.hxx +++ b/source/code/systems/input_action_system/public/ice/input_action_stack.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -26,7 +26,7 @@ namespace ice virtual auto registered_layers( ice::Array& out_layers - ) const noexcept -> ice::ucount = 0; + ) const noexcept -> ice::u32 = 0; virtual auto register_layer( ice::InputActionLayer const* layer @@ -35,7 +35,7 @@ namespace ice virtual auto active_layers( ice::Array& out_layers - ) const noexcept -> ice::ucount = 0; + ) const noexcept -> ice::u32 = 0; virtual void push_layer( ice::InputActionLayer const* layer diff --git a/source/code/systems/input_action_system/public/ice/input_action_types.hxx b/source/code/systems/input_action_system/public/ice/input_action_types.hxx index 37ad1a17..158305a3 100644 --- a/source/code/systems/input_action_system/public/ice/input_action_types.hxx +++ b/source/code/systems/input_action_system/public/ice/input_action_types.hxx @@ -1,8 +1,8 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include #include #include diff --git a/source/code/systems/input_system/private/input_controller.cxx b/source/code/systems/input_system/private/input_controller.cxx index f50ef4e6..cd37ddeb 100644 --- a/source/code/systems/input_system/private/input_controller.cxx +++ b/source/code/systems/input_system/private/input_controller.cxx @@ -1,11 +1,11 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "input_devices.hxx" #include "input_state_helpers.hxx" #include -#include +#include namespace ice::input { @@ -47,7 +47,7 @@ namespace ice::input : _device{ device } , _controls{ alloc } { - ice::array::resize(_controls, controller_button_num + 5); + _controls.resize(controller_button_num + 5); } void ControllerDevice::on_tick(ice::Timer const& timer) noexcept @@ -109,8 +109,8 @@ namespace ice::input if (input != InputID::Invalid) { - ice::ucount const control_index = input_identifier_value(input); - ICE_ASSERT_CORE(control_index < ice::array::count(_controls)); + ice::u32 const control_index = input_identifier_value(input); + ICE_ASSERT_CORE(control_index < _controls.size()); detail::ControlState control = _controls[control_index]; control.id = input; @@ -143,7 +143,7 @@ namespace ice::input event.axis_idx = axis_index; event.value.axis.value_f32 = value; event.value_type = InputValueType::AxisFloat; - ice::array::push_back(events_out, event); + events_out.push_back(event); } else if (reset == false) { @@ -152,7 +152,7 @@ namespace ice::input event.axis_idx = axis_index; event.value.axis.value_f32 = 0.0f; event.value_type = InputValueType::AxisFloat; - ice::array::push_back(events_out, event); + events_out.push_back(event); } }; @@ -167,7 +167,7 @@ namespace ice::input { if (detail::prepared_input_event(control, event)) { - ice::array::push_back(events_out, event); + events_out.push_back(event); } } } diff --git a/source/code/systems/input_system/private/input_keyboard.cxx b/source/code/systems/input_system/private/input_keyboard.cxx index 70e3de4f..21c0f2d4 100644 --- a/source/code/systems/input_system/private/input_keyboard.cxx +++ b/source/code/systems/input_system/private/input_keyboard.cxx @@ -1,11 +1,11 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "input_devices.hxx" #include "input_state_helpers.hxx" #include -#include +#include namespace ice::input { @@ -79,7 +79,7 @@ namespace ice::input , _device{ device } , _controls{ alloc } { - ice::array::resize(_controls, keyboard_key_num + keyboard_mod_num + 10); + _controls.resize(keyboard_key_num + keyboard_mod_num + 10); for (detail::ControlState& control : _controls) { control.id = InputID::Invalid; @@ -122,8 +122,8 @@ namespace ice::input break; } - ice::ucount const control_index = detail::input_control_index(input); - ICE_ASSERT_CORE(control_index < ice::array::count(_controls)); + ice::u32 const control_index = detail::input_control_index(input); + ICE_ASSERT_CORE(control_index < _controls.size()); detail::ControlState control = _controls[control_index]; control.id = input; @@ -158,7 +158,7 @@ namespace ice::input { if (detail::prepared_input_event(control, event)) { - ice::array::push_back(events_out, event); + events_out.push_back(event); } } } diff --git a/source/code/systems/input_system/private/input_mouse.cxx b/source/code/systems/input_system/private/input_mouse.cxx index d410cc60..8d2d0cab 100644 --- a/source/code/systems/input_system/private/input_mouse.cxx +++ b/source/code/systems/input_system/private/input_mouse.cxx @@ -5,7 +5,7 @@ #include "input_state_helpers.hxx" #include -#include +#include namespace ice::input { @@ -45,7 +45,7 @@ namespace ice::input : _device{ device } , _controls{ alloc } { - ice::array::resize(_controls, mouse_button_num + 5); + _controls.resize(mouse_button_num + 5); for (detail::ControlState& control : _controls) { control.id = InputID::Invalid; @@ -94,7 +94,7 @@ namespace ice::input if (input != InputID::Invalid) { ice::u32 const control_index = input_identifier_value(input); - ICE_ASSERT_CORE(control_index < ice::array::count(_controls)); + ICE_ASSERT_CORE(control_index < _controls.size()); detail::ControlState control = _controls[control_index]; control.id = input; @@ -122,13 +122,13 @@ namespace ice::input event.axis_idx = 0; event.value.axis.value_i32 = _position[0]; event.value_type = InputValueType::AxisInt; - ice::array::push_back(events_out, event); + events_out.push_back(event); event.identifier = input_identifier(DeviceType::Mouse, MouseInput::PositionY); event.axis_idx = 1; event.value.axis.value_i32 = _position[1]; event.value_type = InputValueType::AxisInt; - ice::array::push_back(events_out, event); + events_out.push_back(event); if (_position_relative[0] != 0) { @@ -136,7 +136,7 @@ namespace ice::input event.axis_idx = 0; event.value.axis.value_i32 = _position_relative[0]; event.value_type = InputValueType::AxisInt; - ice::array::push_back(events_out, event); + events_out.push_back(event); } if (_position_relative[1] != 0) { @@ -144,7 +144,7 @@ namespace ice::input event.axis_idx = 1; event.value.axis.value_i32 = _position_relative[1]; event.value_type = InputValueType::AxisInt; - ice::array::push_back(events_out, event); + events_out.push_back(event); } // All other events have an axis_idx == 0 @@ -153,14 +153,14 @@ namespace ice::input { event.identifier = input_identifier(DeviceType::Mouse, MouseInput::Wheel); event.value.axis.value_i32 = _wheel; - ice::array::push_back(events_out, event); + events_out.push_back(event); } for (detail::ControlState& control : _controls) { if (detail::prepared_input_event(control, event)) { - ice::array::push_back(events_out, event); + events_out.push_back(event); } } } diff --git a/source/code/systems/input_system/private/input_touchscreen.cxx b/source/code/systems/input_system/private/input_touchscreen.cxx index 680bc341..4572a95b 100644 --- a/source/code/systems/input_system/private/input_touchscreen.cxx +++ b/source/code/systems/input_system/private/input_touchscreen.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "input_devices.hxx" @@ -6,13 +6,13 @@ #include #include -#include +#include namespace ice::input { //! \brief Maximum number of pointers supported on a touchscreen device. - static constexpr ice::ucount Constant_MaxPointerCount = 6; + static constexpr ice::u32 Constant_MaxPointerCount = 6; static constexpr ice::input::detail::ControlConfig Constant_TouchControlConfig { .button_click_threshold = Constant_TouchScreenClickThreshold, @@ -27,12 +27,12 @@ namespace ice::input ice::input::DeviceHandle device ) noexcept; - auto max_count() const noexcept -> ice::ucount override + auto max_count() const noexcept -> ice::u32 override { return Constant_MaxPointerCount; } - auto count() const noexcept -> ice::ucount override + auto count() const noexcept -> ice::u32 override { return _pointer_count; } @@ -48,7 +48,7 @@ namespace ice::input void on_publish(ice::Array& events_out) noexcept override; private: - ice::ucount _pointer_count; + ice::u32 _pointer_count; ice::input::DeviceHandle _pointers[Constant_MaxPointerCount]; ice::vec2f _positions[Constant_MaxPointerCount]; @@ -77,7 +77,7 @@ namespace ice::input pointer = ice::input::DeviceHandle::Invalid; } - ice::array::resize(_controls, Constant_MaxPointerCount + 1); + _controls.resize(Constant_MaxPointerCount + 1); for (detail::ControlState& control : _controls) { control.id = InputID::Invalid; @@ -135,7 +135,7 @@ namespace ice::input if (input != InputID::Invalid) { ice::u32 const control_index = input_identifier_value(input) + pointer_index; - ICE_ASSERT_CORE(control_index < ice::array::count(_controls)); + ICE_ASSERT_CORE(control_index < _controls.size()); detail::ControlState control = _controls[control_index]; control.id = input; @@ -164,12 +164,12 @@ namespace ice::input event.identifier = input_identifier(DeviceType::TouchScreen, TouchInput::TouchPointerCount); event.value_type = InputValueType::AxisInt; event.value.axis.value_i32 = _pointer_count; - ice::array::push_back(events_out, event); + events_out.push_back(event); } event.value_type = InputValueType::AxisFloat; - ice::ucount remaining = _pointer_count; + ice::u32 remaining = _pointer_count; for (ice::u32 idx = 0; idx < max_count() && remaining > 0; ++idx) { if (_pointers[idx] == DeviceHandle::Invalid) continue; @@ -178,11 +178,11 @@ namespace ice::input event.device = _pointers[idx]; event.identifier = input_identifier(DeviceType::TouchScreen, TouchInput::TouchPosX); event.value.axis.value_f32 = (_positions[idx].x / _screen_size.x) - 0.5f; - ice::array::push_back(events_out, event); + events_out.push_back(event); event.identifier = input_identifier(DeviceType::TouchScreen, TouchInput::TouchPosY); event.value.axis.value_f32 = (_positions[idx].y / _screen_size.y) - 0.5f; - ice::array::push_back(events_out, event); + events_out.push_back(event); remaining -= 1; } @@ -192,7 +192,7 @@ namespace ice::input event.device = make_device_handle(DeviceType::TouchPointer, DeviceIndex(control_index++)); if (detail::prepared_input_event(control, event)) { - ice::array::push_back(events_out, event); + events_out.push_back(event); } } } diff --git a/source/code/systems/input_system/private/input_tracker.cxx b/source/code/systems/input_system/private/input_tracker.cxx index 295c26c0..cb1f7f96 100644 --- a/source/code/systems/input_system/private/input_tracker.cxx +++ b/source/code/systems/input_system/private/input_tracker.cxx @@ -155,7 +155,7 @@ namespace ice::input { for (InputDevice* device : _devices) { - ice::array::push_back(devices_out, device->handle()); + devices_out.push_back(device->handle()); } } diff --git a/source/code/systems/input_system/public/ice/input/device_event_queue.hxx b/source/code/systems/input_system/public/ice/input/device_event_queue.hxx index 75621472..9b2e233f 100644 --- a/source/code/systems/input_system/public/ice/input/device_event_queue.hxx +++ b/source/code/systems/input_system/public/ice/input/device_event_queue.hxx @@ -3,7 +3,7 @@ #pragma once #include -#include +#include namespace ice::input { @@ -46,12 +46,12 @@ namespace ice::input inline bool DeviceEventQueue::empty() const noexcept { - return ice::array::empty(_events); + return _events.is_empty(); } inline void DeviceEventQueue::clear() noexcept { - ice::array::clear(_events); + _events.clear(); } inline void DeviceEventQueue::push( @@ -59,8 +59,7 @@ namespace ice::input ice::input::DeviceMessage message ) noexcept { - ice::array::push_back( - _events, + _events.push_back( DeviceEvent{ .device = device, .message = message, @@ -104,7 +103,7 @@ namespace ice::input event.payload_data.val_f32 = payload_value; } - ice::array::push_back(_events, event); + _events.push_back(event); } template requires std::is_enum_v diff --git a/source/code/systems/input_system/public/ice/input/input_device.hxx b/source/code/systems/input_system/public/ice/input/input_device.hxx index 9b7d7ba9..3c473af7 100644 --- a/source/code/systems/input_system/public/ice/input/input_device.hxx +++ b/source/code/systems/input_system/public/ice/input/input_device.hxx @@ -1,10 +1,10 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include -#include +#include #include #include @@ -21,10 +21,10 @@ namespace ice::input //! \note In some cases, like a touch screen, a single touch pointer is seen as a single device. //! Multi touch is implemented using this value. //! \note A total of 15 different devices of the same type can be handled based on engine limits. - virtual auto max_count() const noexcept -> ice::ucount { return 1u; } + virtual auto max_count() const noexcept -> ice::u32 { return 1u; } //! \return Number of currently connected devices. - virtual auto count() const noexcept -> ice::ucount { return 1u; } + virtual auto count() const noexcept -> ice::u32 { return 1u; } //! \return Handle to a connected device. //! \note After accessing a handle, the user is still required to check if the handle valid. diff --git a/source/code/systems/render_system/public/ice/render/render_driver.hxx b/source/code/systems/render_system/public/ice/render/render_driver.hxx index f01324da..a1d94343 100644 --- a/source/code/systems/render_system/public/ice/render/render_driver.hxx +++ b/source/code/systems/render_system/public/ice/render/render_driver.hxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include diff --git a/source/code/systems/render_system/public/ice/render/render_pipeline.hxx b/source/code/systems/render_system/public/ice/render/render_pipeline.hxx index c4c3ca22..4c559f80 100644 --- a/source/code/systems/render_system/public/ice/render/render_pipeline.hxx +++ b/source/code/systems/render_system/public/ice/render/render_pipeline.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/systems/render_system/public/ice/render/render_profiler.hxx b/source/code/systems/render_system/public/ice/render/render_profiler.hxx index adb66460..93f6bd8e 100644 --- a/source/code/systems/render_system/public/ice/render/render_profiler.hxx +++ b/source/code/systems/render_system/public/ice/render/render_profiler.hxx @@ -1,9 +1,9 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include -#include +#include #include namespace ice::render::detail diff --git a/source/code/systems/resource_system/private/resource_dynlib.hxx b/source/code/systems/resource_system/private/resource_dynlib.hxx index d2200507..a94e2dad 100644 --- a/source/code/systems/resource_system/private/resource_dynlib.hxx +++ b/source/code/systems/resource_system/private/resource_dynlib.hxx @@ -1,11 +1,11 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include #include -#include +#include #include namespace ice diff --git a/source/code/systems/resource_system/private/resource_filesystem_baked.cxx b/source/code/systems/resource_system/private/resource_filesystem_baked.cxx index 4b01cee5..52e39d71 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_baked.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_baked.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_filesystem_baked.hxx" @@ -114,7 +114,7 @@ namespace ice auto BakedFileResource::name() const noexcept -> ice::String { - return ice::string::substr(_uri.path(), 1); + return _uri.path().substr(1); } auto BakedFileResource::origin() const noexcept -> ice::String @@ -202,7 +202,7 @@ namespace ice IPT_ZONE_TEXT_STR(utf8_file_path); ice::HeapString<> utf8_uri{ alloc }; - ice::string::push_back(utf8_uri, uri_base); + utf8_uri.push_back(uri_base); char temp[128]; read = ice::native_file::read_file( @@ -210,7 +210,7 @@ namespace ice ); ICE_ASSERT_CORE(read >= 0_B); - ice::string::push_back(utf8_uri, { temp, header.name_size }); + utf8_uri.push_back(ice::String{ temp, header.name_size }); return ice::create_resource_object( alloc, diff --git a/source/code/systems/resource_system/private/resource_filesystem_baked.hxx b/source/code/systems/resource_system/private/resource_filesystem_baked.hxx index bb275e98..ebe67860 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_baked.hxx +++ b/source/code/systems/resource_system/private/resource_filesystem_baked.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include diff --git a/source/code/systems/resource_system/private/resource_filesystem_loose.cxx b/source/code/systems/resource_system/private/resource_filesystem_loose.cxx index d2eb7efe..396ecb3b 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_loose.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_loose.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_filesystem_loose.hxx" @@ -53,7 +53,7 @@ namespace ice ice::native_file::path_from_string(native_filepath, filepath); if (readmeta) { - ice::string::push_back(native_filepath, ISP_PATH_LITERAL(".isrm")); + native_filepath.push_back(ISP_PATH_LITERAL(".isrm")); } IPT_MESSAGE_STR(filepath); @@ -82,7 +82,7 @@ namespace ice ice::native_file::path_from_string(native_filepath, filepath); if (readmeta) { - ice::string::push_back(native_filepath, ISP_PATH_LITERAL(".isrm")); + native_filepath.push_back(ISP_PATH_LITERAL(".isrm")); } ice::native_file::File handle = ice::native_file::open_file(native_filepath); @@ -117,7 +117,7 @@ namespace ice ice::Memory metafile_data = alloc.allocate(meta_size); if (ice::native_file::read_file(meta_handle, meta_size, metafile_data) > 0_B) { - if (ice::config::from_json(out_metadata, ice::string::from_data(metafile_data))) + if (ice::config::from_json(out_metadata, ice::string_from_data(metafile_data))) { // return the memory, we won't release it out_memory = metafile_data; @@ -323,8 +323,8 @@ namespace ice // TODO: Decide how to handle the basepath naming. bool const remove_slash = utf8_file_path[ice::path::length(base_path)] == '/'; - ice::String utf8_origin_name = ice::string::substr(utf8_file_path, ice::path::length(base_path) + remove_slash); - ice::String utf8_uri_path = ice::string::substr(utf8_file_path, ice::path::length(uri_base_path)); + ice::String const utf8_origin_name = utf8_file_path.substr(ice::path::length(base_path) + remove_slash); + ice::String const utf8_uri_path = utf8_file_path.substr(ice::path::length(uri_base_path)); IPT_ZONE_SCOPED_NAMED("stage: create_resource"); main_resource = ice::create_resource_object( diff --git a/source/code/systems/resource_system/private/resource_filesystem_loose.hxx b/source/code/systems/resource_system/private/resource_filesystem_loose.hxx index 795a3d39..0e261a36 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_loose.hxx +++ b/source/code/systems/resource_system/private/resource_filesystem_loose.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include "resource_filesystem.hxx" diff --git a/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx b/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx index b3cb6985..0198b6ad 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_traverser.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_filesystem_traverser.hxx" @@ -6,8 +6,7 @@ #include #include #include -#include -#include +#include #include #include @@ -51,9 +50,9 @@ namespace ice ice::native_file::FilePath const uribase = ice::path::directory(base_path); ice::native_file::FilePath const datafile = file_path; ice::native_file::HeapFilePath metafile{ temp_alloc }; - ice::string::reserve(metafile, 512); - ice::string::push_back(metafile, file_path); - ice::string::push_back(metafile, ISP_PATH_LITERAL(".isrm")); + metafile.reserve(512); + metafile.push_back(file_path); + metafile.push_back(ISP_PATH_LITERAL(".isrm")); resource = _callbacks.create_loose_resource( base_path, @@ -104,9 +103,9 @@ namespace ice ice::native_file::FilePath const uribase = ice::path::directory(base_path); ice::native_file::FilePath const datafile = file_path; ice::native_file::HeapFilePath metafile{ temp_alloc }; - ice::string::reserve(metafile, 512); - ice::string::push_back(metafile, file_path); - ice::string::push_back(metafile, ISP_PATH_LITERAL(".isrm")); + metafile.reserve(512); + metafile.push_back(file_path); + metafile.push_back(ISP_PATH_LITERAL(".isrm")); resource = _callbacks.create_loose_resource( base_path, @@ -196,15 +195,15 @@ namespace ice ) noexcept { ice::Array requests{ _callbacks.allocator() }; - ice::array::reserve(requests, ice::span::count(base_paths)); + requests.reserve(base_paths.size().u32()); [[maybe_unused]] std::atomic_uint32_t remaining = 0; for (ice::native_file::FilePath base_path : base_paths) { - ice::array::push_back(requests, { *this, base_path, remaining, nullptr, nullptr }); + requests.push_back({ *this, base_path, remaining, nullptr, nullptr }); ice::native_file::traverse_directories( - base_path, traverse_callback, &ice::array::back(requests) + base_path, traverse_callback, &requests.last() ); } } @@ -218,16 +217,16 @@ namespace ice ice::TaskScheduler local_sched{ local_queue }; ice::Array requests{ _callbacks.allocator() }; - ice::array::reserve(requests, ice::span::count(base_paths)); + requests.reserve(base_paths.size().u32()); std::atomic_uint32_t remaining = 0; // Traverse directories synchronously but create resources asynchronously. for (ice::native_file::FilePath base_path : base_paths) { - ice::array::push_back(requests, { *this, base_path, remaining, ice::addressof(scheduler), &local_sched }); + requests.push_back({ *this, base_path, remaining, ice::addressof(scheduler), &local_sched }); ice::native_file::traverse_directories( - base_path, traverse_callback, &ice::array::back(requests) + base_path, traverse_callback, &requests.last() ); } diff --git a/source/code/systems/resource_system/private/resource_filesystem_writable.cxx b/source/code/systems/resource_system/private/resource_filesystem_writable.cxx index 4239875e..8a9aed08 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_writable.cxx +++ b/source/code/systems/resource_system/private/resource_filesystem_writable.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_filesystem_writable.hxx" @@ -268,8 +268,8 @@ namespace ice // TODO: Decide how to handle the basepath naming. bool const remove_slash = utf8_file_path[ice::path::length(base_path)] == '/'; - ice::String utf8_origin_name = ice::string::substr(utf8_file_path, ice::path::length(base_path) + remove_slash); - ice::String utf8_uri_path = ice::string::substr(utf8_file_path, ice::path::length(uri_base_path)); + ice::String const utf8_origin_name = utf8_file_path.substr(ice::path::length(base_path) + remove_slash); + ice::String const utf8_uri_path = utf8_file_path.substr(ice::path::length(uri_base_path)); IPT_ZONE_SCOPED_NAMED("stage: create_writable_resource"); main_resource = ice::create_resource_object( diff --git a/source/code/systems/resource_system/private/resource_filesystem_writable.hxx b/source/code/systems/resource_system/private/resource_filesystem_writable.hxx index b026af6d..1c9021ae 100644 --- a/source/code/systems/resource_system/private/resource_filesystem_writable.hxx +++ b/source/code/systems/resource_system/private/resource_filesystem_writable.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include "resource_filesystem.hxx" diff --git a/source/code/systems/resource_system/private/resource_hailstorm_entry.cxx b/source/code/systems/resource_system/private/resource_hailstorm_entry.cxx index 038539fb..eb317cde 100644 --- a/source/code/systems/resource_system/private/resource_hailstorm_entry.cxx +++ b/source/code/systems/resource_system/private/resource_hailstorm_entry.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -29,7 +29,7 @@ namespace ice { ice::usize const filesize = ice::native_file::sizeof_file(handle); ICE_ASSERT( - filesize.value < ice::ucount_max, + filesize.value < ice::u32_max, "Trying to load file larger than supported!" ); diff --git a/source/code/systems/resource_system/private/resource_hailstorm_entry.hxx b/source/code/systems/resource_system/private/resource_hailstorm_entry.hxx index 7130addb..7a6279ef 100644 --- a/source/code/systems/resource_system/private/resource_hailstorm_entry.hxx +++ b/source/code/systems/resource_system/private/resource_hailstorm_entry.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -24,7 +24,7 @@ namespace ice virtual auto name() const noexcept -> ice::String override { - return ice::string::substr(_uri.path(), ice::string::find_first_of(_uri.path(), '.') + 5); + return _uri.path().substr(_uri.path().find_first_of('.') + 5); } virtual auto origin() const noexcept -> ice::String override { return _uri.path(); } diff --git a/source/code/systems/resource_system/private/resource_provider_custom.cxx b/source/code/systems/resource_system/private/resource_provider_custom.cxx index dffc22fc..57727f28 100644 --- a/source/code/systems/resource_system/private/resource_provider_custom.cxx +++ b/source/code/systems/resource_system/private/resource_provider_custom.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_provider_custom.hxx" @@ -42,9 +42,9 @@ namespace ice ice::native_file::FilePath const uribase = ice::path::directory(base_path); ice::native_file::FilePath const datafile = file_path; ice::native_file::HeapFilePath metafile{ temp_alloc }; - ice::string::reserve(metafile, 512); - ice::string::push_back(metafile, file_path); - ice::string::push_back(metafile, ISP_PATH_LITERAL(".isrm")); + metafile.reserve(512); + metafile.push_back(file_path); + metafile.push_back(ISP_PATH_LITERAL(".isrm")); ice::FileSystemResource* const resource = create_resources_from_loose_files( _allocator, @@ -73,14 +73,14 @@ namespace ice auto CustomResourceProvider::collect( ice::Array& out_changes - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { IPT_ZONE_SCOPED; - ice::array::reserve(out_changes, ice::array::count(out_changes) + ice::hashmap::count(_resources)); + out_changes.reserve(out_changes.size() + ice::hashmap::count(_resources)); for (auto* resource : _resources) { - ice::array::push_back(out_changes, resource); + out_changes.push_back(resource); } return ice::hashmap::count(_resources); } @@ -135,17 +135,13 @@ namespace ice ice::Resource const* root_resource ) const noexcept -> ice::Resource const* { - ice::u32 const origin_size = ice::string::size(root_resource->origin()); + ice::ncount const origin_size = root_resource->origin().size(); ice::HeapString<> predicted_path{ _allocator }; - ice::string::reserve(predicted_path, origin_size + ice::string::size(relative_uri.path())); - - predicted_path = ice::string::substr( - root_resource->origin(), - 0, - origin_size - ice::string::size( - ice::path::filename(root_resource->name()) - ) + predicted_path.reserve(origin_size + relative_uri.path().size()); + + predicted_path = root_resource->origin().substr( + 0, origin_size - ice::path::filename(root_resource->name()).size() ); ice::path::join(predicted_path, relative_uri.path()); diff --git a/source/code/systems/resource_system/private/resource_provider_custom.hxx b/source/code/systems/resource_system/private/resource_provider_custom.hxx index c1116e70..15456f89 100644 --- a/source/code/systems/resource_system/private/resource_provider_custom.hxx +++ b/source/code/systems/resource_system/private/resource_provider_custom.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -43,7 +43,7 @@ namespace ice auto collect( ice::Array& out_changes - ) noexcept -> ice::ucount override; + ) noexcept -> ice::u32 override; auto refresh( ice::Array& out_changes diff --git a/source/code/systems/resource_system/private/resource_provider_dynlib.cxx b/source/code/systems/resource_system/private/resource_provider_dynlib.cxx index b5c66842..c736085a 100644 --- a/source/code/systems/resource_system/private/resource_provider_dynlib.cxx +++ b/source/code/systems/resource_system/private/resource_provider_dynlib.cxx @@ -1,10 +1,10 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include #include #include -#include +#include #include #include @@ -123,7 +123,7 @@ namespace ice for (auto* resource : _resources) { - ice::array::push_back(out_changes, resource); + out_changes.push_back(resource); } } return ResourceProviderResult::Success; diff --git a/source/code/systems/resource_system/private/resource_provider_filelist.cxx b/source/code/systems/resource_system/private/resource_provider_filelist.cxx index 45fa1950..b7240427 100644 --- a/source/code/systems/resource_system/private/resource_provider_filelist.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filelist.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_provider_filelist.hxx" @@ -43,14 +43,15 @@ namespace ice _named_allocator, entry.path ); - ICE_ASSERT_CORE(ice::string::starts_with((ice::native_file::FilePath)file_path, (ice::native_file::FilePath)base_path)); + ice::native_file::FilePath const file_path_str = file_path; + ICE_ASSERT_CORE(file_path_str.starts_with((ice::native_file::FilePath)base_path)); } - ice::ucount const basepath_size = ice::string::empty(entry.basepath) - ? ice::string::size(entry.path) - ice::string::size(ice::path::filename(entry.path)) - : ice::string::size(entry.basepath); + ice::ncount const basepath_size = entry.basepath.is_empty() + ? entry.path.size() - ice::path::filename(entry.path).size() + : entry.basepath.size(); - ice::array::push_back(_file_paths, { .path = file_path, .basepath_size = basepath_size, }); + _file_paths.push_back({ .path = file_path, .basepath_size = basepath_size.u32() }); } } @@ -94,9 +95,9 @@ namespace ice ice::native_file::FilePath const uribase = ice::path::directory(base_path); ice::native_file::FilePath const datafile = file_path; ice::native_file::HeapFilePath metafile{ temp_alloc }; - ice::string::reserve(metafile, 512); - ice::string::push_back(metafile, file_path); - ice::string::push_back(metafile, ISP_PATH_LITERAL(".isrm")); + metafile.reserve(512); + metafile.push_back(file_path); + metafile.push_back(ISP_PATH_LITERAL(".isrm")); resource = create_resources_from_loose_files( _named_allocator, @@ -110,8 +111,8 @@ namespace ice if (resource != nullptr) { - resource->data_index = ice::array::count(_resources_data); - ice::array::push_back(_resources_data, ice::Memory{}); + resource->data_index = _resources_data.size().u32(); + _resources_data.push_back(ice::Memory{}); ice::u64 const hash = ice::hash(resource->uri().path()); ICE_ASSERT( @@ -134,7 +135,7 @@ namespace ice for (ice::FileListEntry const& entry : _file_paths) { create_resource_from_file( - ice::string::substr(entry.path, 0, entry.basepath_size), + entry.path.substr(0, entry.basepath_size), entry.path ); } @@ -142,14 +143,14 @@ namespace ice auto FileListResourceProvider::collect( ice::Array& out_changes - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { IPT_ZONE_SCOPED; - ice::array::reserve(out_changes, ice::array::count(out_changes) + ice::hashmap::count(_resources)); + out_changes.reserve(out_changes.size() + ice::hashmap::count(_resources)); for (auto* resource : _resources) { - ice::array::push_back(out_changes, resource); + out_changes.push_back(resource); } return ice::hashmap::count(_resources); } @@ -225,17 +226,13 @@ namespace ice ice::Resource const* root_resource ) const noexcept -> ice::Resource const* { - ice::u32 const origin_size = ice::string::size(root_resource->origin()); + ice::ncount const origin_size = root_resource->origin().size(); ice::HeapString<> predicted_path{ (ice::Allocator&) _data_allocator }; - ice::string::reserve(predicted_path, origin_size + ice::string::size(relative_uri.path())); - - predicted_path = ice::string::substr( - root_resource->origin(), - 0, - origin_size - ice::string::size( - ice::path::filename(root_resource->name()) - ) + predicted_path.reserve(origin_size + relative_uri.path().size()); + + predicted_path = root_resource->origin().substr( + 0, origin_size - ice::path::filename(root_resource->name()).size() ); ice::path::join(predicted_path, relative_uri.path()); diff --git a/source/code/systems/resource_system/private/resource_provider_filelist.hxx b/source/code/systems/resource_system/private/resource_provider_filelist.hxx index c1c1af8f..3e14c78a 100644 --- a/source/code/systems/resource_system/private/resource_provider_filelist.hxx +++ b/source/code/systems/resource_system/private/resource_provider_filelist.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -25,7 +25,7 @@ namespace ice struct FileListEntry { ice::native_file::HeapFilePath path; - ice::ucount basepath_size; + ice::u32 basepath_size; }; class FileListResourceProvider; @@ -58,7 +58,7 @@ namespace ice auto collect( ice::Array& out_changes - ) noexcept -> ice::ucount override; + ) noexcept -> ice::u32 override; auto refresh( ice::Array& out_changes diff --git a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx index cbaec23b..0ed60291 100644 --- a/source/code/systems/resource_system/private/resource_provider_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filesystem.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_provider_filesystem.hxx" @@ -33,7 +33,7 @@ namespace ice { ice::native_file::path_from_string(base_path, path); ice::path::normalize(base_path); - ice::array::push_back(_base_paths, base_path); + _base_paths.push_back(base_path); } } @@ -57,9 +57,9 @@ namespace ice auto FileSystemResourceProvider::filter_resource_uris( ice::ResourceFilter const& filter, ice::Array& out_uris - ) noexcept -> ice::TaskExpected + ) noexcept -> ice::TaskExpected { - ice::ucount collected = 0; + ice::u32 collected = 0; for (ice::FileSystemResource const* resource : _resources) { if (filter.allows_resource(resource)) @@ -83,7 +83,7 @@ namespace ice ice::Memory metadata_mem{}; if (reinterpret_cast(metadata_data.location)[0] == '{') { - metadata = ice::config::from_json(_named_allocator, ice::string::from_data(metadata_data), metadata_mem); + metadata = ice::config::from_json(_named_allocator, ice::string_from_data(metadata_data), metadata_mem); } else { @@ -99,7 +99,7 @@ namespace ice _named_allocator.deallocate(metadata_mem); } - ice::array::push_back(out_uris, resource->uri()); + out_uris.push_back(resource->uri()); collected += 1; } } @@ -108,14 +108,14 @@ namespace ice auto FileSystemResourceProvider::collect( ice::Array& out_changes - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { IPT_ZONE_SCOPED; - ice::array::reserve(out_changes, ice::array::count(out_changes) + ice::hashmap::count(_resources)); + out_changes.reserve(out_changes.size() + ice::hashmap::count(_resources)); for (auto* resource : _resources) { - ice::array::push_back(out_changes, resource); + out_changes.push_back(resource); } return ice::hashmap::count(_resources); } @@ -149,25 +149,25 @@ namespace ice "Trying to find resource for URI that is not handled by this provider." ); - if (ice::string::any(uri.host()) && _virtual_hostname != uri.host()) + if (uri.host().not_empty() && _virtual_hostname != uri.host()) { return nullptr; } ice::FileSystemResource* found_resource = nullptr; - ice::u32 const origin_size = ice::string::size(uri.path()); + ice::ncount const origin_size = uri.path().size(); ice::HeapString<> predicted_path{ (ice::Allocator&) _named_allocator }; for (ice::native_file::FilePath base_path : _base_paths) { - ice::string::resize(predicted_path, 0); - ice::string::reserve(predicted_path, origin_size + ice::string::size(base_path)); + predicted_path.resize(0); + predicted_path.reserve(origin_size + base_path.size()); ice::native_file::path_to_string(base_path, predicted_path); // Remove one directory if neccessary, because it's may be the common value of the base path and the uri path. // Note: This is because if a base path like 'dir/subdir' is provided the uri is created against 'dir/' // While a base path like 'dir/subdir/' will create uris against 'dir/subdir/' - if (ice::string::back(base_path) != '/') + if (base_path.back() != '/') { ice::path::join(predicted_path, ".."); } @@ -215,17 +215,13 @@ namespace ice ice::Resource const* root_resource ) const noexcept -> ice::Resource const* { - ice::u32 const origin_size = ice::string::size(root_resource->origin()); + ice::ncount const origin_size = root_resource->origin().size(); ice::HeapString<> predicted_path{ (ice::Allocator&) _named_allocator }; - ice::string::reserve(predicted_path, origin_size + ice::string::size(relative_uri.path())); - - predicted_path = ice::string::substr( - root_resource->origin(), - 0, - origin_size - ice::string::size( - ice::path::filename(root_resource->name()) - ) + predicted_path.reserve(origin_size + relative_uri.path().size()); + + predicted_path = root_resource->origin().substr( + 0, origin_size - ice::path::filename(root_resource->name()).size() ); ice::path::join(predicted_path, relative_uri.path()); @@ -289,8 +285,8 @@ namespace ice ice::FileSystemResource* resource ) noexcept -> ice::Result { - resource->data_index = ice::array::count(_resources_data); - ice::array::push_back(_resources_data, ice::Memory{}); + resource->data_index = _resources_data.size().u32(); + _resources_data.push_back(ice::Memory{}); ice::u64 const hash = ice::hash(resource->origin()); ICE_ASSERT( diff --git a/source/code/systems/resource_system/private/resource_provider_filesystem.hxx b/source/code/systems/resource_system/private/resource_provider_filesystem.hxx index f5c4fe90..7ca268ad 100644 --- a/source/code/systems/resource_system/private/resource_provider_filesystem.hxx +++ b/source/code/systems/resource_system/private/resource_provider_filesystem.hxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -47,11 +47,11 @@ namespace ice auto filter_resource_uris( ice::ResourceFilter const& filter, ice::Array& out_uris - ) noexcept -> ice::TaskExpected override; + ) noexcept -> ice::TaskExpected override; auto collect( ice::Array& out_changes - ) noexcept -> ice::ucount override; + ) noexcept -> ice::u32 override; auto refresh( ice::Array& out_changes diff --git a/source/code/systems/resource_system/private/resource_provider_filesystem_devui.cxx b/source/code/systems/resource_system/private/resource_provider_filesystem_devui.cxx index d8eb8fc4..693b157f 100644 --- a/source/code/systems/resource_system/private/resource_provider_filesystem_devui.cxx +++ b/source/code/systems/resource_system/private/resource_provider_filesystem_devui.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_provider_filesystem_devui.hxx" @@ -25,7 +25,7 @@ namespace ice { if (ImGui::BeginMenu("Resource Providers", true)) { - ImGui::MenuItem(ice::string::begin(widget_info.name), nullptr, &state.active); + ImGui::MenuItem(widget_info.name.begin(), nullptr, &state.active); ImGui::EndMenu(); } return false; @@ -84,7 +84,7 @@ namespace ice ice::u32 idx = 1; // We start with '1' since the first entry are the headers. for (ice::FileSystemResource* const res : ice::hashmap::values(_resources)) { - if (strstr(ice::string::begin(res->name()), _filter) == nullptr) + if (strstr(res->name().begin(), _filter) == nullptr) { continue; } @@ -100,11 +100,11 @@ namespace ice continue; } - ImGui::TextUnformatted(ice::string::begin(res->name()), ice::string::end(res->name())); + ImGui::TextUnformatted(res->name()); if (ImGui::TableNextColumn()) { - ImGui::TextUnformatted(ice::string::begin(res->origin()), ice::string::end(res->origin())); + ImGui::TextUnformatted(res->origin()); } if (ImGui::TableNextColumn()) diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx b/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx index 2415aa4b..3fb776cd 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_aio_request.hxx" @@ -141,7 +141,7 @@ namespace ice // both data and metadata pointers are allocated separately, which doubles the required hashmap size. ice::u32 const estimated_pointer_count = _chunk.count_entries * (_chunk.type == 3 ? 2 : 1); ice::hashmap::reserve(_offset_map, estimated_pointer_count); - ice::array::resize(_pointers, estimated_pointer_count); + _pointers.resize(estimated_pointer_count); } HailstormChunkLoader_Regular::~HailstormChunkLoader_Regular() noexcept @@ -268,10 +268,10 @@ namespace ice } ice::HeapString<> prefix{ _allocator, _packname }; - ice::string::push_back(prefix, "/"); + prefix.push_back("/"); ice::usize::base_type const size_extended_paths = hailstorm::v1::prefixed_resource_paths_size( - _pack.paths, (ice::ucount)_pack.resources.size(), ice::String{ prefix } + _pack.paths, (ice::u32)_pack.resources.size(), ice::String{ prefix } ); // We allocate enough memory to keep all original paths prefixed with the resource file name and a slash. @@ -293,7 +293,7 @@ namespace ice bool const prefixing_success = v1::prefix_resource_paths( _pack.paths, - { resptr, (ice::ucount)_pack.resources.size() }, + { resptr, (ice::u32)_pack.resources.size() }, { _paths_memory.location, _paths_memory.size.value, (size_t)_paths_memory.alignment }, ice::String{ prefix } ); @@ -309,7 +309,7 @@ namespace ice FileOpenFlags::Exclusive ).value(); - ice::array::resize(_loaders, _pack.header.count_chunks); + _loaders.resize(_pack.header.count_chunks); for (ice::u32 idx = 0; idx < _pack.header.count_chunks; ++idx) { if (_pack.chunks[idx].persistance >= 2) @@ -326,7 +326,7 @@ namespace ice } } - ice::array::resize(_entries, _pack.header.count_resources); + _entries.resize(_pack.header.count_resources); for (ice::u32 idx = 0; idx < _pack.header.count_resources; ++idx) { v1::HailstormResource const& res = _pack.resources[idx]; @@ -362,7 +362,7 @@ namespace ice } ice::multi_hashmap::insert(_entrymap, ice::hash(res_uri.path()), idx); - ice::array::push_back(out_changes, _entries[idx]); + out_changes.push_back(_entries[idx]); } return ResourceProviderResult::Success; @@ -415,7 +415,7 @@ namespace ice ) noexcept -> ice::TaskExpected { hailstorm::HailstormResource const& hsres = static_cast(resource)->_handle; - if (ice::string::size(fragment) && fragment == "meta") + if (fragment.not_empty() && fragment == "meta") { co_return co_await _loaders[hsres.meta_chunk]->request_slice(hsres.meta_offset, hsres.meta_size, _aioport); } diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx b/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx index b4e316e7..4184bbb8 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm.hxx @@ -1,12 +1,12 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.cxx b/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.cxx index 094f7c5f..3fc4d473 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.cxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.cxx @@ -1,8 +1,8 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_provider_hailstorm_devui.hxx" -#include +#include #include #include #include @@ -96,7 +96,7 @@ namespace ice { if (ImGui::BeginMenu("Resource Providers", true)) { - ImGui::MenuItem(ice::string::begin(widget_info.name), nullptr, &state.active); + ImGui::MenuItem(widget_info.name.begin(), nullptr, &state.active); ImGui::EndMenu(); } return false; @@ -223,7 +223,7 @@ namespace ice void HailStormResourceProvider::DevUI::build_resources_table() noexcept { - ice::u32 const pack_name_size = ice::string::size(_name) + 1; + ice::u32 const pack_name_size = _name.size().u32() + 1; ice::u32 const entry_count = 20; ice::u32 const entry_size = static_cast(ImGui::GetTextLineHeightWithSpacing()); diff --git a/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.hxx b/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.hxx index c5cbb08a..d4d30b9f 100644 --- a/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.hxx +++ b/source/code/systems/resource_system/private/resource_provider_hailstorm_devui.hxx @@ -1,10 +1,10 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include "resource_provider_hailstorm.hxx" -#include +#include #include namespace ice diff --git a/source/code/systems/resource_system/private/resource_tracker.cxx b/source/code/systems/resource_system/private/resource_tracker.cxx index b6262904..7013916e 100644 --- a/source/code/systems/resource_system/private/resource_tracker.cxx +++ b/source/code/systems/resource_system/private/resource_tracker.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_tracker.hxx" @@ -104,7 +104,7 @@ namespace ice ice::Array temp_resources{ _allocator }; for (auto const& provider : _resource_providers) { - ice::array::clear(temp_resources); + temp_resources.clear(); this->sync_provider(temp_resources, *provider); } @@ -153,7 +153,7 @@ namespace ice ice::ResourceProvider& provider, ice::ResourceFilter const& filter, ice::Array& out_uris - ) const noexcept -> ice::TaskExpected + ) const noexcept -> ice::TaskExpected { co_return co_await provider.filter_resource_uris(filter, out_uris); } @@ -161,9 +161,9 @@ namespace ice auto ResourceTrackerImplementation::filter_resource_uris( ice::ResourceFilter const& filter, ice::Array& out_uris - ) const noexcept -> ice::TaskExpected + ) const noexcept -> ice::TaskExpected { - ice::ucount collected = 0; + ice::u32 collected = 0; for (ice::UniquePtr const& provider : _resource_providers) { static constexpr ice::String const keywords[]{ "blocked", "allowed" }; @@ -346,7 +346,7 @@ namespace ice return; } - ice::ucount const new_count = ice::hashmap::count(_resources) + ice::array::count(out_resources); + ice::u32 const new_count = ice::hashmap::count(_resources) + out_resources.size().u32(); ICE_ASSERT( new_count <= _info.predicted_resource_count, "Maximum resource capacity of {} entiries reached!", @@ -473,15 +473,15 @@ namespace ice { if constexpr (ice::build::is_windows) { - ice::string::push_back(result, ".dll"); + result.push_back(".dll"); } else { // On unix we expect the library to be prepended with 'lib' and appended with '.so' - ice::string::clear(result); - ice::string::push_back(result, "lib"); - ice::string::push_back(result, name); - ice::string::push_back(result, ".so"); + result.clear(); + result.push_back("lib"); + result.push_back(name); + result.push_back(".so"); } } diff --git a/source/code/systems/resource_system/private/resource_tracker.hxx b/source/code/systems/resource_system/private/resource_tracker.hxx index 9853a290..88b8e4b2 100644 --- a/source/code/systems/resource_system/private/resource_tracker.hxx +++ b/source/code/systems/resource_system/private/resource_tracker.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -153,12 +153,12 @@ namespace ice ice::ResourceProvider& provider, ice::ResourceFilter const& filter, ice::Array& out_uris - ) const noexcept -> ice::TaskExpected; + ) const noexcept -> ice::TaskExpected; auto filter_resource_uris( ice::ResourceFilter const& filter, ice::Array& out_uris - ) const noexcept -> ice::TaskExpected override; + ) const noexcept -> ice::TaskExpected override; auto set_resource( diff --git a/source/code/systems/resource_system/private/resource_tracker_devui.cxx b/source/code/systems/resource_system/private/resource_tracker_devui.cxx index 93f1630d..03e1524e 100644 --- a/source/code/systems/resource_system/private/resource_tracker_devui.cxx +++ b/source/code/systems/resource_system/private/resource_tracker_devui.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_internal.hxx" @@ -6,10 +6,7 @@ #include #include -#include - -#include -#undef assert +#include namespace ice { @@ -79,12 +76,12 @@ namespace ice { ImGui::TableNextRow(); ImGui::TableNextColumn(); - ImGui::TextUnformatted(ice::string::begin(handle->name()), ice::string::end(handle->name())); + ImGui::TextUnformatted(handle->name()); if (ImGui::TableNextColumn()) { detail::status_flags_string(ice::internal_status(handle), temp_str); - ImGui::Text(ice::string::begin(temp_str), ice::string::end(temp_str)); + ImGui::TextUnformatted(temp_str); } } @@ -96,28 +93,28 @@ namespace ice { using enum ice::ResourceStatus; - ice::string::clear(out_str); + out_str.clear(); if (ice::has_all(flags, Available)) { - ice::string::push_back(out_str, "Available | "); + out_str.push_back("Available | "); } if (ice::has_all(flags, Loading)) { - ice::string::push_back(out_str, "Loading | "); + out_str.push_back("Loading | "); } if (ice::has_all(flags, Loaded)) { - ice::string::push_back(out_str, "Loaded | "); + out_str.push_back("Loaded | "); } if (ice::has_all(flags, Unloading)) { - ice::string::push_back(out_str, "Unloading | "); + out_str.push_back("Unloading | "); } if (flags == Invalid) { out_str = ice::String{ "Invalid | " }; } - ice::string::pop_back(out_str, 3); + out_str.pop_back(3); } } // namespace ice diff --git a/source/code/systems/resource_system/private/resource_writer_filesystem.cxx b/source/code/systems/resource_system/private/resource_writer_filesystem.cxx index cbfeeaf0..6ee6f1c3 100644 --- a/source/code/systems/resource_system/private/resource_writer_filesystem.cxx +++ b/source/code/systems/resource_system/private/resource_writer_filesystem.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "resource_writer_filesystem.hxx" @@ -52,9 +52,9 @@ namespace ice auto FileSystemResourceWriter::filter_resource_uris( ice::ResourceFilter const& filter, ice::Array& out_uris - ) noexcept -> ice::TaskExpected + ) noexcept -> ice::TaskExpected { - ice::ucount collected = 0; + ice::u32 collected = 0; for (ice::FileSystemResource const* resource : _resources) { if (filter.allows_resource(resource)) @@ -78,7 +78,7 @@ namespace ice ice::Memory metadata_mem{}; if (reinterpret_cast(metadata_data.location)[0] == '{') { - metadata = ice::config::from_json(_named_allocator, ice::string::from_data(metadata_data), metadata_mem); + metadata = ice::config::from_json(_named_allocator, ice::string_from_data(metadata_data), metadata_mem); } else { @@ -94,7 +94,7 @@ namespace ice _named_allocator.deallocate(metadata_mem); } - ice::array::push_back(out_uris, resource->uri()); + out_uris.push_back(resource->uri()); collected += 1; } } @@ -103,14 +103,14 @@ namespace ice auto FileSystemResourceWriter::collect( ice::Array& out_changes - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { IPT_ZONE_SCOPED; - ice::array::reserve(out_changes, ice::array::count(out_changes) + ice::hashmap::count(_resources)); + out_changes.reserve(out_changes.size() + ice::hashmap::count(_resources)); for (auto* resource : _resources) { - ice::array::push_back(out_changes, resource); + out_changes.push_back(resource); } return ice::hashmap::count(_resources); } @@ -144,22 +144,22 @@ namespace ice "Trying to find resource for URI that is not handled by this provider." ); - if (ice::string::any(uri.host()) && _virtual_hostname != uri.host()) + if (uri.host().not_empty() && _virtual_hostname != uri.host()) { return nullptr; } - ice::u32 const origin_size = ice::string::size(uri.path()); + ice::ncount const origin_size = uri.path().size(); ice::HeapString<> predicted_path{ (ice::Allocator&) _named_allocator }; - ice::string::resize(predicted_path, 0); - ice::string::reserve(predicted_path, origin_size + ice::string::size(_base_path)); + predicted_path.resize(0); + predicted_path.reserve(origin_size + _base_path.size()); ice::native_file::path_to_string(_base_path, predicted_path); // Remove one directory if neccessary, because it's may be the common value of the base path and the uri path. // Note: This is because if a base path like 'dir/subdir' is provided the uri is created against 'dir/' // While a base path like 'dir/subdir/' will create uris against 'dir/subdir/' - if (ice::string::back(_base_path) != '/') + if (_base_path.back() != '/') { ice::path::join(predicted_path, ".."); } @@ -201,17 +201,13 @@ namespace ice ice::Resource const* root_resource ) const noexcept -> ice::Resource const* { - ice::u32 const origin_size = ice::string::size(root_resource->origin()); + ice::ncount const origin_size = root_resource->origin().size(); ice::HeapString<> predicted_path{ (ice::Allocator&) _named_allocator }; - ice::string::reserve(predicted_path, origin_size + ice::string::size(relative_uri.path())); - - predicted_path = ice::string::substr( - root_resource->origin(), - 0, - origin_size - ice::string::size( - ice::path::filename(root_resource->name()) - ) + predicted_path.reserve(origin_size + relative_uri.path().size()); + + predicted_path = root_resource->origin().substr( + 0, origin_size - ice::path::filename(root_resource->name()).size() ); ice::path::join(predicted_path, relative_uri.path()); @@ -240,23 +236,23 @@ namespace ice co_return existing; } - ice::ucount predicted_path_len = 0; + ice::ncount predicted_path_len = 0; ice::native_file::HeapFilePath predicted_metapath{ (ice::Allocator&)_named_allocator }; ICE_ASSERT_CORE(flags != ResourceCreationFlags::Append); // TODO // TODO: move into a utility function { - ice::u32 const origin_size = ice::string::size(uri.path()); + ice::ncount const origin_size = uri.path().size(); - ice::string::resize(predicted_metapath, 0); - ice::string::reserve(predicted_metapath, origin_size + ice::string::size(_base_path)); + predicted_metapath.resize(0); + predicted_metapath.reserve(origin_size + _base_path.size()); ice::path::join(predicted_metapath, _base_path); // Remove one directory if neccessary, because it's may be the common value of the base path and the uri path. // Note: This is because if a base path like 'dir/subdir' is provided the uri is created against 'dir/' // While a base path like 'dir/subdir/' will create uris against 'dir/subdir/' - if (ice::string::back(_base_path) != '/') + if (_base_path.back() != '/') { ice::path::join(predicted_metapath, ISP_PATH_LITERAL("..")); } @@ -265,8 +261,8 @@ namespace ice // Metapath is the actuall file path + .isrm, so we just save the lenght before the appending // to have access to both paths. - predicted_path_len = ice::string::size(predicted_metapath); - ice::string::push_back(predicted_metapath, ISP_PATH_LITERAL(".isrm")); + predicted_path_len = predicted_metapath.size(); + predicted_metapath.push_back(ISP_PATH_LITERAL(".isrm")); // Create the final directory // #TODO: Research if checking for existance improves performance. @@ -278,7 +274,7 @@ namespace ice _base_path, ice::path::directory(_base_path), predicted_metapath, - ice::string::substr(predicted_metapath, 0, predicted_path_len) + predicted_metapath.substr(0, predicted_path_len) ); if (register_resource(new_resource) != S_Ok) @@ -337,8 +333,8 @@ namespace ice { ice::WritableFileSystemResource* const resource = static_cast(fs_resource); - resource->data_index = ice::array::count(_resources_data); - ice::array::push_back(_resources_data, ice::Memory{}); + resource->data_index = _resources_data.size().u32(); + _resources_data.push_back(ice::Memory{}); ice::u64 const hash = ice::hash(resource->origin()); ICE_ASSERT( diff --git a/source/code/systems/resource_system/private/resource_writer_filesystem.hxx b/source/code/systems/resource_system/private/resource_writer_filesystem.hxx index 4be6ef51..7fcc0968 100644 --- a/source/code/systems/resource_system/private/resource_writer_filesystem.hxx +++ b/source/code/systems/resource_system/private/resource_writer_filesystem.hxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -46,11 +46,11 @@ namespace ice auto filter_resource_uris( ice::ResourceFilter const& filter, ice::Array& out_uris - ) noexcept -> ice::TaskExpected override; + ) noexcept -> ice::TaskExpected override; auto collect( ice::Array& out_changes - ) noexcept -> ice::ucount override; + ) noexcept -> ice::u32 override; auto refresh( ice::Array& out_changes diff --git a/source/code/systems/resource_system/public/ice/resource.hxx b/source/code/systems/resource_system/public/ice/resource.hxx index c08e3de4..8c639218 100644 --- a/source/code/systems/resource_system/public/ice/resource.hxx +++ b/source/code/systems/resource_system/public/ice/resource.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/systems/resource_system/public/ice/resource_filter.hxx b/source/code/systems/resource_system/public/ice/resource_filter.hxx index 144aba56..d537f535 100644 --- a/source/code/systems/resource_system/public/ice/resource_filter.hxx +++ b/source/code/systems/resource_system/public/ice/resource_filter.hxx @@ -1,3 +1,6 @@ +/// Copyright 2025 - 2026, Dandielo +/// SPDX-License-Identifier: MIT + #pragma once #include #include @@ -39,14 +42,14 @@ namespace ice bool allows_hostname(ice::String hostname) const noexcept override { - return ice::string::empty(_hostname) || hostname == _hostname; + return _hostname.is_empty() || hostname == _hostname; } bool allows_resource( ice::Resource const* resource ) const noexcept override { - return ice::string::empty(_extension) || ice::path::extension(resource->origin()) == _extension; + return _extension.is_empty() || ice::path::extension(resource->origin()) == _extension; } private: diff --git a/source/code/systems/resource_system/public/ice/resource_provider.hxx b/source/code/systems/resource_system/public/ice/resource_provider.hxx index a726bd09..e553dd7c 100644 --- a/source/code/systems/resource_system/public/ice/resource_provider.hxx +++ b/source/code/systems/resource_system/public/ice/resource_provider.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -35,14 +35,14 @@ namespace ice virtual auto filter_resource_uris( ice::ResourceFilter const& filter, ice::Array& out_uris - ) noexcept -> ice::TaskExpected + ) noexcept -> ice::TaskExpected { co_return 0; } virtual auto collect( ice::Array& out_changes - ) noexcept -> ice::ucount + ) noexcept -> ice::u32 { return 0; } diff --git a/source/code/systems/resource_system/public/ice/resource_tracker.hxx b/source/code/systems/resource_system/public/ice/resource_tracker.hxx index 55b07998..78fb0e2d 100644 --- a/source/code/systems/resource_system/public/ice/resource_tracker.hxx +++ b/source/code/systems/resource_system/public/ice/resource_tracker.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -85,7 +85,7 @@ namespace ice virtual auto filter_resource_uris( ice::ResourceFilter const& filter, ice::Array& out_uris - ) const noexcept -> ice::TaskExpected = 0; + ) const noexcept -> ice::TaskExpected = 0; virtual auto set_resource( diff --git a/source/code/systems/resource_system/public/ice/resource_types.hxx b/source/code/systems/resource_system/public/ice/resource_types.hxx index e0c396c5..5d3aa3d1 100644 --- a/source/code/systems/resource_system/public/ice/resource_types.hxx +++ b/source/code/systems/resource_system/public/ice/resource_types.hxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once diff --git a/source/code/systems/resource_system/public/ice/uri.hxx b/source/code/systems/resource_system/public/ice/uri.hxx index de5817c8..505c2125 100644 --- a/source/code/systems/resource_system/public/ice/uri.hxx +++ b/source/code/systems/resource_system/public/ice/uri.hxx @@ -1,8 +1,8 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once -#include +#include #include namespace ice @@ -79,12 +79,12 @@ namespace ice constexpr bool get_scheme_size(ice::String raw_uri, ice::u8& out_size) noexcept { - ice::ucount const scheme_end = ice::string::find_first_of(raw_uri, ':'); - if (scheme_end != ice::String_NPos) + ice::nindex const scheme_end = raw_uri.find_first_of(':'); + if (scheme_end.is_valid()) { - out_size = static_cast(scheme_end + 1); + out_size = scheme_end.u8() + 1; } - return scheme_end != ice::String_NPos; + return scheme_end.is_valid(); } constexpr bool get_authority_sizes( @@ -97,39 +97,39 @@ namespace ice { if (uri[0] == '/' && uri[1] == '/') { - ice::ucount const authority_end = ice::string::find_first_of(uri, '/', 2); - ICE_ASSERT_CORE(authority_end != ice::String_NPos); - if (authority_end == ice::String_NPos) + ice::nindex const authority_end = uri.find_first_of('/', 2); + ICE_ASSERT_CORE(authority_end.is_valid()); + if (authority_end.is_valid() == false) { return false; } - out_authority = static_cast(authority_end); + out_authority = authority_end.u8(); - ice::ucount offset = 0; - ice::String const authority_uri = ice::string::substr(uri, 2, authority_end - 2); - ice::ucount const authority_user = ice::string::find_first_of(authority_uri, '@', offset); - if (authority_user != ice::String_NPos) + ice::nindex offset = 0; + ice::String const authority_uri = uri.substr(2, authority_end.u32() - 2); + ice::nindex const authority_user = authority_uri.find_first_of('@', offset); + if (authority_user.is_valid()) { // Include the '@' character in the size, since it can be easily removed in the 'userinfo()' method // and helps with calculations. - offset = out_user = static_cast(authority_user - offset) + 1; + offset = out_user = (authority_user - offset).u8() + 1; } - ice::ucount const authority_port = ice::string::find_first_of(authority_uri, ':', offset); - if (authority_port != ice::String_NPos) + ice::nindex const authority_port = authority_uri.find_first_of(':', offset); + if (authority_port.is_valid()) { // If we have a port set the length of host to up to the ':' character - out_host = static_cast(authority_port - offset); + out_host = (authority_port - offset).u8(); // After that it's the 'port' value (without the ':') character // Because the host needs to exist we can always add +1, and keep the port size the actual size. - out_port = static_cast(ice::size(authority_uri) - (authority_port + 1)); + out_port = (authority_uri.size() - (authority_port + 1)).u8(); } else { // The rest of the authority string is the host - out_host = static_cast(ice::size(authority_uri) - offset); + out_host = (authority_uri.size() - offset).u8(); } } return true; @@ -142,34 +142,34 @@ namespace ice ice::u8& out_fragment ) noexcept { - ice::ucount path_separator = ice::string::find_first_of(uri, ice::String{ "?#" }); - if (path_separator == ice::String_NPos) + ice::nindex path_separator = uri.find_first_of("?#"); + if (path_separator == nindex_none) { - out_path = static_cast(ice::size(uri)); + out_path = uri.size().u8(); return out_path > 0; } // We continue after assigning path length - out_path = static_cast(path_separator); + out_path = path_separator.u8(); // Do we have a query? if (uri[path_separator] == '?') { // Get the next separator if necessary - path_separator = ice::string::find_last_of(uri, '#'); - if (path_separator == ice::String_NPos) + path_separator = uri.find_last_of('#'); + if (path_separator == nindex_none) { // We take te remaining query with the starting '?' character - out_query = static_cast(ice::size(uri) - out_path); + out_query = (uri.size() - out_path).u8(); return true; } // The everything up to '#' including the '?' character. - out_query = static_cast(path_separator - out_path); + out_query = (path_separator - out_path).u8(); } // Take everything remaining including the '#' character. - out_fragment = static_cast(ice::size(uri) - path_separator); + out_fragment = (uri.size() - path_separator).u8(); return true; } @@ -195,7 +195,7 @@ namespace ice } constexpr URI::URI(ice::String uri_raw) noexcept - : _uri{ ice::string::begin(uri_raw) } + : _uri{ uri_raw.begin() } , _forced_scheme{ } , _scheme{ } , _authority{ } @@ -206,17 +206,17 @@ namespace ice , _query{ } , _fragment{ } { - ice::u8 scheme_size; + ice::u8 scheme_size = 0; if (detail::get_scheme_size(uri_raw, scheme_size)) { _scheme = scheme_size; } detail::get_authority_sizes( - ice::string::substr(uri_raw, _scheme), + uri_raw.substr(_scheme), _authority, _userinfo, _host, _port ); detail::get_path_query_fragment_sizes( - ice::string::substr(uri_raw, _scheme + _authority), + uri_raw.substr(_scheme + _authority), _path, _query, _fragment ); } @@ -300,7 +300,7 @@ namespace ice constexpr auto URI::userinfo() const noexcept -> ice::String { - return ice::String{ _uri + _scheme + 2 /* removes '//' */, ice::ucount(_userinfo - (_userinfo != 0)) }; + return ice::String{ _uri + _scheme + 2 /* removes '//' */, ice::u32(_userinfo - (_userinfo != 0)) }; } constexpr auto URI::host() const noexcept -> ice::String @@ -316,7 +316,7 @@ namespace ice // Helpers constexpr auto operator""_uri(char const* raw_uri, std::size_t length) noexcept -> ice::URI { - return URI{ ice::String{ raw_uri, ice::ucount(length) } }; + return URI{ ice::String{ raw_uri, length } }; } } // namespace ice diff --git a/source/code/systems/resource_system/resource_system_tests.bff b/source/code/systems/resource_system/resource_system_tests.bff index 9e048925..66971ad1 100644 --- a/source/code/systems/resource_system/resource_system_tests.bff +++ b/source/code/systems/resource_system/resource_system_tests.bff @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT .Project = @@ -29,7 +29,7 @@ .UnitTests = [ - .Enabled = true + .Enabled = false ] ] .Projects + .Project diff --git a/source/code/systems/resource_system/tests/test_resource_meta.cxx b/source/code/systems/resource_system/tests/test_resource_meta.cxx index 147960a0..772b9f27 100644 --- a/source/code/systems/resource_system/tests/test_resource_meta.cxx +++ b/source/code/systems/resource_system/tests/test_resource_meta.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -14,7 +14,7 @@ namespace Catch { static std::string convert(ice::String const& value) { - return StringMaker::convert({ value._data, value._size }); + return StringMaker::convert(value); } }; } @@ -59,6 +59,8 @@ SCENARIO("resource_system 'ice/resource_meta.hxx'", "[resource][metadata]") REQUIRE(meta._data != nullptr); ice::String meta_name; + meta_name == "asd"; + CHECK(ice::config::get(meta, "name", meta_name)); CHECK(meta_name == "foo"); @@ -68,14 +70,14 @@ SCENARIO("resource_system 'ice/resource_meta.hxx'", "[resource][metadata]") ice::Array meta_numbers{ alloc }; CHECK(ice::config::get_array(meta, "details.numbers", meta_numbers)); - CHECK(ice::array::count(meta_numbers) == 3); + CHECK(meta_numbers.size() == 3); CHECK(meta_numbers[0] == 1); CHECK(meta_numbers[1] == 2); CHECK(meta_numbers[2] == 3); ice::Array meta_strings{ alloc }; CHECK(ice::config::get_array(meta, "details.strings", meta_strings)); - CHECK(ice::array::count(meta_strings) == 4); + CHECK(meta_strings.size() == 4); CHECK(meta_strings[0] == "The"); CHECK(meta_strings[2] == "brown"); @@ -101,14 +103,14 @@ SCENARIO("resource_system 'ice/resource_meta.hxx'", "[resource][metadata]") ice::Array meta_numbers_2{ alloc }; CHECK(ice::config::get_array(const_meta, "details.numbers", meta_numbers_2)); - CHECK(ice::array::count(meta_numbers_2) == 3); + CHECK(meta_numbers_2.size() == 3); CHECK(meta_numbers_2[0] == 1); CHECK(meta_numbers_2[1] == 2); CHECK(meta_numbers_2[2] == 3); ice::Array meta_strings_2{ alloc }; CHECK(ice::config::get_array(const_meta, "details.strings", meta_strings_2)); - CHECK(ice::array::count(meta_strings_2) == 4); + CHECK(meta_strings_2.size() == 4); CHECK(meta_strings_2[0] == "The"); CHECK(meta_strings_2[2] == "brown"); } @@ -214,10 +216,10 @@ SCENARIO("resource_system 'ice/resource_meta.hxx'", "[resource][metadata]") CHECK(ice::config::get_array(empty_config, "value.float", meta_float_arr) == ice::E_Fail); CHECK(ice::config::get_array(empty_config, "value.string", meta_string_arr) == ice::E_Fail); - CHECK(ice::array::count(meta_bool_arr) == 0); - CHECK(ice::array::count(meta_int32_arr) == 0); - CHECK(ice::array::count(meta_float_arr) == 0); - CHECK(ice::array::count(meta_string_arr) == 0); + CHECK(meta_bool_arr.size() == 0); + CHECK(meta_int32_arr.size() == 0); + CHECK(meta_float_arr.size() == 0); + CHECK(meta_string_arr.size() == 0); } } } diff --git a/source/code/systems/ui_system/private/ui_element_info.cxx b/source/code/systems/ui_system/private/ui_element_info.cxx index 8ae25ee2..d79eaa61 100644 --- a/source/code/systems/ui_system/private/ui_element_info.cxx +++ b/source/code/systems/ui_system/private/ui_element_info.cxx @@ -17,10 +17,10 @@ namespace ice::ui ice::u16 const index = info.size_i & 0x0fff; ICE_ASSERT( - index < ice::count(uidata.sizes), + index < uidata.sizes.size(), "Trying to read 'size' value for element index outside of the given data. [ idx:{} | range:0 .. {}]", info.size_i, - ice::count(uidata.sizes) + uidata.sizes.size() ); out_size = uidata.sizes[index]; @@ -35,10 +35,10 @@ namespace ice::ui ice::u16 const index = info.pos_i & 0x0fff; ICE_ASSERT( - index < ice::count(uidata.positions), + index < uidata.positions.size(), "Trying to read 'position' value for element index outside of the given data. [ idx:{} | range:0 .. {}]", info.pos_i, - ice::count(uidata.positions) + uidata.positions.size() ); out_position = uidata.positions[index]; @@ -53,10 +53,10 @@ namespace ice::ui ice::u16 const index = info.mar_i & 0x0fff; ICE_ASSERT( - index < ice::count(uidata.margins), + index < uidata.margins.size(), "Trying to read 'margin' value for element index outside of the given data. [ idx:{} | range:0 .. {}]", info.mar_i, - ice::count(uidata.margins) + uidata.margins.size() ); out_rect_offset = uidata.margins[index]; @@ -71,10 +71,10 @@ namespace ice::ui ice::u16 const index = info.mar_i & 0x0fff; ICE_ASSERT( - index < ice::count(uidata.paddings), + index < uidata.paddings.size(), "Trying to read 'padding' value for element index outside of the given data. [ idx:{} | range:0 .. {}]", info.pad_i, - ice::count(uidata.paddings) + uidata.paddings.size() ); out_rect_offset = uidata.paddings[index]; diff --git a/source/code/systems/ui_system/public/ice/ui_action.hxx b/source/code/systems/ui_system/public/ice/ui_action.hxx index 504978cb..0993055d 100644 --- a/source/code/systems/ui_system/public/ice/ui_action.hxx +++ b/source/code/systems/ui_system/public/ice/ui_action.hxx @@ -1,10 +1,10 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include -#include +#include #include namespace ice::ui diff --git a/source/code/systems/ui_system/public/ice/ui_button.hxx b/source/code/systems/ui_system/public/ice/ui_button.hxx index 7c7bf3e4..f9fb1439 100644 --- a/source/code/systems/ui_system/public/ice/ui_button.hxx +++ b/source/code/systems/ui_system/public/ice/ui_button.hxx @@ -1,10 +1,10 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include -#include +#include #include #include diff --git a/source/code/test/private/game.cxx b/source/code/test/private/game.cxx index 844a2231..24581e21 100644 --- a/source/code/test/private/game.cxx +++ b/source/code/test/private/game.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "game.hxx" @@ -156,7 +156,7 @@ struct TestTrait : public ice::Trait update.engine.entity_index().destroy_many(_my_entity); query().tags().for_each_block( - [&](ice::ucount count, ice::ecs::Entity const* entities) noexcept + [&](ice::u32 count, ice::ecs::Entity const* entities) noexcept { _ops->destroy({ entities, count }); } @@ -171,11 +171,11 @@ struct TestTrait : public ice::Trait ice::ecs::Query q = query(); ice::Array> tasks{ update.frame.allocator() }; - ice::array::reserve(tasks, q.block_count()); + tasks.reserve(q.block_count()); - q.for_each_block([&](ice::ucount count, C1* c1p, C2* c2p) noexcept + q.for_each_block([&](ice::u32 count, C1* c1p, C2* c2p) noexcept { - ice::array::push_back(tasks, [](ice::ucount count, C1* c1p, C2* c2p) noexcept -> ice::Task<> + tasks.push_back([](ice::u32 count, C1* c1p, C2* c2p) noexcept -> ice::Task<> { IPT_ZONE_SCOPED_NAMED("block for-each"); for (ice::u32 idx = 0; idx < count; ++idx) diff --git a/source/code/test/private/input_actions.cxx b/source/code/test/private/input_actions.cxx index 60362b32..d18bde2b 100644 --- a/source/code/test/private/input_actions.cxx +++ b/source/code/test/private/input_actions.cxx @@ -1,4 +1,4 @@ -/// Copyright 2025 - 2025, Dandielo +/// Copyright 2025 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "input_actions.hxx" @@ -60,7 +60,7 @@ namespace ice ice::Data const data = co_await script[AssetState::Raw]; if (data.location != nullptr) { - _layers = ice::parse_input_action_layer(_allocator, ice::string::from_data(data)); + _layers = ice::parse_input_action_layer(_allocator, ice::string_from_data(data)); } diff --git a/source/code/tools/asset_compiler/private/asset_compiler_app.cxx b/source/code/tools/asset_compiler/private/asset_compiler_app.cxx index 5e0373f3..4b228e47 100644 --- a/source/code/tools/asset_compiler/private/asset_compiler_app.cxx +++ b/source/code/tools/asset_compiler/private/asset_compiler_app.cxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -42,17 +42,15 @@ class AssetCompilerApp : public ice::tool::ToolApp bool parse_parameter(this AssetCompilerApp& self, ice::Span results) noexcept { - if (ice::count(results) == 2) + if (results.size() == 2) { - ice::array::push_back( - self._params, - ice::shard(results[0], ice::string::begin(results[1])) + self._params.push_back( + ice::shard(results[0], results[1].begin()) ); } - if (ice::count(results) == 1) + if (results.size() == 1) { - ice::array::push_back( - self._params, + self._params.push_back( ice::shard(results[0], true) ); } @@ -149,7 +147,7 @@ class AssetCompilerApp : public ice::tool::ToolApp } ICE_LOG_IF( - Param_Verbose && (_output_std == false && ice::string::empty(_output)), + Param_Verbose && (_output_std == false && _output.is_empty()), ice::LogSeverity::Retail, ice::LogTag::Tool, "No output was selected, please use '-o,--output' or '--stdout'!" ); @@ -160,7 +158,7 @@ class AssetCompilerApp : public ice::tool::ToolApp { .predicted_resource_count = 10'000, .io_dedicated_threads = 0 } ); - if (ice::string::empty(_asset_basepath)) + if (_asset_basepath.is_empty()) { _asset_basepath = ice::app::workingdir(); } @@ -190,11 +188,11 @@ class AssetCompilerApp : public ice::tool::ToolApp Param_Verbose, ice::LogSeverity::Retail, ice::LogTag::Tool, "Creating asset '{}' from {} sources and {} metadata files.", - input_resource->name(), ice::count(_inputs), ice::count(_inputs_meta) + input_resource->name(), _inputs.size(), _inputs_meta.size() ); ice::HeapString<> uristr{ _allocator, "file://" }; - ice::string::push_back(uristr, input_resource->uri().path()); + uristr.push_back(input_resource->uri().path()); ice::ResourceHandle res = resource_tracker->find_resource(ice::URI{ uristr }); if (res == nullptr) @@ -221,7 +219,7 @@ class AssetCompilerApp : public ice::tool::ToolApp continue; } - ice::ucount out_idx = 0; + ice::u32 out_idx = 0; if (ice::search(compiler.fn_supported_resources(_params), res_ext, out_idx)) { resource_compiler = &compiler; @@ -264,7 +262,7 @@ class AssetCompilerApp : public ice::tool::ToolApp return 1; } - ice::ucount out_idx = 0; + ice::u32 out_idx = 0; if (ice::search(resource_compiler->fn_supported_resources(_params), res_ext, out_idx) == false) { ICE_LOG(ice::LogSeverity::Critical, ice::LogTag::Tool, "Resource compiler for resource '{}' is not available.", res->name()); @@ -281,25 +279,25 @@ class AssetCompilerApp : public ice::tool::ToolApp } // If no name was provided use the input name and replace the extension is needed - if (ice::string::empty(final_asset_name)) + if (final_asset_name.is_empty()) { final_asset_name = input_resource->name(); // Replace the extension if a result extension is provided. - if (ice::string::any(result_extension)) + if (result_extension.not_empty()) { ice::path::replace_extension(final_asset_name, result_extension); } } // If asset name has no extension, attach the result extension - else if (ice::string::empty(ice::path::extension(final_asset_name))) + else if (ice::path::extension(final_asset_name).is_empty()) { ice::path::replace_extension(final_asset_name, result_extension); } // Warn if the final extension is different than what the resource compiler expects. ICE_LOG_IF( - ice::string::any(result_extension) && ice::path::extension(final_asset_name) != result_extension, + result_extension.not_empty() && ice::path::extension(final_asset_name) != result_extension, ice::LogSeverity::Warning, ice::LogTag::Tool, "Asset compiler result extension '{}' differs from provided asset name extension {}!", result_extension, ice::path::extension(final_asset_name) @@ -321,9 +319,9 @@ class AssetCompilerApp : public ice::tool::ToolApp } // If empty we add our own handle to the list - if (ice::array::empty(sources)) + if (sources.is_empty()) { - ice::array::push_back(sources, res); + sources.push_back(res); } ice::Array dependencies{ _allocator }; @@ -364,7 +362,7 @@ class AssetCompilerApp : public ice::tool::ToolApp _queue.process_all(); } - ice::array::push_back(results, result); + results.push_back(result); } if (ice::wait_for_result(resource_compiler->fn_build_metadata(ctx, res, *resource_tracker, results, dependencies, meta)) == false) @@ -381,13 +379,13 @@ class AssetCompilerApp : public ice::tool::ToolApp return 1; } - if (ice::string::any(_output)) + if (_output.not_empty()) { ice::Memory const final_meta_data = meta.finalize(_allocator); // Calc meta offset ice::AlignResult const meta_offset = ice::align_to( - (ice::u32)sizeof(ice::ResourceFormatHeader) + ice::string::size(final_asset_name) + 1, + (ice::u32)sizeof(ice::ResourceFormatHeader) + final_asset_name.size().u32() + 1, ice::ualign::b_8 ); @@ -395,7 +393,7 @@ class AssetCompilerApp : public ice::tool::ToolApp ice::ResourceFormatHeader const rfh{ .magic = ice::Constant_ResourceFormatMagic, .version = ice::Constant_ResourceFormatVersion, - .name_size = ice::string::size(final_asset_name), + .name_size = final_asset_name.size().u32(), .meta_offset = meta_offset.value, .meta_size = static_cast(final_meta_data.size.value), .offset = (ice::u32)(meta_offset.value + final_meta_data.size.value), @@ -409,7 +407,7 @@ class AssetCompilerApp : public ice::tool::ToolApp char const filler[8]{ 0 }; ice::Data const file_parts[]{ ice::data_view(rfh), // Header - ice::string::data_view(final_asset_name), // Name + final_asset_name.data_view(), // Name ice::Data{ &filler, 1, ice::ualign::b_1 }, ice::Data{ &filler, meta_offset.padding, ice::ualign::b_1 }, ice::data_view(final_meta_data), // Metadata @@ -417,7 +415,7 @@ class AssetCompilerApp : public ice::tool::ToolApp }; // Write all parts - for (ice::Data file_part : ice::span::subspan(ice::Span{ file_parts }, _output_raw ? 4 : 0)) + for (ice::Data file_part : ice::Span{ file_parts }.subspan(_output_raw ? 4 : 0)) { if (ice::native_file::append_file(output_file, file_part) != file_part.size) { @@ -430,7 +428,7 @@ class AssetCompilerApp : public ice::tool::ToolApp if (_output_std) { - fmt::println("{}", ice::String{ (char const*)final_asset_data.location, (ice::ucount)final_asset_data.size.value }); + fmt::println("{}", ice::String{ (char const*)final_asset_data.location, (ice::u32)final_asset_data.size.value }); } _allocator.deallocate(final_asset_data); diff --git a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx index 7527a88e..97ee3636 100644 --- a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx +++ b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.cxx @@ -1,8 +1,8 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "asset_compiler_resource_provider.hxx" -#include +#include #include AssetCompilerResource::AssetCompilerResource( @@ -18,7 +18,7 @@ AssetCompilerResource::AssetCompilerResource( { ice::native_file::HeapFilePath metapath{ _allocator }; ice::native_file::path_from_string(metapath, _path); - ice::string::push_back(metapath, ISP_PATH_LITERAL(".isrm")); + metapath.push_back(ISP_PATH_LITERAL(".isrm")); if (auto metafile = ice::native_file::open_file(metapath, ice::native_file::FileOpenFlags::Read); file) { @@ -64,7 +64,7 @@ AssetCompilerResourceProvider::AssetCompilerResourceProvider( , _resources{ _allocator } , _data{ _allocator } { - ice::array::reserve(_resources, ice::count(files)); + _resources.reserve(files.size().u32()); ice::u32 idx = 0; for (ice::String file : files) @@ -76,11 +76,11 @@ AssetCompilerResourceProvider::AssetCompilerResourceProvider( AssetCompilerResource* res = _allocator.create(_allocator, ice::move(filehandle), file); res->idx = idx++; - ice::array::push_back(_resources, res); + _resources.push_back(res); } - ice::array::resize(_data, ice::count(_resources)); - ice::memset(ice::begin(_data), '\0', ice::array::data_view(_data).size.value); + _data.resize(_resources.size()); + ice::memset(_data.begin(), '\0', _data.size().bytes().value); } AssetCompilerResourceProvider::~AssetCompilerResourceProvider() noexcept @@ -98,7 +98,7 @@ AssetCompilerResourceProvider::~AssetCompilerResourceProvider() noexcept auto AssetCompilerResourceProvider::collect( ice::Array& out_changes -) noexcept -> ice::ucount +) noexcept -> ice::u32 { return 0; } @@ -109,7 +109,7 @@ auto AssetCompilerResourceProvider::refresh( { for (AssetCompilerResource* res : _resources) { - ice::array::push_back(out_changes, res); + out_changes.push_back(res); } return ice::ResourceProviderResult::Success; } diff --git a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.hxx b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.hxx index 3e274233..e06b09d3 100644 --- a/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.hxx +++ b/source/code/tools/asset_compiler/private/asset_compiler_resource_provider.hxx @@ -1,4 +1,4 @@ -/// Copyright 2024 - 2025, Dandielo +/// Copyright 2024 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once @@ -46,7 +46,7 @@ public: auto collect( ice::Array& out_changes - ) noexcept -> ice::ucount override; + ) noexcept -> ice::u32 override; auto refresh( ice::Array& out_changes diff --git a/source/code/tools/hsc_packer/private/hsc_packer.cxx b/source/code/tools/hsc_packer/private/hsc_packer.cxx index 23cefb4b..81146085 100644 --- a/source/code/tools/hsc_packer/private/hsc_packer.cxx +++ b/source/code/tools/hsc_packer/private/hsc_packer.cxx @@ -1,4 +1,4 @@ -/// Copyright 2022 - 2025, Dandielo +/// Copyright 2022 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include @@ -152,7 +152,7 @@ class HailStormPackerApp final : public ice::tool::ToolApp ice::Memory configmem; ice::Config const config = ice::config::from_json( _allocator, - ice::String{ (char const*)filemem.location, (ice::ucount)filemem.size.value }, + ice::String{ (char const*)filemem.location, (ice::u32)filemem.size.value }, configmem ); @@ -161,8 +161,8 @@ class HailStormPackerApp final : public ice::tool::ToolApp { for (ice::String ext : extensions) { - ice::array::push_back(_filter_extensions_heap, { _allocator, ext }); - ice::array::push_back(_filter_extensions, ice::array::back(_filter_extensions_heap)); + _filter_extensions_heap.push_back({ _allocator, ext }); + _filter_extensions.push_back(_filter_extensions_heap.last()); } } HSCP_ERROR_IF( @@ -176,7 +176,7 @@ class HailStormPackerApp final : public ice::tool::ToolApp } } - if (ice::array::empty(_filter_extensions)) + if (_filter_extensions.is_empty()) { HSCP_ERROR("No valid configuration files where provided."); return 1; @@ -237,11 +237,11 @@ class HailStormPackerApp final : public ice::tool::ToolApp _param_output = hscp_process_directory(_allocator, _param_output); // The paths that will be searched for loose file resources. - ice::Array files{ _allocator, }; - ice::array::reserve(files, ice::count(_inputs)); + ice::Array files{ _allocator }; + files.reserve(_inputs.size()); for (ice::String file : _inputs) { - ice::array::push_back(files, { .path = file }); + files.push_back({ .path = file }); } ice::UniquePtr fsprov = ice::create_resource_provider_files( @@ -283,10 +283,10 @@ class HailStormPackerApp final : public ice::tool::ToolApp ice::Array resource_handles{ _allocator }; ice::Array resource_paths{ _allocator }; - ice::array::resize(resource_data, ice::count(resources)); - ice::array::resize(resource_metamap, ice::count(resources)); - ice::array::resize(resource_handles, ice::count(resources)); - ice::array::resize(resource_paths, ice::count(resources)); + resource_data.resize(resources.size()); + resource_metamap.resize(resources.size()); + resource_handles.resize(resources.size()); + resource_paths.resize(resources.size()); // We serialize an empty meta object ice::ConfigBuilder meta{ _allocator }; @@ -308,7 +308,7 @@ class HailStormPackerApp final : public ice::tool::ToolApp ice::Data md; ice::wait_for_result(ice::resource_meta(resource_handles[res_idx], md)); - ice::array::push_back(resource_metas, hsdata_view(md)); + resource_metas.push_back(hsdata_view(md)); ice::schedule_task( read_resource_size(resource_handles[res_idx], resource_data[res_idx], res_count), @@ -326,9 +326,9 @@ class HailStormPackerApp final : public ice::tool::ToolApp ice::current_thread::sleep(1_Tms); } - ice::array::resize(resource_paths, res_idx); - ice::array::resize(resource_data, res_idx); - ice::array::resize(resource_metamap, res_idx); + resource_paths.resize(res_idx); + resource_data.resize(res_idx); + resource_metamap.resize(res_idx); hailstorm::v1::HailstormWriteData const hsdata{ .paths = resource_paths, diff --git a/source/code/tools/hsc_packer/private/hsc_packer_app.hxx b/source/code/tools/hsc_packer/private/hsc_packer_app.hxx index bd7c4780..2b16f585 100644 --- a/source/code/tools/hsc_packer/private/hsc_packer_app.hxx +++ b/source/code/tools/hsc_packer/private/hsc_packer_app.hxx @@ -1,12 +1,12 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/source/code/tools/hsc_reader/private/hsc_reader_app.cxx b/source/code/tools/hsc_reader/private/hsc_reader_app.cxx index 8e1e110f..66d0972c 100644 --- a/source/code/tools/hsc_reader/private/hsc_reader_app.cxx +++ b/source/code/tools/hsc_reader/private/hsc_reader_app.cxx @@ -1,4 +1,4 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include "hsc_reader_app.hxx" @@ -11,16 +11,16 @@ bool ParamRange::param_parse_results(ParamRange& range, ice::Span 1) + if (results.size() > 1) { value = results[1]; } - if (ice::string::any(value)) + if (value.not_empty()) { ice::from_chars(value, value, range.count); } diff --git a/source/code/tools/hsc_reader/private/hsc_reader_app.hxx b/source/code/tools/hsc_reader/private/hsc_reader_app.hxx index ed9bf7fa..0c8268b8 100644 --- a/source/code/tools/hsc_reader/private/hsc_reader_app.hxx +++ b/source/code/tools/hsc_reader/private/hsc_reader_app.hxx @@ -1,10 +1,10 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #pragma once #include #include -#include +#include #include #include diff --git a/source/code/tools/tool_base/private/tool.cxx b/source/code/tools/tool_base/private/tool.cxx index bd790ab4..d4c7b6e7 100644 --- a/source/code/tools/tool_base/private/tool.cxx +++ b/source/code/tools/tool_base/private/tool.cxx @@ -1,10 +1,10 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include #include #include -#include +#include #include #include #include @@ -27,7 +27,7 @@ auto ice::tool::path_make_absolute(ice::native_file::FilePath path) noexcept -> ice::native_file::HeapFilePath searched_utf8_path{ global_allocator(), path }; if (ice::path::is_absolute(path) == false) { - ice::string::clear(searched_utf8_path); + searched_utf8_path.clear(); ice::path::join(searched_utf8_path, ice::tool::path_current_directory()); ice::path::join(searched_utf8_path, path); } diff --git a/source/code/tools/tool_base/private/tool_app.cxx b/source/code/tools/tool_base/private/tool_app.cxx index 83f20c56..2edb08bc 100644 --- a/source/code/tools/tool_base/private/tool_app.cxx +++ b/source/code/tools/tool_base/private/tool_app.cxx @@ -1,9 +1,9 @@ -/// Copyright 2023 - 2025, Dandielo +/// Copyright 2023 - 2026, Dandielo /// SPDX-License-Identifier: MIT #include #include -#include +#include #include namespace ice::tool