Move function to bspf.hxx. It's not used yet, but it might be in the future.

This commit is contained in:
Stephen Anthony 2020-11-30 16:08:56 -03:30
parent d1f9ee730b
commit 2e0c0549e7
2 changed files with 13 additions and 12 deletions

View File

@ -470,18 +470,6 @@ Int32 HighScoresManager::convert(Int32 val, uInt32 maxVal, bool isBCD, bool zero
return val;
}
#if 0
void replaceAll(std::string& str, const std::string& from, const std::string& to) {
if(from.empty())
return;
size_t start_pos = 0;
while((start_pos = str.find(from, start_pos)) != std::string::npos) {
str.replace(start_pos, from.length(), to);
start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'
}
}
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::getPropBool(const json& jprops, const string& key,
bool defVal) const

View File

@ -290,6 +290,19 @@ namespace BSPF
return false;
}
// Modify 'str', replacing all occurrences of 'from' with 'to'
inline void replaceAll(string& str, const string& from, const string& to)
{
if(from.empty()) return;
size_t start_pos = 0;
while((start_pos = str.find(from, start_pos)) != string::npos)
{
str.replace(start_pos, from.length(), to);
start_pos += to.length(); // In case 'to' contains 'from',
// like replacing 'x' with 'yx'
}
}
// C++11 way to get local time
// Equivalent to the C-style localtime() function, but is thread-safe
inline std::tm localTime()