diff options
Diffstat (limited to 'src/StringUtils.cpp')
-rw-r--r-- | src/StringUtils.cpp | 7 |
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) { |