Changeset 16066
- Timestamp:
- 2008-06-19T13:09:56+12:00 (16 years ago)
- Location:
- gsdl/trunk/src/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/src/lib/text_t.cpp
r15077 r16066 374 374 } 375 375 376 text_t::const_iterator findword (text_t::const_iterator first, 377 text_t::const_iterator last, 378 const text_t& word) 379 { 380 text_t::const_iterator word_begin = word.begin(); 381 text_t::const_iterator word_end = word.end(); 382 383 while (first != last) 384 { 385 text_t::const_iterator char_match = first; 386 text_t::const_iterator word_here = word_begin; 387 while (word_here!=word_end) 388 { 389 if (*char_match != *word_here) 390 { 391 break; 392 } 393 ++char_match; 394 ++word_here; 395 } 396 if (word_here==word_end) 397 { 398 return first; 399 } 400 ++first; 401 } 402 return last; // get to here only if there is no match 403 } 404 376 405 text_t::iterator findword (text_t::iterator first, 377 406 text_t::iterator last, … … 427 456 } 428 457 458 text_t::const_iterator getdelimitstr (text_t::const_iterator first, text_t::const_iterator last, 459 text_t w, text_t &outstr) 460 { 461 text_t::const_iterator here = first; 462 here = findword (first, last, w); 463 outstr.clear(); 464 outstr.appendrange (first, here); 465 if (here != last) here += w.size(); // skip w 466 return here; 467 } 468 429 469 // split a string with a character 430 470 void splitchar (text_t::const_iterator first, text_t::const_iterator last, … … 466 506 { 467 507 first = getdelimitstr (first, last, c, t); 508 outlist.push_back (t); 509 } 510 } 511 512 void splitword (text_t::const_iterator first, text_t::const_iterator last, 513 text_t w, text_tlist &outlist) 514 { 515 outlist.erase(outlist.begin(), outlist.end()); 516 517 text_t t; 518 519 while (first != last) 520 { 521 first = getdelimitstr (first, last, w, t); 468 522 outlist.push_back (t); 469 523 } -
gsdl/trunk/src/lib/text_t.h
r14342 r16066 229 229 text_t::iterator findword (text_t::iterator first, text_t::iterator last, 230 230 const text_t &word); 231 text_t::const_iterator findword (text_t::const_iterator first, text_t::const_iterator last, 232 const text_t& word); 231 233 232 234 // get a string up to the next delimiter (which is skipped) … … 236 238 text_t::iterator getdelimitstr (text_t::iterator first, text_t::iterator last, 237 239 unsigned short c, text_t &outstr); 240 241 text_t::const_iterator getdelimitstr (text_t::const_iterator first, text_t::const_iterator last, 242 text_t w, text_t &outstr); 238 243 239 244 // split a string with a character … … 244 249 void splitchar (text_t::const_iterator first, text_t::const_iterator last, 245 250 unsigned short c, text_tarray &outlist); 251 252 void splitword (text_t::const_iterator first, text_t::const_iterator last, 253 text_t w, text_tlist &outlist); 246 254 247 255 // join a string using a character
Note:
See TracChangeset
for help on using the changeset viewer.