mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Add include_user_metadata parameter to Database::known_bash_tags()
The C++ wrapper defaults it to true, so the behaviour hasn't changed for existing callers.
This commit is contained in:
@@ -61,8 +61,7 @@ public:
|
||||
* The relative or absolute path to the masterlist file that should be
|
||||
* loaded.
|
||||
*/
|
||||
virtual void LoadMasterlist(
|
||||
const std::filesystem::path& masterlistPath) = 0;
|
||||
virtual void LoadMasterlist(const std::filesystem::path& masterlistPath) = 0;
|
||||
|
||||
/**
|
||||
* @brief Loads the masterlist and masterlist prelude from the paths
|
||||
@@ -141,9 +140,14 @@ public:
|
||||
/**
|
||||
* @brief Gets the Bash Tags that are listed in the loaded metadata lists.
|
||||
* @details Bash Tag suggestions can include Bash Tags not in this list.
|
||||
* @param includeUserMetadata
|
||||
* If true, any Bash Tag metadata present in the userlist is included
|
||||
* in the returned metadata, otherwise the metadata returned only
|
||||
* includes metadata from the masterlist.
|
||||
* @returns The Bash Tag names, which may include duplicates.
|
||||
*/
|
||||
virtual std::vector<std::string> GetKnownBashTags() const = 0;
|
||||
virtual std::vector<std::string> GetKnownBashTags(
|
||||
bool includeUserMetadata = true) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Gets the Bash Tags that are listed in the loaded userlist.
|
||||
|
||||
@@ -60,9 +60,11 @@ void Database::ClearConditionCache() {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> Database::GetKnownBashTags() const {
|
||||
std::vector<std::string> Database::GetKnownBashTags(
|
||||
bool includeUserMetadata) const {
|
||||
try {
|
||||
return convert<std::string>(database_->known_bash_tags());
|
||||
return convert<std::string>(
|
||||
database_->known_bash_tags(includeUserMetadata));
|
||||
} catch (const ::rust::Error& e) {
|
||||
std::rethrow_exception(mapError(e));
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@ public:
|
||||
|
||||
void ClearConditionCache() override;
|
||||
|
||||
std::vector<std::string> GetKnownBashTags() const override;
|
||||
std::vector<std::string> GetKnownBashTags(
|
||||
bool includeUserMetadata = true) const override;
|
||||
|
||||
std::vector<std::string> GetUserKnownBashTags() const override;
|
||||
|
||||
|
||||
+5
-2
@@ -103,12 +103,15 @@ impl Database {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn known_bash_tags(&self) -> Result<Vec<String>, VerboseError> {
|
||||
pub fn known_bash_tags(
|
||||
&self,
|
||||
include_user_metadata: bool,
|
||||
) -> Result<Vec<String>, VerboseError> {
|
||||
Ok(self
|
||||
.0
|
||||
.read()
|
||||
.map_err(DatabaseLockPoisonError::from)?
|
||||
.known_bash_tags())
|
||||
.known_bash_tags(to_merge_mode(include_user_metadata)))
|
||||
}
|
||||
|
||||
pub fn user_known_bash_tags(&self) -> Result<Vec<String>, VerboseError> {
|
||||
|
||||
+1
-1
@@ -268,7 +268,7 @@ mod ffi {
|
||||
|
||||
pub fn clear_condition_cache(&self) -> Result<()>;
|
||||
|
||||
pub fn known_bash_tags(&self) -> Result<Vec<String>>;
|
||||
pub fn known_bash_tags(&self, include_user_metadata: bool) -> Result<Vec<String>>;
|
||||
|
||||
pub fn user_known_bash_tags(&self) -> Result<Vec<String>>;
|
||||
|
||||
|
||||
@@ -485,6 +485,24 @@ TEST_P(DatabaseInterfaceTest,
|
||||
EXPECT_EQ(expectedTags, tags);
|
||||
}
|
||||
|
||||
TEST_P(
|
||||
DatabaseInterfaceTest,
|
||||
getKnownBashTagsShouldReturnAllBashTagsListedInLoadedMasterlistOnlyWhenParamIsFalse) {
|
||||
ASSERT_NO_THROW(GenerateMasterlist());
|
||||
ASSERT_NO_THROW(GenerateUserlist());
|
||||
|
||||
ASSERT_NO_THROW(handle_->GetDatabase().LoadMasterlist(masterlistPath));
|
||||
ASSERT_NO_THROW(handle_->GetDatabase().LoadUserlist(userlistPath_));
|
||||
|
||||
auto tags = handle_->GetDatabase().GetKnownBashTags(false);
|
||||
|
||||
std::vector<std::string> expectedTags({
|
||||
"Actors.ACBS",
|
||||
"C.Climate",
|
||||
});
|
||||
EXPECT_EQ(expectedTags, tags);
|
||||
}
|
||||
|
||||
TEST_P(DatabaseInterfaceTest,
|
||||
getUserKnownBashTagsShouldReturnAllBashTagsListedInLoadedUserMetadata) {
|
||||
ASSERT_NO_THROW(GenerateMasterlist());
|
||||
|
||||
Reference in New Issue
Block a user