mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Be explicit about string -> PluginMetadata conversions
I can't enforce this without making a breaking change to the API, but this will do for now.
This commit is contained in:
@@ -239,7 +239,7 @@ std::optional<PluginMetadata> ApiDatabase::GetPluginUserMetadata(
|
||||
}
|
||||
|
||||
void ApiDatabase::SetPluginUserMetadata(const PluginMetadata& pluginMetadata) {
|
||||
userlist_.ErasePlugin(pluginMetadata);
|
||||
userlist_.ErasePlugin(pluginMetadata.GetName());
|
||||
userlist_.AddPlugin(pluginMetadata);
|
||||
}
|
||||
|
||||
|
||||
@@ -145,20 +145,20 @@ void MetadataList::SetGroups(const std::unordered_set<Group>& groups) {
|
||||
|
||||
// Merges multiple matching regex entries if any are found.
|
||||
std::optional<PluginMetadata> MetadataList::FindPlugin(
|
||||
const std::string& plugin) const {
|
||||
PluginMetadata match(plugin);
|
||||
const std::string& pluginName) const {
|
||||
PluginMetadata match(pluginName);
|
||||
|
||||
auto it = plugins_.find(plugin);
|
||||
auto it = plugins_.find(match);
|
||||
|
||||
if (it != plugins_.end())
|
||||
match = *it;
|
||||
|
||||
// Now we want to also match possibly multiple regex entries.
|
||||
auto regIt = find(regexPlugins_.begin(), regexPlugins_.end(), plugin);
|
||||
auto regIt = find(regexPlugins_.begin(), regexPlugins_.end(), match);
|
||||
while (regIt != regexPlugins_.end()) {
|
||||
match.MergeMetadata(*regIt);
|
||||
|
||||
regIt = find(++regIt, regexPlugins_.end(), plugin);
|
||||
regIt = find(++regIt, regexPlugins_.end(), match);
|
||||
}
|
||||
|
||||
if (match.HasNameOnly()) {
|
||||
@@ -181,8 +181,8 @@ void MetadataList::AddPlugin(const PluginMetadata& plugin) {
|
||||
|
||||
// Doesn't erase matching regex entries, because they might also
|
||||
// be required for other plugins.
|
||||
void MetadataList::ErasePlugin(const PluginMetadata& plugin) {
|
||||
auto it = plugins_.find(plugin);
|
||||
void MetadataList::ErasePlugin(const std::string& pluginName) {
|
||||
auto it = plugins_.find(PluginMetadata(pluginName));
|
||||
|
||||
if (it != plugins_.end()) {
|
||||
plugins_.erase(it);
|
||||
|
||||
@@ -50,12 +50,12 @@ public:
|
||||
void SetGroups(const std::unordered_set<Group>& groups);
|
||||
|
||||
// Merges multiple matching regex entries if any are found.
|
||||
std::optional<PluginMetadata> FindPlugin(const std::string& plugin) const;
|
||||
std::optional<PluginMetadata> FindPlugin(const std::string& pluginName) const;
|
||||
void AddPlugin(const PluginMetadata& plugin);
|
||||
|
||||
// Doesn't erase matching regex entries, because they might also
|
||||
// be required for other plugins.
|
||||
void ErasePlugin(const PluginMetadata& plugin);
|
||||
void ErasePlugin(const std::string& pluginName);
|
||||
|
||||
void AppendMessage(const Message& message);
|
||||
|
||||
|
||||
@@ -354,7 +354,7 @@ TEST_P(MetadataListTest,
|
||||
ASSERT_EQ(blankEsp, plugin.GetName());
|
||||
ASSERT_FALSE(plugin.HasNameOnly());
|
||||
|
||||
metadataList.ErasePlugin(plugin);
|
||||
metadataList.ErasePlugin(plugin.GetName());
|
||||
|
||||
EXPECT_FALSE(metadataList.FindPlugin(plugin.GetName()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user