From 4e48d085cc24ce99770905d251f4d1bc89a5ae6c Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sun, 7 Jun 2020 11:28:37 +0100 Subject: [PATCH] Make PluginInterface::GetBashTags() return a std::vector Instead of a std::set. The tags are only iterated over, and uniqueness and ordering are more of a concern for the UI. Part of #68. --- include/loot/plugin_interface.h | 2 +- src/api/helpers/text.cpp | 6 +++--- src/api/helpers/text.h | 4 ++-- src/api/plugin.cpp | 4 ++-- src/api/plugin.h | 4 ++-- src/tests/api/internals/helpers/text_test.h | 2 +- src/tests/api/internals/plugin_test.h | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/loot/plugin_interface.h b/include/loot/plugin_interface.h index 5d5457b4..8303a7a2 100644 --- a/include/loot/plugin_interface.h +++ b/include/loot/plugin_interface.h @@ -75,7 +75,7 @@ public: * @return A set of Bash Tags. The order of elements in the set holds no * semantics. */ - virtual std::set GetBashTags() const = 0; + virtual std::vector GetBashTags() const = 0; /** * Get the plugin's CRC-32 checksum. diff --git a/src/api/helpers/text.cpp b/src/api/helpers/text.cpp index 2de055f7..a5cac26b 100644 --- a/src/api/helpers/text.cpp +++ b/src/api/helpers/text.cpp @@ -71,8 +71,8 @@ const std::vector versionRegexes({ regex::ECMAScript | regex::icase), }); -std::set ExtractBashTags(const std::string& description) { - std::set tags; +std::vector ExtractBashTags(const std::string& description) { + std::vector tags; size_t startPos = description.find("{{BASH:"); if (startPos == std::string::npos || startPos + 7 >= description.length()) { @@ -92,7 +92,7 @@ std::set ExtractBashTags(const std::string& description) { for (auto& tag : bashTags) { boost::trim(tag); - tags.insert(Tag(tag)); + tags.push_back(Tag(tag)); } return tags; diff --git a/src/api/helpers/text.h b/src/api/helpers/text.h index 24149444..c0729c97 100644 --- a/src/api/helpers/text.h +++ b/src/api/helpers/text.h @@ -26,13 +26,13 @@ #define LOOT_API_HELPERS_TEXT #include -#include #include +#include #include "loot/metadata/tag.h" namespace loot { -std::set ExtractBashTags(const std::string& description); +std::vector 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 a5b7ec49..d0cde3e0 100644 --- a/src/api/plugin.cpp +++ b/src/api/plugin.cpp @@ -120,7 +120,7 @@ std::vector Plugin::GetMasters() const { return mastersVec; } -std::set Plugin::GetBashTags() const { return tags_; } +std::vector Plugin::GetBashTags() const { return tags_; } std::optional Plugin::GetCRC() const { return crc_; } @@ -210,7 +210,7 @@ size_t Plugin::GetOverlapSize( size_t Plugin::NumOverrideFormIDs() const { return numOverrideRecords_; } -uint32_t Plugin::GetRecordAndGroupCount() const { +uint32_t Plugin::GetRecordAndGroupCount() const { uint32_t recordAndGroupCount = 0; auto ret = esp_plugin_record_and_group_count(esPlugin.get(), &recordAndGroupCount); diff --git a/src/api/plugin.h b/src/api/plugin.h index 67944f45..319a770d 100644 --- a/src/api/plugin.h +++ b/src/api/plugin.h @@ -52,7 +52,7 @@ public: float GetHeaderVersion() const; std::optional GetVersion() const; std::vector GetMasters() const; - std::set GetBashTags() const; + std::vector GetBashTags() const; std::optional GetCRC() const; bool IsMaster() const; @@ -92,7 +92,7 @@ private: const std::string name_; std::optional version_; // Obtained from description field. std::optional crc_; - std::set tags_; + std::vector tags_; // Useful caches. size_t numOverrideRecords_; diff --git a/src/tests/api/internals/helpers/text_test.h b/src/tests/api/internals/helpers/text_test.h index 9726c874..11f1d752 100644 --- a/src/tests/api/internals/helpers/text_test.h +++ b/src/tests/api/internals/helpers/text_test.h @@ -46,7 +46,7 @@ Requires Skyrim Special Edition 1.5.39 or greater. auto tags = ExtractBashTags(description); - std::set expectedTags({ + std::vector expectedTags({ Tag("C.Climate"), Tag("C.Encounter"), Tag("C.ImageSpace"), diff --git a/src/tests/api/internals/plugin_test.h b/src/tests/api/internals/plugin_test.h index 9d6d95a8..f53793e0 100644 --- a/src/tests/api/internals/plugin_test.h +++ b/src/tests/api/internals/plugin_test.h @@ -145,7 +145,7 @@ public: std::vector GetMasters() const { return std::vector(); } - std::set GetBashTags() const { return std::set(); } + std::vector GetBashTags() const { return std::vector(); } std::optional GetCRC() const { return std::nullopt; } bool IsMaster() const { return false; }