14 std::string
findAndReplace(std::string s, std::string find, std::string replace) {
15 size_t p = s.find(find);
16 while (p != std::string::npos) {
17 s.erase(p, find.length());
25 if ((s.length() > 0) && (s[0] ==
'~')) {
34 std::transform(s.begin(), s.end(), s.begin(), ::tolower);
35 std::transform(suffix.begin(), suffix.end(), suffix.begin(), ::tolower);
38 if (s.length() >= suffix.length()) {
39 std::string end = s.substr(s.length() - suffix.length());
40 return (end == suffix);
47 auto pos = s.find_last_of(
"/\\");
48 if (pos == std::string::npos)
54 auto pos = s.find_last_of(
"/\\");
55 if (pos == std::string::npos)
57 return s.erase(0, pos + 1);
61 std::string::size_type pos;
64 while ((pos = s.find(
'/')) != std::string::npos) {
65 s.replace(pos, 1, 1,
'\\');
68 while ((pos = s.find(
'\\')) != std::string::npos) {
69 s.replace(pos, 1, 1,
'/');
std::string expandHomeDirectory(std::string s)
String handling utilities.
std::string getLastPathElement(std::string s)
bool stringEndsWith(std::string s, std::string suffix, bool casesensitive)
std::string findAndReplace(std::string s, std::string find, std::string replace)
std::string getHomeDirectory()
std::string convertPathDelimiter(std::string s)
std::string removeLastPathElement(std::string s)