- Timestamp:
- 2007-08-08T15:42:44+12:00 (17 years ago)
- Location:
- gsdl/trunk/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/lib/text_t.cpp
r12504 r14342 298 298 299 299 300 int text_t::replace(text_t toreplace, text_t replacement) 301 { 302 // Get the beginning and end of the current text 303 text_t::iterator text_begin = text.begin(), text_end = text.end(); 304 int count = 0; 305 text_t new_text, temp_text; 306 307 // Loop through and grab the text off the end 308 while (text_begin < text_end) 309 { 310 // Find where the next toreplace is 311 text_t::iterator next_toreplace = findword(text_begin, text_end, toreplace); 312 313 // Grab the string up to it 314 temp_text = substr(text_begin, next_toreplace); 315 316 // Add the new string onto the end 317 if (new_text.empty()) 318 { 319 new_text.append(temp_text); 320 } 321 else 322 { 323 new_text.append(replacement + temp_text); 324 } 325 326 // Finally, we need to move the current pointer up to the new position 327 text_begin = next_toreplace + 1; 328 count++; 329 } 330 331 text.clear(); 332 text = new_text.text_as_usvector(); 333 return count; 334 } 335 336 300 337 // general functions which work on text_ts 301 338 -
gsdl/trunk/lib/text_t.h
r12504 r14342 168 168 char *getcstr() const; 169 169 170 int replace(text_t toreplace, text_t replacement); 170 171 }; 171 172
Note:
See TracChangeset
for help on using the changeset viewer.