mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Make PluginMetadata::GetTags() return a std::vector
The collection is only ever iterated over, and the uniqueness and ordering don't matter.
This commit is contained in:
@@ -124,7 +124,7 @@ public:
|
||||
* Get the plugin's Bash Tag suggestions.
|
||||
* @return The plugin's Bash Tag suggestions.
|
||||
*/
|
||||
LOOT_API std::set<Tag> GetTags() const;
|
||||
LOOT_API std::vector<Tag> GetTags() const;
|
||||
|
||||
/**
|
||||
* Get the plugin's dirty plugin information.
|
||||
@@ -198,7 +198,7 @@ public:
|
||||
* @param tags
|
||||
* The Bash Tag suggestions to set.
|
||||
*/
|
||||
LOOT_API void SetTags(const std::set<Tag>& tags);
|
||||
LOOT_API void SetTags(const std::vector<Tag>& tags);
|
||||
|
||||
/**
|
||||
* Set the plugin's dirty information.
|
||||
@@ -272,7 +272,7 @@ private:
|
||||
std::vector<File> requirements_;
|
||||
std::vector<File> incompatibilities_;
|
||||
std::vector<Message> messages_;
|
||||
std::set<Tag> tags_;
|
||||
std::vector<Tag> tags_;
|
||||
std::set<PluginCleaningData> dirtyInfo_;
|
||||
std::set<PluginCleaningData> cleanInfo_;
|
||||
std::set<Location> locations_;
|
||||
|
||||
@@ -155,12 +155,12 @@ PluginMetadata ConditionEvaluator::EvaluateAll(const PluginMetadata& pluginMetad
|
||||
}
|
||||
evaluatedMetadata.SetMessages(messages);
|
||||
|
||||
std::set<Tag> tagSet;
|
||||
std::vector<Tag> tags;
|
||||
for (const auto& tag : pluginMetadata.GetTags()) {
|
||||
if (Evaluate(tag.GetCondition()))
|
||||
tagSet.insert(tag);
|
||||
tags.push_back(tag);
|
||||
}
|
||||
evaluatedMetadata.SetTags(tagSet);
|
||||
evaluatedMetadata.SetTags(tags);
|
||||
|
||||
if (!evaluatedMetadata.IsRegexPlugin()) {
|
||||
std::set<PluginCleaningData> infoSet;
|
||||
|
||||
@@ -61,9 +61,7 @@ void PluginMetadata::MergeMetadata(const PluginMetadata& plugin) {
|
||||
requirements_ = mergeVectors(requirements_, plugin.requirements_);
|
||||
incompatibilities_ = mergeVectors(incompatibilities_, plugin.incompatibilities_);
|
||||
|
||||
// Merge Bash Tags too. Conditions are ignored during comparison, but
|
||||
// if a tag is added and removed, both instances will be in the set.
|
||||
tags_.insert(begin(plugin.tags_), end(plugin.tags_));
|
||||
tags_ = mergeVectors(tags_, plugin.tags_);
|
||||
|
||||
// Messages are in an ordered list, and should be fully merged.
|
||||
messages_.insert(
|
||||
@@ -102,13 +100,7 @@ PluginMetadata PluginMetadata::NewMetadata(const PluginMetadata& plugin) const {
|
||||
inserter(mDiff, begin(mDiff)));
|
||||
p.SetMessages(mDiff);
|
||||
|
||||
set<Tag> tagDiff;
|
||||
set_difference(begin(tags_),
|
||||
end(tags_),
|
||||
begin(plugin.tags_),
|
||||
end(plugin.tags_),
|
||||
inserter(tagDiff, begin(tagDiff)));
|
||||
p.SetTags(tagDiff);
|
||||
p.SetTags(diffVectors(tags_, plugin.tags_));
|
||||
|
||||
set<PluginCleaningData> dirtDiff;
|
||||
set_difference(begin(dirtyInfo_),
|
||||
@@ -153,7 +145,7 @@ std::vector<File> PluginMetadata::GetIncompatibilities() const {
|
||||
|
||||
std::vector<Message> PluginMetadata::GetMessages() const { return messages_; }
|
||||
|
||||
std::set<Tag> PluginMetadata::GetTags() const { return tags_; }
|
||||
std::vector<Tag> PluginMetadata::GetTags() const { return tags_; }
|
||||
|
||||
std::set<PluginCleaningData> PluginMetadata::GetDirtyInfo() const {
|
||||
return dirtyInfo_;
|
||||
@@ -198,7 +190,7 @@ void PluginMetadata::SetMessages(const std::vector<Message>& m) {
|
||||
messages_ = m;
|
||||
}
|
||||
|
||||
void PluginMetadata::SetTags(const std::set<Tag>& t) { tags_ = t; }
|
||||
void PluginMetadata::SetTags(const std::vector<Tag>& t) { tags_ = t; }
|
||||
|
||||
void PluginMetadata::SetDirtyInfo(
|
||||
const std::set<PluginCleaningData>& dirtyInfo) {
|
||||
|
||||
@@ -111,7 +111,7 @@ struct convert<loot::PluginMetadata> {
|
||||
if (node["msg"])
|
||||
rhs.SetMessages(node["msg"].as<std::vector<loot::Message>>());
|
||||
if (node["tag"])
|
||||
rhs.SetTags(node["tag"].as<std::set<loot::Tag>>());
|
||||
rhs.SetTags(node["tag"].as<std::vector<loot::Tag>>());
|
||||
if (node["dirty"]) {
|
||||
rhs.SetDirtyInfo(
|
||||
node["dirty"].as<std::set<loot::PluginCleaningData>>());
|
||||
|
||||
@@ -574,17 +574,15 @@ TEST_P(DatabaseInterfaceTest,
|
||||
|
||||
auto metadata = db_->GetPluginMetadata(blankEsm, true).value();
|
||||
|
||||
std::set<Tag> expectedTags({
|
||||
Tag("Actors.ACBS"),
|
||||
std::vector<Tag> expectedTags({
|
||||
Tag("Actors.ACBS", true, "file(\"" + missingEsp + "\")"),
|
||||
Tag("Actors.ACBS"),
|
||||
Tag("Actors.AIData"),
|
||||
Tag("C.Water", false),
|
||||
});
|
||||
EXPECT_EQ(expectedTags, metadata.GetTags());
|
||||
EXPECT_EQ("file(\"" + missingEsp + "\")",
|
||||
metadata.GetTags()
|
||||
.find(Tag("Actors.ACBS", true, "file(\"" + missingEsp + "\")"))
|
||||
->GetCondition());
|
||||
metadata.GetTags()[0].GetCondition());
|
||||
}
|
||||
|
||||
TEST_P(
|
||||
|
||||
@@ -195,7 +195,7 @@ TEST_P(ConditionEvaluatorTest, evaluateAllShouldEvaluateAllMetadataConditions) {
|
||||
EXPECT_EQ(expectedFiles, plugin.GetRequirements());
|
||||
EXPECT_EQ(expectedFiles, plugin.GetIncompatibilities());
|
||||
EXPECT_EQ(std::vector<Message>({message1}), plugin.GetMessages());
|
||||
EXPECT_EQ(std::set<Tag>({tag1}), plugin.GetTags());
|
||||
EXPECT_EQ(std::vector<Tag>({tag1}), plugin.GetTags());
|
||||
EXPECT_EQ(std::set<PluginCleaningData>({info1}), plugin.GetDirtyInfo());
|
||||
EXPECT_EQ(std::set<PluginCleaningData>({info1}), plugin.GetCleanInfo());
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ TEST_P(PluginMetadataTest, mergeMetadataShouldMergeTags) {
|
||||
plugin2.SetTags({tag1, tag2, tag3});
|
||||
plugin1.MergeMetadata(plugin2);
|
||||
|
||||
EXPECT_EQ(std::set<Tag>({tag1, tag2, tag3}), plugin1.GetTags());
|
||||
EXPECT_EQ(std::vector<Tag>({tag1, tag2, tag3}), plugin1.GetTags());
|
||||
}
|
||||
|
||||
TEST_P(PluginMetadataTest, mergeMetadataShouldMergeDirtyInfoData) {
|
||||
@@ -386,7 +386,7 @@ TEST_P(PluginMetadataTest,
|
||||
plugin2.SetTags({tag1, tag3});
|
||||
PluginMetadata newMetadata = plugin1.NewMetadata(plugin2);
|
||||
|
||||
EXPECT_EQ(std::set<Tag>({tag2}), newMetadata.GetTags());
|
||||
EXPECT_EQ(std::vector<Tag>({tag2}), newMetadata.GetTags());
|
||||
}
|
||||
|
||||
TEST_P(
|
||||
@@ -822,7 +822,7 @@ TEST_P(PluginMetadataTest, encodingAsYamlShouldSetTagFieldIfTagsExist) {
|
||||
YAML::Node node;
|
||||
node = plugin;
|
||||
|
||||
EXPECT_EQ(plugin.GetTags(), node["tag"].as<std::set<Tag>>());
|
||||
EXPECT_EQ(plugin.GetTags(), node["tag"].as<std::vector<Tag>>());
|
||||
}
|
||||
|
||||
TEST_P(PluginMetadataTest, encodingAsYamlShouldSetDirtyFieldIfDirtyInfoExists) {
|
||||
@@ -886,7 +886,7 @@ TEST_P(PluginMetadataTest, decodingFromYamlShouldStoreAllGivenData) {
|
||||
EXPECT_EQ(std::vector<File>({File("Blank.esm")}), plugin.GetIncompatibilities());
|
||||
EXPECT_EQ(std::vector<Message>({Message(MessageType::say, "content")}),
|
||||
plugin.GetMessages());
|
||||
EXPECT_EQ(std::set<Tag>({Tag("Relev")}), plugin.GetTags());
|
||||
EXPECT_EQ(std::vector<Tag>({Tag("Relev")}), plugin.GetTags());
|
||||
EXPECT_EQ(std::set<PluginCleaningData>(
|
||||
{PluginCleaningData(5, "utility", {}, 0, 1, 2)}),
|
||||
plugin.GetDirtyInfo());
|
||||
|
||||
Reference in New Issue
Block a user