5#include "string_range.h"
8template<
typename ITERATOR_TYPE>
9class mutable_string_range :
12public ::const_string_range<ITERATOR_TYPE> {
18 using BASE_RANGE = ::const_string_range<ITERATOR_TYPE>;
20 using THIS_RANGE = ::mutable_string_range<ITERATOR_TYPE>;
22 using STRING_RANGE = ::string_range < BASE_RANGE >;
24 using ITEM_POINTER = get_type_item_pointer<ITERATOR_TYPE>;
25 using ITEM = non_const<dereference<ITEM_POINTER> >;
26 using CHARACTER = ITEM;
29 using this_iterator =
typename BASE_RANGE::this_iterator;
30 using iterator =
typename BASE_RANGE::iterator;
31 using const_iterator =
typename BASE_RANGE::const_iterator;
36 using THIS_RAW_RANGE =
typename BASE_RANGE::THIS_RAW_RANGE;
37 using RAW_RANGE =
typename BASE_RANGE::RAW_RANGE;
38 using CONST_RAW_RANGE =
typename BASE_RANGE::CONST_RAW_RANGE;
47 using ARG_ITEM =
typename BASE_RANGE::ARG_ITEM;
50 template<::std::
size_t count>
51 constexpr mutable_string_range(
const ITEM(&array)[count]) : BASE_RANGE(array, array[count - 1] == 0 ? count - 1 : count) {}
53 template<prototype_
integral INTEGRAL>
54 constexpr mutable_string_range(const_iterator begin, INTEGRAL count) : BASE_RANGE((this_iterator) begin,
55 (this_iterator) (begin + count)) {}
59 mutable_string_range(nullptr_t) : BASE_RANGE(
nullptr) {}
61 mutable_string_range() {}
63 template<typed_range<iterator> RANGE>
64 explicit mutable_string_range(
const RANGE &
range) : BASE_RANGE(
range) {}
66 template<typed_range<const_iterator> RANGE>
67 explicit mutable_string_range(
const RANGE &
range) : BASE_RANGE(
range) {}
69 mutable_string_range(THIS_RANGE &
range) : BASE_RANGE(
range) {}
71 mutable_string_range(THIS_RANGE &&
range) : BASE_RANGE(::transfer(
range)) {}
73 mutable_string_range(this_iterator begin, this_iterator end) : BASE_RANGE(begin, end) {}
75 explicit mutable_string_range(const ::block &block);
77 explicit mutable_string_range(ITERATOR_TYPE psz) : STRING_RANGE(psz, 0, string_safe_length(psz)) {}
79 mutable_string_range(ITERATOR_TYPE psz, character_count len) : STRING_RANGE(psz, 0, len) {}
83 mutable_string_range(ITERATOR_TYPE psz, character_count start, character_count count) : STRING_RANGE(
84 ::_start_count_string_range(psz, start, count)) {}
95 void escape_copy(::i8 escape, const ::const_ansi_range & rangeSource);
117template<prototype_
character CHARACTER>
119_unicode_find_first_character_in(const ::range<CHARACTER> &
block, const ::range<CHARACTER> &blockBlock)
noexcept {
121 auto p =
block.data();
123 auto pEnd = p +
block.size();
125 auto pBlock = blockBlock.data();
127 auto pBlockEnd = pBlock + blockBlock.size();
135 auto pBlockScan = pBlock;
137 auto index = unicode_index_length(p, len1);
141 if (index == unicode_index_length(pBlockScan, len2)) {
149 }
while (pBlockScan < pBlockEnd);
160template<prototype_
character CHARACTER>
162unicode_find_first_character_in(const ::range<CHARACTER> &
block, const ::range<CHARACTER> &blockBlock)
noexcept {
166 if (_string_find_first_character_in_prefix(p,
block, blockBlock)) {
172 return _unicode_find_first_character_in(
block, blockBlock);
177template<prototype_
character CHARACTER>
179_unicode_rear_find_first_character_in(const ::range<CHARACTER> &
block, const ::range<CHARACTER> &blockBlock)
noexcept {
181 auto p =
block.data();
183 auto pEnd = p +
block.size();
185 auto pBlock = blockBlock.data();
187 auto pBlockEnd = pBlock + blockBlock.size();
195 auto pBlockScan = pBlock;
197 auto pPrior = unicode_prior(pEnd, p);
199 auto index = unicode_index(pPrior);
203 if (index == unicode_index_length(pBlockScan, len2)) {
211 }
while (pBlockScan < pBlockEnd);
222template<prototype_
character CHARACTER>
224unicode_rear_find_first_character_in(const ::range<CHARACTER> &
block, const ::range<CHARACTER> &blockBlock)
noexcept {
228 if (_string_rear_find_first_character_in_prefix(p,
block, blockBlock)) {
234 return _unicode_rear_find_first_character_in(
block, blockBlock);
244template<prototype_
character CHARACTER>
247 if (
range.is_empty()) {
255 while (
range.m_begin <
range.m_end) uHash = (uHash << 5) + *(
range.m_begin++);
286template<prototype_
character CHARACTER>
287constexpr ::character_range<const CHARACTER *> _string_range(
const CHARACTER *psz) {
289 return {psz, psz + string_safe_length(psz)};
294template<prototype_
character CHARACTER>
295constexpr ::character_range<const CHARACTER *>
296_start_count_string_range(
const CHARACTER *psz, memsize start, memsize count) {
298 auto pend = psz + string_safe_length(psz);
301 ::clipped_add(psz, start, psz, pend),
302 ((count >= 0) ? ::clipped_add(psz, start + count, psz, pend) :
303 ::clipped_add(pend, count, psz, pend))};
310template <
typename ITERATOR_TYPE >
311template < prototype_
integral START, prototype_
integral COUNT>
312inline typename const_string_range < ITERATOR_TYPE > ::STRING_RANGE const_string_range < ITERATOR_TYPE > ::operator()(START start, COUNT count)
const {
316 auto sizeThis = this->size();
318 auto end = minimum(count < 0 ? sizeThis + count + 1 : start + count, sizeThis);
320 return start == 0 && end == sizeThis
322 *(string_range < ITERATOR_TYPE >*)
this :
325 this->m_begin + minimum(start, sizeThis),
353template <
typename ITERATOR_TYPE >
354template < prototype_
integral START >
355inline typename const_string_range < ITERATOR_TYPE > ::STRING_RANGE const_string_range < ITERATOR_TYPE > ::operator()(START start)
const {
357 return STRING_RANGE(this->begin() + start, this->end());
362template <
typename ITERATOR_TYPE >
363inline typename const_string_range < ITERATOR_TYPE > ::STRING_RANGE const_string_range < ITERATOR_TYPE > ::operator()()
const {
365 return STRING_RANGE(*
this);
Definition mutable_string_range.h:12
void escape_copy(::i8 escape, const ::const_ansi_range &rangeSource)
Definition _impl.h:1890
Definition scoped_string_base.h:13