Changeset 6264087 for libcfa/src/containers/string.cfa
- Timestamp:
- Aug 14, 2023, 9:29:40 PM (15 months ago)
- Branches:
- master
- Children:
- 329487c
- Parents:
- b5e725a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/containers/string.cfa
rb5e725a r6264087 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S at Aug 12 15:24:18 202313 // Update Count : 612 // Last Modified On : Sun Aug 13 22:50:08 2023 13 // Update Count : 7 14 14 // 15 15 … … 55 55 } 56 56 57 void ?{}( string & this, const char * buffer, size_t bsize) {57 void ?{}( string & this, const char * buffer, size_t bsize) { 58 58 (this.inner) { malloc() }; 59 59 ?{}( *this.inner, buffer, bsize ); … … 110 110 } 111 111 112 ifstream & ?|?(ifstream & in, string &this) {112 ifstream & ?|?(ifstream & in, string & this) { 113 113 return in | (*this.inner); // read to internal string_res 114 114 } 115 115 116 void ?|?( ifstream & in, string & this ) { 117 (ifstream &)(in | this); ends( in ); 118 } 116 119 117 120 //////////////////////////////////////////////////////// … … 131 134 // Comparison 132 135 133 bool ?==?(const string & s, const string &other) {136 bool ?==?(const string & s, const string & other) { 134 137 return *s.inner == *other.inner; 135 138 } 136 139 137 bool ?!=?(const string & s, const string &other) {140 bool ?!=?(const string & s, const string & other) { 138 141 return *s.inner != *other.inner; 139 142 } 140 143 141 bool ?==?(const string & s, const char* other) {144 bool ?==?(const string & s, const char * other) { 142 145 return *s.inner == other; 143 146 } 144 147 145 bool ?!=?(const string & s, const char* other) {148 bool ?!=?(const string & s, const char * other) { 146 149 return *s.inner != other; 147 150 } … … 150 153 // Getter 151 154 152 size_t size(const string & s) {155 size_t size(const string & s) { 153 156 return size( * s.inner ); 154 157 } … … 157 160 // Concatenation 158 161 159 void ?+=?(string & s, char other) {162 void ?+=?(string & s, char other) { 160 163 (*s.inner) += other; 161 164 } 162 165 163 void ?+=?(string & s, const string &s2) {166 void ?+=?(string & s, const string & s2) { 164 167 (*s.inner) += (*s2.inner); 165 168 } 166 169 167 void ?+=?(string & s, const char* other) {170 void ?+=?(string & s, const char * other) { 168 171 (*s.inner) += other; 169 172 } 170 173 171 string ?+?(const string & s, char other) {174 string ?+?(const string & s, char other) { 172 175 string ret = s; 173 176 ret += other; … … 175 178 } 176 179 177 string ?+?(const string & s, const string &s2) {180 string ?+?(const string & s, const string & s2) { 178 181 string ret = s; 179 182 ret += s2; … … 181 184 } 182 185 183 string ?+?(const char * s1, const char* s2) {186 string ?+?(const char * s1, const char * s2) { 184 187 string ret = s1; 185 188 ret += s2; … … 187 190 } 188 191 189 string ?+?(const string & s, const char* other) {192 string ?+?(const string & s, const char * other) { 190 193 string ret = s; 191 194 ret += other; … … 196 199 // Repetition 197 200 198 string ?*?(const string & s, size_t factor) {201 string ?*?(const string & s, size_t factor) { 199 202 string ret = ""; 200 203 for (factor) ret += s; … … 216 219 // Character access 217 220 218 char ?[?](const string & s, size_t index) {221 char ?[?](const string & s, size_t index) { 219 222 return (*s.inner)[index]; 220 223 } 221 224 222 string ?[?](string & s, size_t index) {225 string ?[?](string & s, size_t index) { 223 226 string ret = { *s.inner, index, index + 1 }; 224 227 return ret`shareEdits; … … 228 231 // Search 229 232 230 bool contains(const string & s, char ch) {233 bool contains(const string & s, char ch) { 231 234 return contains( *s.inner, ch ); 232 235 } 233 236 234 int find(const string & s, char search) {237 int find(const string & s, char search) { 235 238 return find( *s.inner, search ); 236 239 } 237 240 238 int find(const string & s, const string &search) {241 int find(const string & s, const string & search) { 239 242 return find( *s.inner, *search.inner ); 240 243 } 241 244 242 int find(const string & s, const char* search) {245 int find(const string & s, const char * search) { 243 246 return find( *s.inner, search); 244 247 } 245 248 246 int find(const string & s, const char* search, size_t searchsize) {249 int find(const string & s, const char * search, size_t searchsize) { 247 250 return find( *s.inner, search, searchsize); 248 251 } 249 252 250 int findFrom(const string & s, size_t fromPos, char search) {253 int findFrom(const string & s, size_t fromPos, char search) { 251 254 return findFrom( *s.inner, fromPos, search ); 252 255 } 253 256 254 int findFrom(const string & s, size_t fromPos, const string &search) {257 int findFrom(const string & s, size_t fromPos, const string & search) { 255 258 return findFrom( *s.inner, fromPos, *search.inner ); 256 259 } 257 260 258 int findFrom(const string & s, size_t fromPos, const char* search) {261 int findFrom(const string & s, size_t fromPos, const char * search) { 259 262 return findFrom( *s.inner, fromPos, search ); 260 263 } 261 264 262 int findFrom(const string & s, size_t fromPos, const char* search, size_t searchsize) {265 int findFrom(const string & s, size_t fromPos, const char * search, size_t searchsize) { 263 266 return findFrom( *s.inner, fromPos, search, searchsize ); 264 267 } 265 268 266 bool includes(const string & s, const string &search) {269 bool includes(const string & s, const string & search) { 267 270 return includes( *s.inner, *search.inner ); 268 271 } 269 272 270 bool includes(const string & s, const char* search) {273 bool includes(const string & s, const char * search) { 271 274 return includes( *s.inner, search ); 272 275 } 273 276 274 bool includes(const string & s, const char* search, size_t searchsize) {277 bool includes(const string & s, const char * search, size_t searchsize) { 275 278 return includes( *s.inner, search, searchsize ); 276 279 } 277 280 278 bool startsWith(const string & s, const string &prefix) {281 bool startsWith(const string & s, const string & prefix) { 279 282 return startsWith( *s.inner, *prefix.inner ); 280 283 } 281 284 282 bool startsWith(const string & s, const char* prefix) {285 bool startsWith(const string & s, const char * prefix) { 283 286 return startsWith( *s.inner, prefix ); 284 287 } 285 288 286 bool startsWith(const string & s, const char* prefix, size_t prefixsize) {289 bool startsWith(const string & s, const char * prefix, size_t prefixsize) { 287 290 return startsWith( *s.inner, prefix, prefixsize ); 288 291 } 289 292 290 bool endsWith(const string & s, const string &suffix) {293 bool endsWith(const string & s, const string & suffix) { 291 294 return endsWith( *s.inner, *suffix.inner ); 292 295 } 293 296 294 bool endsWith(const string & s, const char* suffix) {297 bool endsWith(const string & s, const char * suffix) { 295 298 return endsWith( *s.inner, suffix ); 296 299 } 297 300 298 bool endsWith(const string & s, const char* suffix, size_t suffixsize) {301 bool endsWith(const string & s, const char * suffix, size_t suffixsize) { 299 302 return endsWith( *s.inner, suffix, suffixsize ); 300 303 } … … 326 329 327 330 328 int exclude(const string & s, const charclass &mask) {331 int exclude(const string & s, const charclass & mask) { 329 332 return exclude( *s.inner, *mask.inner ); 330 333 } 331 334 /* 332 StrSlice exclude(string & s, const charclass &mask) {335 StrSlice exclude(string & s, const charclass & mask) { 333 336 } 334 337 */ 335 338 336 int include(const string & s, const charclass &mask) {339 int include(const string & s, const charclass & mask) { 337 340 return include( *s.inner, *mask.inner ); 338 341 } 339 342 340 343 /* 341 StrSlice include(string & s, const charclass &mask) {344 StrSlice include(string & s, const charclass & mask) { 342 345 } 343 346 */
Note: See TracChangeset
for help on using the changeset viewer.