Changeset 479fbe3 for libcfa/src/collections
- Timestamp:
- Jan 14, 2024, 5:48:00 PM (7 months ago)
- Branches:
- master
- Children:
- 739495a
- Parents:
- 5ecaeca
- Location:
- libcfa/src/collections
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/collections/string.cfa
r5ecaeca r479fbe3 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 4 11:27:37 202413 // Update Count : 2 3312 // Last Modified On : Sun Jan 14 12:03:47 2024 13 // Update Count : 240 14 14 // 15 15 … … 29 29 // string RAII 30 30 31 32 void ?{}( string & s ) {33 (s.inner) { malloc() };34 ?{}( *s.inner );35 }36 37 31 // private (not in header) 38 32 static void ?{}( string & s, string_res & src, size_t start, size_t end ) { … … 41 35 } 42 36 37 void ?{}( string & s ) { 38 (s.inner) { malloc() }; 39 ?{}( *s.inner ); 40 } 41 43 42 void ?{}( string & s, const string & c ) { 44 43 (s.inner) { malloc() }; … … 50 49 } 51 50 52 void ?{}( string & s, const char * val ) { 53 (s.inner) { malloc() }; 54 ?{}( *s.inner, val ); 55 } 56 57 void ?{}( string & s, const char * buffer, size_t bsize) { 58 (s.inner) { malloc() }; 59 ?{}( *s.inner, buffer, bsize ); 51 void ?{}( string & s, const char c ) { 52 (s.inner) { malloc() }; 53 char cs[2] = { c, '\0' }; 54 ?{}( *s.inner, cs ); 55 } 56 57 void ?{}( string & s, const char * c ) { 58 (s.inner) { malloc() }; 59 ?{}( *s.inner, c ); 60 } 61 62 void ?{}( string & s, const char * c, size_t size) { 63 (s.inner) { malloc() }; 64 ?{}( *s.inner, c, size ); 60 65 } 61 66 … … 237 242 } 238 243 239 string ?*?(char c, size_t size) { 240 string ret = ""; 241 for ((size_t)size) ret += c; 242 return ret; 243 } 244 245 string ?*?(const char *s, size_t factor) { 246 string ss = s; 247 return ss * factor; 244 void ?*=?(string & s, size_t factor) { 245 s = s * factor; 246 } 247 248 string ?*?(char c, size_t factor) { 249 string ret = c; 250 return ret * factor; 251 } 252 253 string ?*?(const char * s, size_t factor) { 254 string ret = s; 255 return ret * factor; 248 256 } 249 257 -
libcfa/src/collections/string.hfa
r5ecaeca r479fbe3 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 4 11:27:35202413 // Update Count : 7512 // Last Modified On : Sun Jan 14 12:03:46 2024 13 // Update Count : 81 14 14 // 15 15 … … 33 33 // RAII, assignment 34 34 void ?{}(string & s); // empty string 35 void ?{}(string & s, const char * initial); // copy from string literal (NULL-terminated)36 void ?{}(string & s, const char * buffer, size_t bsize); // copy specific length from buffer37 38 35 void ?{}(string & s, const string & s2); 39 36 void ?{}(string & s, string & s2); 40 37 38 void ?{}(string & s, const char); 39 void ?{}(string & s, const char * c); // copy from string literal (NULL-terminated) 40 void ?{}(string & s, const char * c, size_t size); // copy specific length from buffer 41 41 42 void ?=?(string & s, const char * c); // copy assignment from literal 42 43 static inline string & strcpy(string & s, const char * c) { s = c; return s; } 44 static inline string & strncpy(string & s, const char * c, size_t n) { s = c; return s; } 43 45 void ?=?(string & s, const string & c); 44 46 static inline string & strcpy(string & s, const string c) { s = c; return s; } … … 112 114 // Repetition 113 115 string ?*?(const string & s, size_t factor); 114 string ?*?(char c, size_t size); 115 string ?*?(const char *s, size_t size); 116 void ?*=?(string & s, size_t factor); 117 string ?*?(char c, size_t factor); 118 string ?*?(const char *s, size_t factor); 116 119 117 120 // Character access
Note: See TracChangeset
for help on using the changeset viewer.