From 4db8641fd12c6e11257a6a45fcb2e1948fe4bcb1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 27 Jan 2017 19:35:12 +0300 Subject: Move keys replace code from browserbox into browserboxtools. --- src/utils/browserboxtools.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/utils/browserboxtools.cpp') 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("###"); + } +} -- cgit v1.2.3-60-g2f50