@@ -19,30 +19,29 @@ std::string WStringToString (const std::wstring& str)
19
19
return std::string (convert.to_bytes (str));
20
20
}
21
21
22
- std::wstring ReplaceAll (const std::wstring& string, const std::wstring& from , const std::wstring& to )
22
+ std::wstring ReplaceAll (const std::wstring& string, const std::wstring& fromString , const std::wstring& toString )
23
23
{
24
24
std::wstring result = string;
25
- size_t searchPos = string.find (from );
25
+ size_t searchPos = string.find (fromString );
26
26
while (searchPos != std::wstring::npos) {
27
- result.replace (searchPos, from .length (), to );
28
- searchPos = result.find (from , searchPos + to .length ());
27
+ result.replace (searchPos, fromString .length (), toString );
28
+ searchPos = result.find (fromString , searchPos + toString .length ());
29
29
}
30
30
return result;
31
31
}
32
32
33
- std::wstring ReplaceAll (const std::wstring& string, const std::wstring& from , const std::initializer_list<std::wstring>& to )
33
+ std::wstring ReplaceAll (const std::wstring& string, const std::wstring& fromString , const std::initializer_list<std::wstring>& toStrings )
34
34
{
35
35
std::wstring result = string;
36
- auto toIt = to .begin ();
37
- size_t searchPos = string.find (from );
38
- while (searchPos != std::wstring::npos && toIt != to .end ()) {
39
- const std::wstring currStr = *toIt ;
40
- result.replace (searchPos, from .length (), currStr);
41
- searchPos = result.find (from , searchPos + currStr.length ());
42
- ++toIt ;
36
+ auto toStringIt = toStrings .begin ();
37
+ size_t searchPos = string.find (fromString );
38
+ while (searchPos != std::wstring::npos && toStringIt != toStrings .end ()) {
39
+ const std::wstring& currStr = *toStringIt ;
40
+ result.replace (searchPos, fromString .length (), currStr);
41
+ searchPos = result.find (fromString , searchPos + currStr.length ());
42
+ ++toStringIt ;
43
43
}
44
-
45
- DBGASSERT (searchPos == std::wstring::npos && toIt == to.end ());
44
+ DBGASSERT (searchPos == std::wstring::npos && toStringIt == toStrings.end ());
46
45
return result;
47
46
}
48
47
0 commit comments