Changeset e8b3717 for libcfa/src/collections
- Timestamp:
- Jan 18, 2024, 10:17:21 PM (7 months ago)
- Branches:
- master
- Children:
- f988834
- Parents:
- 906d8fa
- Location:
- libcfa/src/collections
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/collections/string.cfa
r906d8fa re8b3717 30 30 31 31 // private (not in header) 32 static void ?{}( string & s, string_res & src, size_t start, size_t end) {33 (s.inner) { malloc() }; 34 ?{}( *s.inner, src, SHARE_EDITS, start, end);32 static void ?{}( string & s, string_res & src, size_t start, size_t len ) { 33 (s.inner) { malloc() }; 34 ?{}( *s.inner, src, SHARE_EDITS, start, len ); 35 35 } 36 36 … … 161 161 // Slicing 162 162 163 string ?()( string & s, size_t start, size_t end) {164 string ret = { *s.inner, start, end};163 string ?()( string & s, size_t start, size_t len ) { 164 string ret = { *s.inner, start, len }; 165 165 return ret`shareEdits; 166 166 } 167 167 168 168 string ?()( string & s, size_t start ) { 169 string ret = { *s.inner, start, size( s ) };169 string ret = { *s.inner, start, size( s ) - start }; 170 170 return ret`shareEdits; 171 171 } … … 286 286 287 287 string ?[?](string & s, size_t index) { 288 string ret = { *s.inner, index, index +1 };288 string ret = { *s.inner, index, 1 }; 289 289 return ret`shareEdits; 290 290 } -
libcfa/src/collections/string.hfa
r906d8fa re8b3717 162 162 163 163 // Slicing 164 string ?()( string & s, size_t start, size_t end); // TODO const?164 string ?()( string & s, size_t start, size_t len ); // TODO const? 165 165 string ?()( string & s, size_t start); 166 166 -
libcfa/src/collections/string_res.cfa
r906d8fa re8b3717 346 346 } 347 347 348 348 349 // General copy constructor 349 void ?{}(string_res & s, const string_res & s2, StrResInitMode mode, size_t start, size_t end ) { 350 350 void ?{}(string_res & s, const string_res & s2, StrResInitMode mode, size_t start, size_t len ) { 351 352 size_t end = start + len; 351 353 verify( start <= end && end <= s2.Handle.lnth ); 352 354 … … 611 613 612 614 void assignAt(const string_res & s, size_t index, char val) { 613 string_res editZone = { s, SHARE_EDITS, index, index+1 }; 615 // caution: not tested (not reachable by string-api-coverage interface) 616 // equivalent form at string level is `s[index] = val`, 617 // which uses the overload that returns a length-1 string 618 string_res editZone = { s, SHARE_EDITS, index, 1 }; 614 619 assign(editZone, &val, 1); 615 620 } … … 656 661 657 662 void ?*=?(string_res & s, size_t factor) { 658 string_res s2 = { s, COPY_VALUE , 0, size(s)};663 string_res s2 = { s, COPY_VALUE }; 659 664 s = ""; 660 665 for (factor) s += s2; -
libcfa/src/collections/string_res.hfa
r906d8fa re8b3717 87 87 88 88 enum StrResInitMode { COPY_VALUE, SHARE_EDITS }; 89 void ?{}(string_res & s, const string_res & src, StrResInitMode, size_t start, size_t end);89 void ?{}(string_res & s, const string_res & src, StrResInitMode, size_t start, size_t len ); 90 90 static inline void ?{}(string_res & s, const string_res & src, StrResInitMode mode ) { 91 91 ?{}( s, src, mode, 0, size(src));
Note: See TracChangeset
for help on using the changeset viewer.