11class scoped_string_base :
12 public const_string_range < ITERATOR_TYPE >
26 using BASE_RANGE = ::const_string_range < ITERATOR_TYPE >;
27 using RAW_CHARACTER_RANGE =
typename BASE_RANGE::RAW_CHARACTER_RANGE;
32 using ITEM_POINTER = get_type_item_pointer< ITERATOR_TYPE>;
33 using ITEM = dereference < ITEM_POINTER >;
34 using CHARACTER = ITEM;
35 using this_iterator =
typename BASE_RANGE::this_iterator;
36 using iterator =
typename BASE_RANGE::iterator;
37 using const_iterator =
typename BASE_RANGE::const_iterator;
38 using STRING = ::string_base < ITERATOR_TYPE >;
39 using BASE_DATA = BASE_RANGE::BASE_DATA;
44 scoped_string_base(): BASE_RANGE(
nullptr) { }
46 scoped_string_base(nullptr_t) : BASE_RANGE(
nullptr) { }
49 template < typed_character_pointer < typename scoped_string_base < ITERATOR_TYPE >::CHARACTER > CHARACTER_POINTER >
50 scoped_string_base(CHARACTER_POINTER start, CHARACTER_POINTER end, enum_range erange = e_range_none, BASE_DATA * pbasedata =
nullptr) :
51 BASE_RANGE(start, end, erange, pbasedata) {}
54 template < other_character_pointer < typename scoped_string_base < ITERATOR_TYPE >::CHARACTER > OTHER_CHARACTER_POINTER >
55 scoped_string_base(OTHER_CHARACTER_POINTER start, OTHER_CHARACTER_POINTER end, enum_range erange = e_range_none) :
59 if (::is_null(start) || end <= start)
69 this->construct_string( start, end, erange );
74 template <
character_po
inter CHARACTER_POINTER >
75 scoped_string_base(CHARACTER_POINTER start) : scoped_string_base(start, ::string_safe_length(start)) { }
78 template <
character_po
inter CHARACTER_POINTER >
79 scoped_string_base(CHARACTER_POINTER start, character_count length) : scoped_string_base(start, start + length) { }
81 template <
character_count length >
82 scoped_string_base(
const CHARACTER (&s)[length]) :
88 this->m_end = s + string_safe_length2(s, length);
90 this->m_erange = e_range_none;
92 this->m_pbasedata =
nullptr;
97 template < other_primitive_
character <CHARACTER> OTHER_CHARACTER,
character_count length >
98 scoped_string_base(
const CHARACTER(&s)[length]) :
102 this->construct_owned_string(s, string_safe_length(s, length));
107 scoped_string_base(const ::character_range < const CHARACTER * > &
range) : scoped_string_base(
range.m_begin,
range.m_end,
range.m_erange,
range.m_pbasedata) { }
109 template < other_primitive_
character <CHARACTER> OTHER_CHARACTER >
110 scoped_string_base(const ::character_range < const OTHER_CHARACTER* > &
range) : scoped_string_base(
range.m_begin,
range.m_end,
range.m_erange) {
122 template < has_as_
string HAS_AS_STRING >
124 this->transfer_construct_string(::transfer(
has_as_string.as_string()));
129 template < has_get_
string HAS_GET_STRING >
131 this->transfer_construct_string(::transfer(
has_get_string.get_string()));
145 scoped_string_base(
const c::string & cstring) :
149 if constexpr (
sizeof(CHARACTER) == 1)
152 this->m_begin = cstring.m_psz;
154 this->m_end = this->m_begin + string_safe_length(this->m_begin);
156 this->m_erange = e_range_none;
158 this->m_pbasedata =
nullptr;
164 this->construct_owned_string(cstring);
171 ITERATOR_TYPE c_str()
const
174 if (!this->is_null_terminated())
177 ((scoped_string_base *)
this)->make_owned_string();
181 return this->m_begin;
256 ~scoped_string_base()
279 ::base_data_defer_release(this->m_pbasedata);
292 this->m_begin =
nullptr;
294 this->m_end =
nullptr;
296 this->m_erange = e_range_none;
570 void make_owned_string()
573 auto pdataThis = this->m_pbasedata;
576 this->construct_string(this->m_begin, this->m_end);
581 ::base_data_defer_release(pdataThis);
609 void transfer_construct_string(STRING && str)
612 this->m_begin = str.m_begin;
614 this->m_end = str.m_end;
617 this->m_erange = str.m_erange;
619 this->m_pbasedata = str.m_pbasedata;
621 str.m_begin =
nullptr;
625 str.m_erange = e_range_none;
627 str.m_pbasedata =
nullptr;
698 template < other_primitive_
character < CHARACTER > OTHER_CHARACTER >
706 STRING as_string()
const;
708 BASE_RANGE rear_word(
CHARACTER separator =
' ')
const;
709 BASE_RANGE rear_prefix(
CHARACTER separator =
' ')
const;
723 template <
typename RANGE >
724 bool operator ==(
const RANGE & str)
const requires
725 (::std::is_base_of_v < ::range < const typename scoped_string_base < ITERATOR_TYPE >::CHARACTER* >, RANGE >
727 (::std::is_base_of_v < scoped_string_base < ITERATOR_TYPE >, RANGE >
728 || ::std::is_same_v < scoped_string_base < ITERATOR_TYPE >, RANGE >))
736 template <
typename OTHER_CHARACTER >
737 bool operator ==(const ::range < const OTHER_CHARACTER* >& range)
const
738 requires other_primitive_character < OTHER_CHARACTER, CHARACTER >
741 return this->equals((
const scoped_string_base&)range);
746 template < prototype_
character CHARACTER >
747 bool operator ==(
const CHARACTER* p)
const
750 return this->equals(p);
774 ::block as_block()
const {
return { (::u8 *)this->begin(), this->size() *
sizeof(CHARACTER) }; }