| 1 |
#include "StdToWX.h" |
| 2 |
|
| 3 |
void StdToWX::Remove(std::string& str, size_t from, size_t len) { str.erase(from, len); } |
| 4 |
|
| 5 |
bool StdToWX::EndsWith(const std::string& str, const std::string& what) |
| 6 |
{ |
| 7 |
if(str.length() >= what.length()) { |
| 8 |
return (0 == str.compare(str.length() - what.length(), what.length(), what)); |
| 9 |
} else { |
| 10 |
return false; |
| 11 |
} |
| 12 |
} |
| 13 |
|
| 14 |
bool StdToWX::StartsWith(const std::string& str, const std::string& what) |
| 15 |
{ |
| 16 |
if(str.length() >= what.length()) { |
| 17 |
return (0 == str.compare(0, what.length(), what)); |
| 18 |
} else { |
| 19 |
return false; |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
void StdToWX::Trim(std::string& str, bool fromRight) |
| 24 |
{ |
| 25 |
static std::string trimString = " \t\r\n"; |
| 26 |
if(fromRight) { |
| 27 |
str.erase(str.find_last_not_of(trimString) + 1); |
| 28 |
} else { |
| 29 |
str.erase(0, str.find_first_not_of(trimString)); |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
void StdToWX::RemoveLast(std::string& str, size_t count) |
| 34 |
{ |
| 35 |
if(str.length() >= count) { |
| 36 |
str.erase(str.length() - count, count); |
| 37 |
} |
| 38 |
} |