Changeset 10140
- Timestamp:
- 2005-06-17T10:49:44+12:00 (19 years ago)
- Location:
- trunk/gsdl/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/lib/text_t.cpp
r9593 r10140 28 28 /* 29 29 $Log$ 30 Revision 1.25 2005/06/16 22:49:44 kjdon 31 added starts_with and ends_with functions 32 30 33 Revision 1.24 2005/04/07 04:27:18 kjdon 31 34 added some x++ -> ++x changes submitted by Emanuel Dejanu … … 660 663 } 661 664 665 // checks to see if a text_t starts with the specified prefix 666 bool starts_with(const text_t& text, const text_t& prefix) { 667 if (prefix.empty()) return true; 668 if (text.empty() || text.size()<prefix.size()) return false; 669 text_t substring = substr(text.begin(), text.begin()+prefix.size()); 670 return substring == prefix; 671 } 672 // checks to see if a text_t ends with the specified suffix 673 bool ends_with(const text_t& text, const text_t& suffix) { 674 if (suffix.empty()) return true; 675 if (text.empty() || text.size() < suffix.size()) return false; 676 text_t substring = substr(text.end()-suffix.size(),text.end()); 677 return substring == suffix; 678 679 } 662 680 663 681 -
trunk/gsdl/lib/text_t.h
r8727 r10140 272 272 bool has_unicode_letdig (const text_t &text); 273 273 274 // checks to see if a text_t starts with the specified prefix 275 bool starts_with(const text_t& text, const text_t& prefix); 276 // checks to see if a text_t ends with the specified suffix 277 bool ends_with(const text_t& text, const text_t& suffix); 274 278 275 279 // conversion classes used for getting information in to and out of
Note:
See TracChangeset
for help on using the changeset viewer.