Merged with trunk R1612.
[ardour.git] / libs / pbd / strreplace.cc
1 #include <pbd/replace_all.h>
2
3 int
4 replace_all (std::string& str,
5              std::string const& target,
6              std::string const& replacement) 
7 {
8         std::string::size_type start = str.find (target, 0);
9         int cnt = 0;
10
11         while (start != std::string::npos) {
12                 str.replace (start, target.size(), replacement);
13                 start = str.find (target, start+replacement.size());
14                 ++cnt;
15         }
16
17         return cnt;
18 }
19