aboutsummaryrefslogtreecommitdiff
path: root/src/StringUtils.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-05-05 19:12:07 +0200
committerdec05eba <dec05eba@protonmail.com>2020-05-05 19:12:07 +0200
commit737263bc5a123bee889530a2623dfbeb90ee30e9 (patch)
treef1ec22cc26c7dfe86353e21e0443e0a7a74a248e /src/StringUtils.cpp
parenta255719fa63aa52f56c4c9c7f04fb43b89b6b64c (diff)
Fallback to backup image source if image fails to load for manganelo
Diffstat (limited to 'src/StringUtils.cpp')
-rw-r--r--src/StringUtils.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp
index 981b227..7668df7 100644
--- a/src/StringUtils.cpp
+++ b/src/StringUtils.cpp
@@ -16,14 +16,17 @@ namespace QuickMedia {
}
}
- void string_replace_all(std::string &str, const std::string &old_str, const std::string &new_str) {
+ size_t string_replace_all(std::string &str, const std::string &old_str, const std::string &new_str) {
+ size_t num_replaced_substrings = 0;
size_t index = 0;
while(true) {
index = str.find(old_str, index);
if(index == std::string::npos)
- return;
+ break;
str.replace(index, old_str.size(), new_str);
+ ++num_replaced_substrings;
}
+ return num_replaced_substrings;
}
static bool is_whitespace(char c) {