summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-01-27 19:35:12 +0300
committerAndrei Karas <akaras@inbox.ru>2017-01-27 19:35:12 +0300
commit4db8641fd12c6e11257a6a45fcb2e1948fe4bcb1 (patch)
tree6766b3b9b98bfb518d9580ea2eb2caa61a6bfefb /src/utils
parentd78eb448f235f80667378f57d325ee0d3fb0a633 (diff)
downloadmv-4db8641fd12c6e11257a6a45fcb2e1948fe4bcb1.tar.gz
mv-4db8641fd12c6e11257a6a45fcb2e1948fe4bcb1.tar.bz2
mv-4db8641fd12c6e11257a6a45fcb2e1948fe4bcb1.tar.xz
mv-4db8641fd12c6e11257a6a45fcb2e1948fe4bcb1.zip
Move keys replace code from browserbox into browserboxtools.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/browserboxtools.cpp19
-rw-r--r--src/utils/browserboxtools.h2
2 files changed, 21 insertions, 0 deletions
diff --git a/src/utils/browserboxtools.cpp b/src/utils/browserboxtools.cpp
index d39e8e280..6684684ff 100644
--- a/src/utils/browserboxtools.cpp
+++ b/src/utils/browserboxtools.cpp
@@ -23,6 +23,8 @@
#include "main.h"
#include "settings.h"
+#include "input/inputmanager.h"
+
#include "utils/stringutils.h"
#include "debug.h"
@@ -32,3 +34,20 @@ void BrowserBoxTools::replaceVars(std::string &data)
data = replaceAll(data, "%VER%", SMALL_VERSION);
data = replaceAll(data, "%SUPPORTURL%", settings.supportUrl);
}
+
+void BrowserBoxTools::replaceKeys(std::string &data)
+{
+ size_t idx1 = data.find("###");
+ while (idx1 != std::string::npos)
+ {
+ const size_t idx2 = data.find(';', idx1);
+ if (idx2 == std::string::npos)
+ break;
+
+ const std::string str = inputManager.getKeyValueByNameLong(
+ data.substr(idx1 + 3, idx2 - idx1 - 3));
+ data.replace(idx1, idx2 - idx1 + 1, str);
+
+ idx1 = data.find("###");
+ }
+}
diff --git a/src/utils/browserboxtools.h b/src/utils/browserboxtools.h
index eba70118a..c2d0c9dc9 100644
--- a/src/utils/browserboxtools.h
+++ b/src/utils/browserboxtools.h
@@ -28,6 +28,8 @@
namespace BrowserBoxTools
{
void replaceVars(std::string &data);
+
+ void replaceKeys(std::string &data);
} // BrowserBoxTools
#endif // UTILS_BROWSERBOXTOOLS_H