Improved Fragment Shader Decompiler

- Implemented LIT, RFL, LIF, BRK, IF, LOOP, REP
- Fixed KIL, RCP, RSQ, DP2A

Implemented fmt::replace_first & fmt::replace_all
This commit is contained in:
DH 2014-06-07 17:15:49 +03:00
parent 30a1516d19
commit f8e8e2f624
6 changed files with 294 additions and 99 deletions

View file

@ -31,6 +31,29 @@ std::string fmt::FormatV(std::string fmt, va_list args)
return str;
}
std::string replace_first(const std::string& src, const std::string& from, const std::string& to)
{
auto pos = src.find(from);
if (pos == std::string::npos)
{
return src;
}
return (pos ? src.substr(0, pos) + to : to) + std::string(src.c_str() + pos + from.length());
}
std::string replace_all(std::string src, const std::string& from, const std::string& to)
{
for (auto pos = src.find(from); pos != std::string::npos; src.find(from, pos + 1))
{
src = (pos ? src.substr(0, pos) + to : to) + std::string(src.c_str() + pos + from.length());
pos += to.length();
}
return src;
}
//convert a wxString to a std::string encoded in utf8
//CAUTION, only use this to interface with wxWidgets classes
std::string fmt::ToUTF8(const wxString& right)