mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-07-18 17:04:28 -05:00
Move replaceAll() to utility
This commit is contained in:
parent
3d6d690583
commit
0bf70e443e
|
|
@ -1042,3 +1042,16 @@ std::pair<int, int> getCursorPos()
|
|||
auto cursorPos = QCursor::pos();
|
||||
return {cursorPos.x(), cursorPos.y()};
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,3 +118,4 @@ QString formatJsonString(QString);
|
|||
QString escapeForRegex(QString &s);
|
||||
bool doubleEquals(double left, double right, double epsilon);
|
||||
std::pair<int, int> getCursorPos();
|
||||
void replaceAll(std::string &str, const std::string &from, const std::string &to);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include "variable.hpp"
|
||||
#include "utility.hpp"
|
||||
|
||||
#include <switcher-data-structs.hpp>
|
||||
|
||||
|
|
@ -160,19 +161,6 @@ const char *VariableResolvingString::c_str() const
|
|||
return _resolvedValue.c_str();
|
||||
}
|
||||
|
||||
static 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();
|
||||
}
|
||||
}
|
||||
|
||||
std::string SubstitueVariables(std::string str)
|
||||
{
|
||||
for (const auto &v : switcher->variables) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user