MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / ReplaceString

Method ReplaceString

external/ImGuiFileDialog/ImGuiFileDialog.cpp:971–992  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

969}
970
971bool IGFD::Utils::ReplaceString(std::string& str, const ::std::string& oldStr, const ::std::string& newStr, const size_t& vMaxRecursion) {
972 if (!str.empty() && oldStr != newStr) {
973 bool res = false;
974 size_t pos = 0;
975 bool found = false;
976 size_t max_recursion = vMaxRecursion;
977 do {
978 pos = str.find(oldStr, pos);
979 if (pos != std::string::npos) {
980 found = res = true;
981 str.replace(pos, oldStr.length(), newStr);
982 pos += newStr.length();
983 } else if (found && max_recursion > 0) { // recursion loop
984 found = false;
985 pos = 0;
986 --max_recursion;
987 }
988 } while (pos != std::string::npos);
989 return res;
990 }
991 return false;
992}
993
994std::vector<std::string> IGFD::Utils::SplitStringToVector(const std::string& vText, const std::string& vDelimiterPattern, const bool vPushEmpty) {
995 std::vector<std::string> arr;

Callers

nothing calls this directly

Calls 3

emptyMethod · 0.45
findMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected