acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
scoped_string_base.h
1// Created by camilo on 2012-12-18 18:44 <3ThomasBorregaardSorensen!!
2#pragma once
3
4
5#include "scoped_string_base.h"
6#include "scoped_string_base.h"
7#include "acme/prototype/string/c_string.h"
8
9
10template < typename ITERATOR_TYPE >
11class scoped_string_base :
12 public const_string_range < ITERATOR_TYPE >
13{
14public:
15
16// union
17// {
18// ::ansi_character m_chaTempuStock[8];
19// ::wd16_character m_shaTempoStore[4];
20// ::wd32_character m_iaTempiWarehouse[2];
21// ::i64 m_llTempeMart;
22//
23// };
24
25
26 using BASE_RANGE = ::const_string_range < ITERATOR_TYPE >;
27 using RAW_CHARACTER_RANGE = typename BASE_RANGE::RAW_CHARACTER_RANGE;
28
29
30 using PRIMITIVE_SCOPED_STRING_TAG = PRIMITIVE_SCOPED_STRING_TAG_TYPE;
31
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;
40
41
42 scoped_string_base(no_initialize_t) : BASE_RANGE(no_initialize_t{}) { }
43
44 scoped_string_base(): BASE_RANGE(nullptr) { }
45
46 scoped_string_base(nullptr_t) : BASE_RANGE(nullptr) { }
47
48
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) {}
52
53
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) :
56 BASE_RANGE(no_initialize_t{})
57 {
58
59 if (::is_null(start) || end <= start)
60 {
61
62 this->set_null();
63
64 return;
65
66 }
67
68 //this->construct_owned_string( start, end, erange );
69 this->construct_string( start, end, erange );
70
71 }
72
73
74 template < character_pointer CHARACTER_POINTER >
75 scoped_string_base(CHARACTER_POINTER start) : scoped_string_base(start, ::string_safe_length(start)) { }
76
77
78 template < character_pointer CHARACTER_POINTER >
79 scoped_string_base(CHARACTER_POINTER start, character_count length) : scoped_string_base(start, start + length) { }
80
81 template < character_count length >
82 scoped_string_base(const CHARACTER (&s)[length]) :
83 BASE_RANGE(no_initialize_t{})
84 {
85
86 this->m_begin = s;
87
88 this->m_end = s + string_safe_length2(s, length);
89
90 this->m_erange = e_range_none;
91
92 this->m_pbasedata = nullptr;
93
94 }
95
96
97 template < other_primitive_character <CHARACTER> OTHER_CHARACTER, character_count length >
98 scoped_string_base(const CHARACTER(&s)[length]) :
99 BASE_RANGE(no_initialize_t{})
100 {
101
102 this->construct_owned_string(s, string_safe_length(s, length));
103
104 }
105
106
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) { }
108
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) { //this->construct_owned_string(range.m_begin, range.m_end, range.m_erange);
111 this->construct_string(range.m_begin, range.m_end, range.m_erange);
112
113 }
114
115 // template < typed_primitive_string <CHARACTER> STRING2 >
116 // scoped_string_base(const STRING2& str) : BASE_RANGE(str) { }
117 //
118 // template < other_primitive_string <CHARACTER> STRING2 >
119 // scoped_string_base(const STRING2& str) : BASE_RANGE(no_initialize_t{}) { this->construct_owned_string(str); }
120
121
122 template < has_as_string HAS_AS_STRING >
123 scoped_string_base(const HAS_AS_STRING & has_as_string) : BASE_RANGE(no_initialize_t{}) { //this->transfer_construct_owned_string(::transfer(has_as_string.as_string()));
124 this->transfer_construct_string(::transfer(has_as_string.as_string()));
125
126 }
127
128
129 template < has_get_string HAS_GET_STRING >
130 scoped_string_base(const HAS_GET_STRING & has_get_string) : BASE_RANGE(no_initialize_t{}) { //this->transfer_construct_owned_string(::transfer(has_get_string.get_string()));
131 this->transfer_construct_string(::transfer(has_get_string.get_string()));
132 }
133
134
135 // template < prototype_character SOME_CHARACTER, character_count m_sizeMaximumLength >
136 // scoped_string_base(const ::inline_string < SOME_CHARACTER, & inlinenumberstring) :
137 // BASE_RANGE(no_initialize_t{})
138 // {
139 //
140 // this->construct_owned_string(inlinenumberstring);
141 //
142 // }
143
144
145 scoped_string_base(const c::string & cstring) :
146 BASE_RANGE(no_initialize_t{})
147 {
148
149 if constexpr (sizeof(CHARACTER) == 1)
150 {
151
152 this->m_begin = cstring.m_psz;
153
154 this->m_end = this->m_begin + string_safe_length(this->m_begin);
155
156 this->m_erange = e_range_none;
157
158 this->m_pbasedata = nullptr;
159
160 }
161 else
162 {
163
164 this->construct_owned_string(cstring);
165
166 }
167
168 }
169
170
171 ITERATOR_TYPE c_str() const
172 {
173
174 if (!this->is_null_terminated())
175 {
176
177 ((scoped_string_base *)this)->make_owned_string();
178
179 }
180
181 return this->m_begin;
182
183 }
184
185
186 // template < typed_character_pointer < typename scoped_string_base < ITERATOR_TYPE >::CHARACTER > CHARACTER_POINTER >
187 // inline void construct_with_length(CHARACTER_POINTER pSrc, character_count length)
188 // {
189 //
190 // if (::is_null(pSrc) || length <= 0)
191 // {
192 //
193 // null_construct();
194 //
195 // return;
196 //
197 // }
198 //
199 // this->m_begin = pSrc;
200 //
201 // this->m_end = pSrc + length;
202 //
203 // this->m_erange = *this->m_end ? e_range_none : e_range_null_terminated;
204 //
205 // }
206 //
207 //
208 // template < other_character_pointer < typename scoped_string_base < ITERATOR_TYPE >::CHARACTER > OTHER_CHARACTER_POINTER >
209 // inline void construct_with_length(OTHER_CHARACTER_POINTER p, character_count length)
210 // {
211 //
212 // if (::is_null(p) || length <= 0)
213 // {
214 //
215 // null_construct();
216 //
217 // return;
218 //
219 // }
220 //
221 // this->construct_owned_string({ p, length });
222 //
223 // }
224
225
226 // template < typed_character_pointer < typename scoped_string_base < ITERATOR_TYPE >::CHARACTER > CHARACTER_POINTER >
227 // scoped_string_base(CHARACTER_POINTER start, CHARACTER_POINTER end) :
228 // BASE_RANGE(no_initialize_t{})
229 // {
230 //
231 // if (::is_null(start) || end <= start)
232 // {
233 //
234 // null_construct();
235 //
236 // return;
237 //
238 // }
239 //
240 // this->m_begin = start;
241 //
242 // this->m_end = end;
243 //
244 // this->m_erange = *this->m_end ? e_range_none : e_range_null_terminated;
245 //
246 // }
247 //
248 //
249 // template < other_character_pointer < typename scoped_string_base < ITERATOR_TYPE >::CHARACTER > OTHER_CHARACTER_POINTER >
250 // scoped_string_base(OTHER_CHARACTER_POINTER start, OTHER_CHARACTER_POINTER end) :
251 // scoped_string_base(start, end - start) { }
252 //
253 //
254
255
256 ~scoped_string_base()
257 {
258
259 destroy();
260
261 }
262
263
264 // void __release()
265 // {
266 //
267 // ((STRING*)this)->__release();
268 //
269 // }
270 //
271
272 void destroy()
273 {
274
275 //if (!(this->m_erange & e_range_scoped_ownership))
276 //if(::is_s)
277 {
278
279 ::base_data_defer_release(this->m_pbasedata);
280
281 //this->m_erange = e_range_none;
282
283 }
284 //else
285 //{
286
288 // Actually you are asking to destroy...
289 // ... so it should be clean/clear after...
290 // ... and reported as empty or null....
291
292 this->m_begin = nullptr;
293
294 this->m_end = nullptr;
295
296 this->m_erange = e_range_none;
297
298 //}
299
300 }
301
302
303 // scoped_string_base & _append(const scoped_string_base & scopedstr)
304 // {
305 //
306 // if (this->m_erange & e_range_scoped_ownership
307 // && ::is_set(this->m_pbasedata)
308 // {
309 //
310 // ((STRING *)this)->append(scopedstr);
311 //
312 // }
313 // else
314 // {
315 //
316 // auto data = this->data();
317 // auto size = this->size();
318 // this->m_begin = nullptr;
319 // this->m_end = nullptr;
320 // this->m_erange = e_range_none;
321 //
322 // string_concatenate(*((STRING *)this), data, size, scopedstr.data(), scopedstr.size());
323 //
324 // }
325 //
326 // return *this;
327 //
328 // }
329 //
330 //
331 // scoped_string_base & append(const scoped_string_base & scopedstr)
332 // {
333 // if (this->has_character())
334 // {
335 // //::string str(m_scopedstrLine + ::string(buf + x, i - x));
336 // //m_scopedstrLine.destroy();
337 // //m_scopedstrLine = str;
338 // this->_append(scopedstr);
339 // }
340 // else
341 // {
342 // this->assign(scopedstr);
343 // //m_scopedstrLine.destroy();
344 // //m_scopedstrLine.construct_str({buf + x, i - x});
345 // }
346 //
347 // return *this;
348 //
349 // }
350
351
352 // scoped_string_base & _append(const scoped_string_base & scopedstr)
353 // {
354 //
355 // if (this->m_erange& e_range_string)
356 // {
357 //
358 // ((STRING *)this)->append(scopedstr);
359 //
360 // }
361 // else
362 // {
363 //
364 // auto data = this->data();
365 //
366 // auto size = this->size();
367 //
368 // this->m_begin = nullptr;
369 //
370 // this->m_end = nullptr;
371 //
372 // this->m_erange = e_range_none;
373 //
374 // string_concatenate(*((STRING *)this), data, size, scopedstr.data(), scopedstr.size());
375 //
376 // }
377 //
378 // return *this;
379 //
380 // }
381
382
383 // scoped_string_base & append(const scoped_string_base & scopedstr)
384 // {
385 // if (this->has_character())
386 // {
387 // //::string str(m_scopedstrLine + ::string(buf + x, i - x));
388 // //m_scopedstrLine.destroy();
389 // //m_scopedstrLine = str;
390 // this->_append(scopedstr);
391 // }
392 // else
393 // {
394 // this->assign(scopedstr);
395 // //m_scopedstrLine.destroy();
396 // //m_scopedstrLine.construct_owned_string({buf + x, i - x});
397 // }
398 //
399 // return *this;
400 //
401 // }
402
403
404
405 // scoped_string_base & operator +=(const scoped_string_base & scopedstr)
406 // {
407 //
408 // // if (this->m_erange & e_range_scoped_ownership
409 // // && this->m_erange& e_range_string)
410 // // {
411 // //
412 // // ((STRING *)this)->append(scopedstr);
413 // //
414 // // }
415 // // else
416 // // {
417 // //
418 // // auto data = this->data();
419 // // auto size = this->size();
420 // // this->m_begin = nullptr;
421 // // this->m_end = nullptr;
422 // //
423 // // this->construct_owned_string(string_concatenate(data, size, scopedstr.data(), scopedstr.size()));
424 // //
425 // // }
426 //
427 // return this->append(scopedstr);
428 //
429 // }
430
431
432 // scoped_string_base & assign_range(const scoped_string_base & scopedstr)
433 // {
434 //
435 // if (this->m_begin == scopedstr.m_begin
436 // && this->m_end == scopedstr.m_end)
437 // {
438 //
439 // this->m_erange = scopedstr.m_erange;
440 //
441 // }
442 // else if (this->m_erange& e_range_string
443 // && !((STRING *)this)->is_shared()
444 // && scopedstr.length_in_bytes() < ((STRING *)this)->storage_size())
445 // {
446 //
447 // *((STRING *)this) = scopedstr;
448 //
449 // }
450 // else
451 // {
452 //
453 // this->m_begin = scopedstr.m_begin;
454 // this->m_end = scopedstr.m_end;
455 // this->m_erange = scopedstr.m_erange;
456 //
457 // }
458 //
459 // return *this;
460 //
461 // }
462
463
464 // scoped_string_base & assign_copy(const STRING & str)
465 // {
466 //
467 // if (this->m_erange& e_range_string)
468 // {
469 //
470 // *((STRING *)this) = str;
471 //
472 // }
473 // else
474 // {
475 //
476 // this->m_begin = nullptr;
477 // this->m_end = nullptr;
478 //
479 // construct_owned_string(str.m_begin, str.m_end, str.m_erange);
480 //
481 // }
482 //
483 // return *this;
484 //
485 // }
486
487
488 // scoped_string_base & assign(const scoped_string_base & scopedstr)
489 // {
490 //
491 // if (this->m_erange & e_range_string)
492 // {
493 //
494 // if (scopedstr.m_erange & e_range_string)
495 // {
496 //
497 // *((STRING *)this) = scopedstr;
498 //
499 // }
500 // else
501 // {
502 //
503 // this->destroy();
504 //
505 // this->construct_owned_string(scopedstr);
506 //
507 // }
508 //
509 // }
510 // else if (scopedstr.m_erange& e_range_string)
511 // {
512 //
513 //
514 // this->m_begin = nullptr;
515 //
516 // this->m_end = nullptr;
517 //
518 // this->construct_owned_string(scopedstr);
519 //
520 //
521 // }
522 // else
523 // {
524 //
525 // this->m_begin = scopedstr.m_begin;
526 //
527 // this->m_end = scopedstr.m_end;
528 //
529 // this->m_erange = scopedstr.m_erange;
530 //
531 // }
532 //
533 // return *this;
534 //
535 // }
536
537
538 // scoped_string_base & operator = (const scoped_string_base & scopedstr)
539 // {
540 //
541 // return this->assign(scopedstr);
542 //
543 // }
544
545
546 //template < character_count n >
547 //scoped_string_base(const ::i8 (&cha)[n]) :m_str(e_zero_initialize), BASE_RANGE(e_zero_initialize) { _construct1(cha); }
548 //template < typed_character_pointer < typename scoped_string_base < ITERATOR_TYPE >::CHARACTER > CHARACTER_POINTER >
549 //void construct_owned_string(ITERATOR_TYPE start, ITERATOR_TYPE end, enum_range erange = e_range_none)
550 //requires (sizeof(get_iterator_item < ITERATOR_TYPE >) == sizeof(CHARACTER))
551 //{
552
553 // auto length = end - start;
554
555 // auto lengthNew = string_safe_length(start, length);
556
557 // auto pbasedata = this->create_string_data2(lengthNew, e_range_scoped_ownership);
558
559 // auto pdata = pbasedata->data();
560
561 // this->m_begin = pdata;
562
563 // memory_transfer(pdata, start, lengthNew);
564
565 // this->_set_length(lengthNew);
566
567 //}
568
569
570 void make_owned_string()
571 {
572
573 auto pdataThis = this->m_pbasedata;
574
575 //construct_owned_string(this->m_begin, this->m_end);
576 this->construct_string(this->m_begin, this->m_end);
577
578 if (pdataThis)
579 {
580
581 ::base_data_defer_release(pdataThis);
582
583 }
584
585 }
586
587
588// template < typename SAME_ITERATOR_TYPE >
589// void construct_owned_string(SAME_ITERATOR_TYPE start, SAME_ITERATOR_TYPE end, enum_range erange = e_range_none, typename ::character_range<SAME_ITERATOR_TYPE>::BASE_DATA * pbasedata = nullptr)
590// requires(sizeof(get_iterator_item < SAME_ITERATOR_TYPE >) == sizeof(CHARACTER))
591// {
592//
593// this->construct_string(start, end, (enum_range)(erange | e_range_scoped_ownership), pbasedata);
594//
595// }
596
597//
598// template < typename OTHER_ITERATOR_TYPE >
599// void construct_owned_string(OTHER_ITERATOR_TYPE start, OTHER_ITERATOR_TYPE end, enum_range erange = e_range_none)
600// requires(sizeof(get_iterator_item < OTHER_ITERATOR_TYPE >) != sizeof(CHARACTER))
601// {
602//
603// this->construct_string(start, end, (enum_range)(erange | e_range_scoped_ownership));
604//
605// }
606
607
608 //void transfer_construct_owned_string(STRING && str)
609 void transfer_construct_string(STRING && str)
610 {
611
612 this->m_begin = str.m_begin;
613
614 this->m_end = str.m_end;
615
616// this->m_erange = (enum_range) (str.m_erange | e_range_scoped_ownership);
617 this->m_erange = str.m_erange;
618
619 this->m_pbasedata = str.m_pbasedata;
620
621 str.m_begin = nullptr;
622
623 str.m_end = nullptr;
624
625 str.m_erange = e_range_none;
626
627 str.m_pbasedata = nullptr;
628
629 }
630
631
632 // template < typename OTHER_ITERATOR_TYPE >
633 // void construct_owned_string(const ::range < OTHER_ITERATOR_TYPE > & characterrange)
634 // {
635 //
636 // create_string(*this, characterrange);
637 //
638 // this->m_erange = (enum_range) (this->m_erange | e_range_scoped_ownership);
639 //
640 // }
641
642
643 // STRING & str(const STRING& str)
644 // {
645 //
646 // this->destroy();
647 //
648 // this->construct_owned_string(str);
649 //
650 // return *(STRING*)this;
651 //
652 // }
653
654
655 // STRING & fork()
656 // {
657 //
658 // return this->str({this->m_begin, this->m_end});
659 //
660 // }
661
662
663 //template < prototype_character CHARACTER2 >
664 //void _construct1(const CHARACTER2 * psz)
665 //{
666 //
667 // if constexpr (sizeof(CHARACTER2) == sizeof(CHARACTER))
668 // {
669
670 // this->m_begin = psz;
671 // this->m_end = psz + string_safe_length(scopedstr);
672
673 // }
674 // else
675 // {
676
677 // this->str(scopedstr);
678
679 // }
680
681 //}
682
683
687
688
689 //void construct_range(const ::range < const CHARACTER* >& range)
690 //{
691
692 // this->m_begin = (ITERATOR_TYPE)range.m_begin;
693 // this->m_end = (ITERATOR_TYPE)range.m_end;
694 // this->m_erange = range.m_erange;
695
696 //}
697
698 template < other_primitive_character < CHARACTER > OTHER_CHARACTER >
699 void construct_range(const ::range < const OTHER_CHARACTER* >& range)
700 {
701
702 this->str(range);
703
704 }
705
706 STRING as_string() const;
707
708 BASE_RANGE rear_word(CHARACTER separator = ' ') const;
709 BASE_RANGE rear_prefix(CHARACTER separator = ' ') const;
710
711 //inline bool operator ==(const ::ansi_string & str) const { return this->equals((const scoped_string_base&)str); }
712 //inline bool operator ==(const ::wd16_string & str) const { return this->equals((const scoped_string_base&)str); }
713 //inline bool operator ==(const ::wd32_string & str) const { return this->equals((const scoped_string_base&)str); }
714 //inline bool operator ==(const_char_pointer psz) const { return this->equals(psz); }
715 //inline bool operator ==(const ::wd16_character * psz) const { return this->equals(psz); }
716 //inline bool operator ==(const ::wd32_character * psz) const { return this->equals(psz); }
717 //inline bool operator ==(const ::scoped_ansi_string & str) const { return this->equals((const scoped_string_base&)str); }
718 //inline bool operator ==(const ::scoped_wd16_string & str) const { return this->equals((const scoped_string_base&)str); }
719 //inline bool operator ==(const ::scoped_wd32_string & str) const { return this->equals((const scoped_string_base&)str); }
720
721
722
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 >
726 && !
727 (::std::is_base_of_v < scoped_string_base < ITERATOR_TYPE >, RANGE >
728 || ::std::is_same_v < scoped_string_base < ITERATOR_TYPE >, RANGE >))
729 {
730
731 return this->equals((const scoped_string_base&)str);
732
733 }
734
735
736 template < typename OTHER_CHARACTER >
737 bool operator ==(const ::range < const OTHER_CHARACTER* >& range) const
738 requires other_primitive_character < OTHER_CHARACTER, CHARACTER >
739 {
740
741 return this->equals((const scoped_string_base&)range);
742
743 }
744
745
746 template < prototype_character CHARACTER >
747 bool operator ==(const CHARACTER* p) const
748 {
749
750 return this->equals(p);
751
752 }
753
754 // const CHARACTER * null_terminated() const
755 // {
756 //
757 // if (!(this->m_erange & e_range_string) && (this->m_erange & e_range_null_terminated))
758 // {
759 //
760 // ((scoped_string_base *)this)->fork();
761 //
762 // }
763 //
764 // return this->m_begin;
765 //
766 // }
767
768
769 //operator const CHARACTER * () const { return this->null_terminated(); }
770
771 //const CHARACTER * c_str() const { return this->null_terminated(); }
772
773
774 ::block as_block() const { return { (::u8 *)this->begin(), this->size() * sizeof(CHARACTER) }; }
775
776
777};
778
779
780//inline block::block(const ::scoped_string & scopedstr):
781// block((iterator)scopedstr.begin(), (iterator)scopedstr.end())
782//{
783//
784//
785//}
786
787
788//template < typename ITERATOR_TYPE >
789//inline string_base < ITERATOR_TYPE >::string_base(const ::scoped_string & scopedstr)
790//{
791//
792// if (sizeof(typename scoped_string::ITEM) == sizeof(CHARACTER)
793// && (range.m_erange & e_range_string))
794// {
795//
796// this->m_begin = (ITERATOR_TYPE)range.m_begin;
797// this->m_end = (ITERATOR_TYPE)range.m_end;
798// this->m_erange = range.m_erange;
799//
800// }
801// else
802// {
803//
804// this->str(range);
805//
806// }
807//
808//}
809
810
811//template < typename ITERATOR_TYPE >
812//inline string_base < ITERATOR_TYPE >::string_base(const ::scoped_wstring & scopedstr) :
813// string_base(scopedstr.begin(), scopedstr.size())
814//{
815// construct5(scopedstr);
816//
817//}
818
819
820//template < typename ITERATOR_TYPE >
821//inline string_base < ITERATOR_TYPE > & string_base < ITERATOR_TYPE >::operator = (const scoped_ansi_string & scopedansistring)
822//{
823//
824// assign(scopedansistring.begin(), scopedansistring.end());
825//
826// return *this;
827//
828//}
829
830
831//template < typename ITERATOR_TYPE >
832//inline string_base < ITERATOR_TYPE > & string_base < ITERATOR_TYPE >::operator = (const scoped_wd16_string & scopedwd16string)
833//{
834//
835// assign(scopedwd16string.begin(), scopedwd16string.end());
836//
837// return *this;
838//
839//}
840//
841//
842//template < typename ITERATOR_TYPE >
843//inline string_base < ITERATOR_TYPE > & string_base < ITERATOR_TYPE >::operator = (const scoped_wd32_string & scopedwd32string)
844//{
845//
846// assign(scopedwd32string.begin(), scopedwd32string.end());
847//
848// return *this;
849//
850//}
851
852
853//template < typename ITERATOR_TYPE, prototype_string STRING >
854//inline string_base < ITERATOR_TYPE > operator + (const scoped_string_base < ITERATOR_TYPE > & scopedstr, const STRING & str)
855//{
856//
857// return ::transfer(::string(scopedstr) + str);
858//
859//}
860
861//template < typename ITERATOR_TYPE1, typename ITERATOR_TYPE2 >
862//inline string_base < ITERATOR_TYPE1 > operator + (const scoped_string_base < ITERATOR_TYPE1 > & scopedstr1, const scoped_string_base < ITERATOR_TYPE2 > & scopedstr2)
863//{
864//
865// return ::transfer(::string(scopedstr1) + ::string(scopedstr2));
866//
867//}
868
869
870//template < prototype_character CHARACTER1, prototype_character CHARACTER2 >
871//inline ::ansi_string operator + (const ::range < const CHARACTER1 * > & scopedstr1, const ::range < const CHARACTERE & scopedstr2)
872//{
873//
874// ::ansi_string str(scopedstr1);
875//
876// str.append(scopedstr2);
877//
878// return ::transfer(str);
879//
880//}
881
882
883//inline ::wd16_string operator + (const ::scoped_wd16_string & scopedstr1, const ::scoped_wd16_string & scopedstr2)
884//{
885//
886// ::wd16_string str(scopedstr1);
887//
888// str.append(scopedstr2);
889//
890// return ::transfer(str);
891//
892//}
893//
894//
895//inline ::wd32_string operator + (const ::scoped_wd32_string & scopedstr1, const ::scoped_wd32_string & scopedstr2)
896//{
897//
898// ::wd32_string str(scopedstr1);
899//
900// str.append(scopedstr2);
901//
902// return ::transfer(str);
903//
904//}
905
906
907
908template<prototype_character CHARACTER>
909inline ::hash32 _scoped_string_u32_hash(const ::scoped_string_base<const CHARACTER *> & scopedstr)
910{
911
912 if (scopedstr.is_empty())
913 {
914
915 return {0};
916
917 }
918
919 ::u32 uHash = 0;
920
921 auto p = scopedstr.m_begin;
922
923 while (p < scopedstr.m_end) uHash = (uHash << 5) + *(p++);
924
925 return {uHash};
926
927}
928
929
930template < >
931inline ::hash32 as_hash32 < scoped_ansi_string >(const scoped_ansi_string & scopedstr);
932
933
934template < >
935inline ::hash32 as_hash32 < scoped_wd16_string >(const scoped_wd16_string & scopedstr);
936
937
938template < >
939inline ::hash32 as_hash32 < scoped_wd32_string >(const scoped_wd32_string & scopedstr);
940
941
942
943
944#include "acme/prototype/mathematics/_string.h"
945
946
947//#ifdef __STD_FORMAT__
948
949
950template < >
951struct std::formatter<::scoped_string > :
952 public ::std::formatter< ::std::string_view >
953{
954 template < typename FormatContext >
955 auto format(const ::scoped_string& scopedstr, FormatContext & context) const {
956 return formatter<::std::string_view>::format({ scopedstr.begin(), scopedstr.end() }, context);
957 }
958};
959
960
961//#endif
962
963
964inline ::block as_block(const ::scoped_string & scopedstr)
965{
966
968
969 block.m_begin = (decltype(block.m_begin))scopedstr.m_begin;
970 block.m_end = (decltype(block.m_end))scopedstr.m_end;
971 block.m_erange = scopedstr.m_erange;
972
973 return block;
974
975}
976
977
978template < >
979inline bool EqualElements(const ::scoped_string_base < const_char_pointer > & element1, const ::scoped_string_base < const_char_pointer > & element2)
980{
981
982 return element1.equals(element2);
983
984}
985
986
987template < >
988inline bool EqualElements(const ::scoped_string_base < const wchar_t * >& element1, const ::scoped_string_base < const wchar_t* >& element2)
989{
990
991 return element1.equals(element2);
992
993}
994
995
996//
997//template < >
998//struct std::formatter<::scoped_string > :
999// public ::std::formatter< ::std::string_view >
1000//{
1001// auto format(const ::scoped_string& scopedstr, std::format_context& ctx) const {
1002// return ::std::formatter<::std::string_view>::format(::std::string_view{ scopedstr.begin(), scopedstr.end() }, ctx);
1003// }
1004//};
1005
1006
1007
Definition c_string.h:12
Definition range.h:223
Definition scoped_string_base.h:13
void construct_range(const ::range< const OTHER_CHARACTER * > &range)
Definition scoped_string_base.h:699
Definition _initial_concepts.h:462
Definition _initial_concepts.h:470
Definition _forward_declaration.h:1328
Definition block.h:46
Definition _tags.h:5