Changeset 06280ad
- Timestamp:
- Jan 16, 2024, 10:20:33 PM (11 months ago)
- Branches:
- master
- Children:
- e891349
- Parents:
- 38951c31
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/collections/string_res.cfa
r38951c31 r06280ad 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jan 2 13:20:27 202413 // Update Count : 3 412 // Last Modified On : Tue Jan 16 22:19:27 2024 13 // Update Count : 35 14 14 // 15 15 … … 180 180 181 181 size_t DEBUG_string_bytes_avail_until_gc( VbyteHeap * heap ) { 182 return ((char *)heap->ExtVbyte) - heap->EndVbyte;182 return ((char *)heap->ExtVbyte) - heap->EndVbyte; 183 183 } 184 184 … … 229 229 230 230 // rest of heap is available to read into 231 int lenReadable = (char *)temp.Handle.ulink->ExtVbyte - temp.Handle.ulink->EndVbyte;231 int lenReadable = (char *)temp.Handle.ulink->ExtVbyte - temp.Handle.ulink->EndVbyte; 232 232 assert (lenReadable >= 2); 233 233 … … 315 315 } 316 316 317 static void eagerCopyCtorHelper(string_res & s, const char * rhs, size_t rhslnth) with(s) {317 static void eagerCopyCtorHelper(string_res & s, const char * rhs, size_t rhslnth) with(s) { 318 318 if( ambient_string_sharectx->activeHeap ) { 319 319 (Handle){ * ambient_string_sharectx->activeHeap }; … … 331 331 332 332 // Constructor from a raw buffer and size 333 void ?{}(string_res & s, const char * rhs, size_t rhslnth) with(s) {333 void ?{}(string_res & s, const char * rhs, size_t rhslnth) with(s) { 334 334 eagerCopyCtorHelper(s, rhs, rhslnth); 335 335 } 336 336 337 337 // private ctor (not in header): use specified heap (ignore ambient) and copy chars in 338 void ?{}( string_res & s, VbyteHeap & heap, const char * rhs, size_t rhslnth ) with(s) {338 void ?{}( string_res & s, VbyteHeap & heap, const char * rhs, size_t rhslnth ) with(s) { 339 339 (Handle){ heap }; 340 340 Handle.s = VbyteAlloc(*Handle.ulink, rhslnth); … … 479 479 } 480 480 481 static string_res & assign_(string_res & s, const char * buffer, size_t bsize, const string_res & valSrc) {481 static string_res & assign_(string_res & s, const char * buffer, size_t bsize, const string_res & valSrc) { 482 482 483 483 string_res * shareEditSetStartPeer; … … 563 563 } 564 564 565 string_res & assign(string_res & s, const char * buffer, size_t bsize) {565 string_res & assign(string_res & s, const char * buffer, size_t bsize) { 566 566 return assign_(s, buffer, bsize, *0p); 567 567 } … … 668 668 bool ?<? (const string_res & s1, const string_res & s2) { return strcmp(s1, s2) < 0; } 669 669 670 int strcmp (const string_res & s1, const char * s2) {670 int strcmp (const string_res & s1, const char * s2) { 671 671 string_res s2x = s2; 672 672 return strcmp(s1, s2x); 673 673 } 674 674 675 bool ?==?(const string_res & s1, const char * s2) { return strcmp(s1, s2) == 0; }676 bool ?!=?(const string_res & s1, const char * s2) { return strcmp(s1, s2) != 0; }677 bool ?>? (const string_res & s1, const char * s2) { return strcmp(s1, s2) > 0; }678 bool ?>=?(const string_res & s1, const char * s2) { return strcmp(s1, s2) >= 0; }679 bool ?<=?(const string_res & s1, const char * s2) { return strcmp(s1, s2) <= 0; }680 bool ?<? (const string_res & s1, const char * s2) { return strcmp(s1, s2) < 0; }681 682 int strcmp (const char * s1, const string_res & s2) {675 bool ?==?(const string_res & s1, const char * s2) { return strcmp(s1, s2) == 0; } 676 bool ?!=?(const string_res & s1, const char * s2) { return strcmp(s1, s2) != 0; } 677 bool ?>? (const string_res & s1, const char * s2) { return strcmp(s1, s2) > 0; } 678 bool ?>=?(const string_res & s1, const char * s2) { return strcmp(s1, s2) >= 0; } 679 bool ?<=?(const string_res & s1, const char * s2) { return strcmp(s1, s2) <= 0; } 680 bool ?<? (const string_res & s1, const char * s2) { return strcmp(s1, s2) < 0; } 681 682 int strcmp (const char * s1, const string_res & s2) { 683 683 string_res s1x = s1; 684 684 return strcmp(s1x, s2); 685 685 } 686 686 687 bool ?==?(const char * s1, const string_res & s2) { return strcmp(s1, s2) == 0; }688 bool ?!=?(const char * s1, const string_res & s2) { return strcmp(s1, s2) != 0; }689 bool ?>? (const char * s1, const string_res & s2) { return strcmp(s1, s2) > 0; }690 bool ?>=?(const char * s1, const string_res & s2) { return strcmp(s1, s2) >= 0; }691 bool ?<=?(const char * s1, const string_res & s2) { return strcmp(s1, s2) <= 0; }692 bool ?<? (const char * s1, const string_res & s2) { return strcmp(s1, s2) < 0; }687 bool ?==?(const char * s1, const string_res & s2) { return strcmp(s1, s2) == 0; } 688 bool ?!=?(const char * s1, const string_res & s2) { return strcmp(s1, s2) != 0; } 689 bool ?>? (const char * s1, const string_res & s2) { return strcmp(s1, s2) > 0; } 690 bool ?>=?(const char * s1, const string_res & s2) { return strcmp(s1, s2) >= 0; } 691 bool ?<=?(const char * s1, const string_res & s2) { return strcmp(s1, s2) <= 0; } 692 bool ?<? (const char * s1, const string_res & s2) { return strcmp(s1, s2) < 0; } 693 693 694 694 … … 727 727 } 728 728 729 int find(const string_res & s, const char * search) {729 int find(const string_res & s, const char * search) { 730 730 return findFrom(s, 0, search); 731 731 } 732 int findFrom(const string_res & s, size_t fromPos, const char * search) {732 int findFrom(const string_res & s, size_t fromPos, const char * search) { 733 733 return findFrom(s, fromPos, search, strlen(search)); 734 734 } 735 735 736 int find(const string_res & s, const char * search, size_t searchsize) {736 int find(const string_res & s, const char * search, size_t searchsize) { 737 737 return findFrom(s, 0, search, searchsize); 738 738 } 739 739 740 int findFrom(const string_res & s, size_t fromPos, const char * search, size_t searchsize) {740 int findFrom(const string_res & s, size_t fromPos, const char * search, size_t searchsize) { 741 741 742 742 /* Remaining implementations essentially ported from Sunjay's work */ … … 779 779 } 780 780 781 bool includes(const string_res & s, const char * search) {781 bool includes(const string_res & s, const char * search) { 782 782 return includes(s, search, strlen(search)); 783 783 } 784 784 785 bool includes(const string_res & s, const char * search, size_t searchsize) {785 bool includes(const string_res & s, const char * search, size_t searchsize) { 786 786 return find(s, search, searchsize) < s.Handle.lnth; 787 787 } … … 791 791 } 792 792 793 bool startsWith(const string_res & s, const char * prefix) {793 bool startsWith(const string_res & s, const char * prefix) { 794 794 return startsWith(s, prefix, strlen(prefix)); 795 795 } 796 796 797 bool startsWith(const string_res & s, const char * prefix, size_t prefixsize) {797 bool startsWith(const string_res & s, const char * prefix, size_t prefixsize) { 798 798 if (s.Handle.lnth < prefixsize) { 799 799 return false; … … 806 806 } 807 807 808 bool endsWith(const string_res & s, const char * suffix) {808 bool endsWith(const string_res & s, const char * suffix) { 809 809 return endsWith(s, suffix, strlen(suffix)); 810 810 } 811 811 812 bool endsWith(const string_res & s, const char * suffix, size_t suffixsize) {812 bool endsWith(const string_res & s, const char * suffix, size_t suffixsize) { 813 813 if (s.Handle.lnth < suffixsize) { 814 814 return false;
Note: See TracChangeset
for help on using the changeset viewer.