diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2f2481e4..2f78459f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -208,7 +208,7 @@ set (LOOT_API_SRC "${CMAKE_BINARY_DIR}/generated/loot_version.cpp"
"${CMAKE_SOURCE_DIR}/src/api/sorting/plugin_sorting_data.cpp"
"${CMAKE_SOURCE_DIR}/src/api/helpers/crc.cpp"
"${CMAKE_SOURCE_DIR}/src/api/helpers/git_helper.cpp"
- "${CMAKE_SOURCE_DIR}/src/api/helpers/version.cpp"
+ "${CMAKE_SOURCE_DIR}/src/api/helpers/text.cpp"
"${CMAKE_SOURCE_DIR}/src/api/vertex.cpp"
"${CMAKE_SOURCE_DIR}/src/api/resource.rc")
@@ -263,7 +263,7 @@ set (LOOT_API_HEADERS "${CMAKE_SOURCE_DIR}/include/loot/api.h"
"${CMAKE_SOURCE_DIR}/src/api/helpers/git_helper.h"
"${CMAKE_SOURCE_DIR}/src/api/helpers/crc.h"
"${CMAKE_SOURCE_DIR}/src/api/helpers/logging.h"
- "${CMAKE_SOURCE_DIR}/src/api/helpers/version.h")
+ "${CMAKE_SOURCE_DIR}/src/api/helpers/text.h")
set (LOOT_TESTS_SRC "${CMAKE_SOURCE_DIR}/src/tests/api/internals/main.cpp")
@@ -272,7 +272,7 @@ set (LOOT_TESTS_HEADERS "${CMAKE_SOURCE_DIR}/src/tests/api/internals/game/game_t
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/game/load_order_handler_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/helpers/git_helper_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/helpers/crc_test.h"
- "${CMAKE_SOURCE_DIR}/src/tests/api/internals/helpers/version_test.h"
+ "${CMAKE_SOURCE_DIR}/src/tests/api/internals/helpers/text_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/helpers/yaml_set_helpers_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/metadata/condition_evaluator_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/metadata/conditional_metadata_test.h"
diff --git a/src/api/helpers/version.cpp b/src/api/helpers/text.cpp
similarity index 81%
rename from src/api/helpers/version.cpp
rename to src/api/helpers/text.cpp
index ec261509..caa7ba90 100644
--- a/src/api/helpers/version.cpp
+++ b/src/api/helpers/text.cpp
@@ -21,7 +21,7 @@
along with LOOT. If not, see
.
*/
-#include "api/helpers/version.h"
+#include "api/helpers/text.h"
#include
@@ -62,6 +62,32 @@ const std::vector versionRegexes({
regex::ECMAScript | regex::icase),
});
+std::set ExtractBashTags(const std::string& description) {
+ std::set tags;
+
+ size_t startPos = description.find("{{BASH:");
+ if (startPos == std::string::npos) {
+ return tags;
+ }
+
+ size_t endPos = description.find("}}", startPos);
+ if (endPos == std::string::npos) {
+ return tags;
+ }
+
+ auto commaSeparatedTags = description.substr(startPos, endPos - startPos);
+
+ std::vector bashTags;
+ boost::split(bashTags, commaSeparatedTags, [](char c) { return c == ','; });
+
+ for (auto& tag : bashTags) {
+ boost::trim(tag);
+ tags.insert(Tag(tag));
+ }
+
+ return tags;
+}
+
std::optional ExtractVersion(const std::string& text) {
std::smatch what;
for (const auto& versionRegex : versionRegexes) {
diff --git a/src/api/helpers/version.h b/src/api/helpers/text.h
similarity index 84%
rename from src/api/helpers/version.h
rename to src/api/helpers/text.h
index 2bd4f1b3..1e3e65d4 100644
--- a/src/api/helpers/version.h
+++ b/src/api/helpers/text.h
@@ -22,13 +22,18 @@
.
*/
-#ifndef LOOT_API_HELPERS_VERSION
-#define LOOT_API_HELPERS_VERSION
+#ifndef LOOT_API_HELPERS_TEXT
+#define LOOT_API_HELPERS_TEXT
#include
+#include
#include
+#include "loot/metadata/tag.h"
+
namespace loot {
+std::set ExtractBashTags(const std::string& description);
+
std::optional ExtractVersion(const std::string& text);
}
diff --git a/src/api/plugin.cpp b/src/api/plugin.cpp
index eee2c24c..e35c12e5 100644
--- a/src/api/plugin.cpp
+++ b/src/api/plugin.cpp
@@ -25,7 +25,6 @@
#include "api/plugin.h"
#include
-#include
#include
#include
@@ -33,7 +32,7 @@
#include "api/game/game.h"
#include "api/helpers/crc.h"
#include "api/helpers/logging.h"
-#include "api/helpers/version.h"
+#include "api/helpers/text.h"
#include "loot/exception/file_access_error.h"
using std::set;
@@ -88,28 +87,7 @@ Plugin::Plugin(const GameType gameType,
name_);
}
- string text = GetDescription();
- size_t pos1 = text.find("{{BASH:");
- if (pos1 != string::npos && pos1 + 7 != text.length()) {
- pos1 += 7;
-
- size_t pos2 = text.find("}}", pos1);
- if (pos2 != string::npos && pos1 != pos2) {
- text = text.substr(pos1, pos2 - pos1);
-
- std::vector bashTags;
- boost::split(bashTags, text, [](char c) { return c == ','; });
-
- for (auto& tag : bashTags) {
- boost::trim(tag);
- tags_.insert(Tag(tag));
-
- if (logger) {
- logger->trace("{}: Extracted Bash Tag: {}", name_, tag);
- }
- }
- }
- }
+ tags_ = ExtractBashTags(GetDescription());
loadsArchive_ = LoadsArchive(gameType, gameCache, pluginPath);
} catch (std::exception& e) {
diff --git a/src/tests/api/internals/helpers/version_test.h b/src/tests/api/internals/helpers/text_test.h
similarity index 97%
rename from src/tests/api/internals/helpers/version_test.h
rename to src/tests/api/internals/helpers/text_test.h
index f058def1..bb131725 100644
--- a/src/tests/api/internals/helpers/version_test.h
+++ b/src/tests/api/internals/helpers/text_test.h
@@ -22,10 +22,10 @@ along with LOOT. If not, see
.
*/
-#ifndef LOOT_TESTS_API_INTERNALS_HELPERS_VERSION_TEST
-#define LOOT_TESTS_API_INTERNALS_HELPERS_VERSION_TEST
+#ifndef LOOT_TESTS_API_INTERNALS_HELPERS_TEXT_TEST
+#define LOOT_TESTS_API_INTERNALS_HELPERS_TEXT_TEST
-#include "api/helpers/version.h"
+#include "api/helpers/text.h"
#include "loot/loot_version.h"
#include
@@ -42,7 +42,6 @@ TEST(Version, shouldExtractAVersionContainingMultipleDigits) {
}
TEST(Version, shouldExtractAVersionContainingMultipleNumbers) {
-
EXPECT_EQ("10.11.12.13", ExtractVersion("10.11.12.13").value());
}
diff --git a/src/tests/api/internals/main.cpp b/src/tests/api/internals/main.cpp
index 4c99204c..b0c472ad 100644
--- a/src/tests/api/internals/main.cpp
+++ b/src/tests/api/internals/main.cpp
@@ -29,7 +29,7 @@
#include "tests/api/internals/game/load_order_handler_test.h"
#include "tests/api/internals/helpers/crc_test.h"
#include "tests/api/internals/helpers/git_helper_test.h"
-#include "tests/api/internals/helpers/version_test.h"
+#include "tests/api/internals/helpers/text_test.h"
#include "tests/api/internals/helpers/yaml_set_helpers_test.h"
#include "tests/api/internals/masterlist_test.h"
#include "tests/api/internals/metadata/condition_evaluator_test.h"