11 using ice::concepts::StringType;
15 template<StringType Self>
16 constexpr bool is_empty(
this Self
const& self)
noexcept
18 return self.size() == 0;
21 template<StringType Self>
22 constexpr bool not_empty(
this Self
const& self)
noexcept
24 return self.size() > 0;
27 template<StringType Self>
28 constexpr auto front(
this Self
const& self)
noexcept ->
typename Self::CharType
30 return self.data()[0];
33 template<StringType Self>
34 constexpr auto back(
this Self
const& self)
noexcept ->
typename Self::CharType
36 return self.data()[self.size().native() - 1];
39 template<StringType Self>
42 )
noexcept ->
typename Self::StringType
52 return { self.data() + pos, size - pos };
56 return { self.data() + pos, std::min(len, size - pos) };
60 template<StringType Self>
63 )
noexcept ->
typename Self::StringType
65 return self.substr(ref.offset, ref.size);
68 template<StringType Self>
69 constexpr auto starts_with(
this Self
const& self, StringType
auto prefix)
noexcept
71 return self.substr(0, prefix.size()) ==
typename Self::StringType{ prefix };
74 template<StringType Self>
76 this Self
const& self,
77 typename Self::CharType character_value,
81 auto const* it = self.cbegin() + start;
82 auto const*
const beg = it;
83 auto const*
const end = self.cend();
85 while (it <
end && *it != character_value)
93 template<StringType Self>
95 this Self
const& self,
96 typename Self::StringType character_values,
100 auto const* it = self.cbegin() + start;
101 auto const*
const beg = it;
102 auto const*
const it_end = self.cend();
104 while (it < it_end && character_values.find_first_of(*it) ==
nindex_none)
112 template<StringType Self>
114 this Self
const& self,
115 typename Self::CharType character_value,
119 auto it = self.crbegin();
120 auto const it_end = self.crend();
122 while (it != it_end && start > 0)
128 while (it != it_end && *it != character_value)
136 template<StringType Self>
138 this Self
const& self,
139 typename Self::StringType character_values,
143 auto it = self.crbegin();
144 auto const it_end = self.crend();
146 while (it != it_end && start > 0)
152 while (it != it_end && character_values.find_first_of(*it) ==
nindex_none)
160 template<StringType Self>
162 this Self
const& self,
163 typename Self::CharType character_value,
167 auto const* it = self.cbegin() + start_idx;
168 auto const*
const beg = it;
169 auto const*
const end = self.cend();
171 while (it <
end && *it == character_value)
179 template<StringType Self>
181 this Self
const& self,
182 typename Self::StringType character_values,
186 auto const* it = self.cbegin() + start_idx;
187 auto const*
const beg = it;
188 auto const*
const it_end = self.cend();
190 while (it < it_end && character_values.find_first_of(*it) !=
ice::nindex_none)
198 template<StringType Self>
200 this Self
const& self,
201 typename Self::CharType character_value,
205 auto it = self.crbegin();
206 auto const end = self.crend();
208 while (it !=
end && start_idx > 0)
214 while (it !=
end && *it == character_value)
222 template<StringType Self>
224 this Self
const& self,
225 typename Self::StringType character_values,
229 auto it = self.crbegin();
230 auto const it_end = self.crend();
232 while (it != it_end && start_idx > 0)
238 while (it != it_end && character_values.find_first_of(*it) !=
ice::nindex_none)
248 template<StringType Self>
249 constexpr auto cbegin(
this Self
const& self)
noexcept ->
typename Self::ConstIterator
254 template<StringType Self>
255 constexpr auto cend(
this Self
const& self)
noexcept ->
typename Self::ConstIterator
257 return self.data() + self.size();
260 template<StringType Self>
261 constexpr auto crbegin(
this Self
const& self)
noexcept ->
typename Self::ConstReverseIterator
263 return typename Self::ConstReverseIterator{ self.data() + self.size() };
266 template<StringType Self>
267 constexpr auto crend(
this Self
const& self)
noexcept ->
typename Self::ConstReverseIterator
269 return typename Self::ConstReverseIterator{ self.data() };
272 template<StringType Self>
273 constexpr auto begin(
this Self
const& self)
noexcept ->
typename Self::ConstIterator
275 return self.cbegin();
278 template<StringType Self>
279 constexpr auto end(
this Self
const& self)
noexcept ->
typename Self::ConstIterator
284 template<StringType Self>
285 constexpr auto rbegin(
this Self
const& self)
noexcept ->
typename Self::ConstReverseIterator
287 return self.crbegin();
290 template<StringType Self>
291 constexpr auto rend(
this Self
const& self)
noexcept ->
typename Self::ConstReverseIterator
298 template<StringType Self>
301 return self.data()[index.native()];
304 template<StringType Self>
305 constexpr bool operator==(
this Self
const& self,
typename Self::StringType
const& other)
noexcept
308 if (size == other.size())
310 typename Self::ValueType
const* self_data = self.data();
311 typename Self::ValueType
const* other_data = other.data();
314 while (idx < size && self_data[idx] == other_data[idx])
325 template<StringType Self>
Definition editable_operations.hxx:9
SPDX-License-Identifier: MIT.
Definition array.hxx:12
std::uint64_t u64
Definition types.hxx:27
constexpr ice::meminfo meminfo_of
Definition mem_info.hxx:18
static constexpr ice::ncount_invalid_t ncount_none
Definition ncount.hxx:60
static constexpr ice::nindex_invalid_t nindex_none
Definition nindex.hxx:56
Definition mem_size_types.hxx:59
ice::detail::nvalue_base_utype base_type
Definition nvalue.hxx:75
Holds 'offset' and 'size' fields (u32) to access data stored in a buffer-like object.
Definition ref.hxx:12
Definition readonly_operations.hxx:14
constexpr bool is_empty(this Self const &self) noexcept
Definition readonly_operations.hxx:16
constexpr auto front(this Self const &self) noexcept -> typename Self::CharType
Definition readonly_operations.hxx:28
constexpr auto meminfo(this Self const &self) noexcept -> ice::meminfo
Definition readonly_operations.hxx:326
constexpr auto crend(this Self const &self) noexcept -> typename Self::ConstReverseIterator
Definition readonly_operations.hxx:267
constexpr auto find_first_of(this Self const &self, typename Self::StringType character_values, ice::nindex start=0) noexcept -> ice::nindex
Definition readonly_operations.hxx:94
constexpr auto find_last_of(this Self const &self, typename Self::StringType character_values, ice::nindex start=0) noexcept -> ice::nindex
Definition readonly_operations.hxx:137
constexpr auto end(this Self const &self) noexcept -> typename Self::ConstIterator
Definition readonly_operations.hxx:279
constexpr auto operator[](this Self const &self, ice::nindex index) noexcept -> typename Self::ValueType
Definition readonly_operations.hxx:299
constexpr auto find_first_not_of(this Self const &self, typename Self::CharType character_value, ice::nindex start_idx=0) noexcept -> ice::nindex
Definition readonly_operations.hxx:161
constexpr bool not_empty(this Self const &self) noexcept
Definition readonly_operations.hxx:22
constexpr auto find_first_of(this Self const &self, typename Self::CharType character_value, ice::nindex start=0) noexcept -> ice::nindex
Definition readonly_operations.hxx:75
constexpr auto find_last_of(this Self const &self, typename Self::CharType character_value, ice::nindex start=0) noexcept -> ice::nindex
Definition readonly_operations.hxx:113
constexpr auto begin(this Self const &self) noexcept -> typename Self::ConstIterator
Definition readonly_operations.hxx:273
constexpr auto substr(this Self const &self, ice::ref32 ref) noexcept -> typename Self::StringType
Definition readonly_operations.hxx:61
constexpr auto find_first_not_of(this Self const &self, typename Self::StringType character_values, ice::nindex start_idx=0) noexcept -> ice::nindex
Definition readonly_operations.hxx:180
constexpr auto rbegin(this Self const &self) noexcept -> typename Self::ConstReverseIterator
Definition readonly_operations.hxx:285
constexpr auto crbegin(this Self const &self) noexcept -> typename Self::ConstReverseIterator
Definition readonly_operations.hxx:261
constexpr auto find_last_not_of(this Self const &self, typename Self::StringType character_values, ice::nindex start_idx=0) noexcept -> ice::nindex
Definition readonly_operations.hxx:223
constexpr auto find_last_not_of(this Self const &self, typename Self::CharType character_value, ice::nindex start_idx=0) noexcept -> ice::nindex
Definition readonly_operations.hxx:199
constexpr auto starts_with(this Self const &self, StringType auto prefix) noexcept
Definition readonly_operations.hxx:69
constexpr auto back(this Self const &self) noexcept -> typename Self::CharType
Definition readonly_operations.hxx:34
constexpr bool operator==(this Self const &self, typename Self::StringType const &other) noexcept
Definition readonly_operations.hxx:305
constexpr auto cend(this Self const &self) noexcept -> typename Self::ConstIterator
Definition readonly_operations.hxx:255
constexpr auto substr(this Self const &self, ice::nindex pos, ice::ncount len={}) noexcept -> typename Self::StringType
Definition readonly_operations.hxx:40
constexpr auto cbegin(this Self const &self) noexcept -> typename Self::ConstIterator
Definition readonly_operations.hxx:249
constexpr auto rend(this Self const &self) noexcept -> typename Self::ConstReverseIterator
Definition readonly_operations.hxx:291