From a9a71998f11c3f6d984a5da5ba2aa98d4f872c20 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sat, 15 May 2021 15:26:18 +0100 Subject: [PATCH] Rename the 'info' property in cleaning data objects to 'detail' To be consistent with the new property in File objects, as they share the same type and sematics. --- docs/metadata/data_structures/cleaning.rst | 6 ++-- include/loot/metadata/plugin_cleaning_data.h | 16 ++++----- src/api/metadata/plugin_cleaning_data.cpp | 16 ++++----- src/api/metadata/yaml/plugin_cleaning_data.h | 28 +++++++-------- .../metadata/plugin_cleaning_data_test.h | 36 +++++++++---------- .../internals/metadata/plugin_metadata_test.h | 2 +- 6 files changed, 52 insertions(+), 52 deletions(-) diff --git a/docs/metadata/data_structures/cleaning.rst b/docs/metadata/data_structures/cleaning.rst index d95a1bdb..4e50f3d2 100644 --- a/docs/metadata/data_structures/cleaning.rst +++ b/docs/metadata/data_structures/cleaning.rst @@ -15,7 +15,7 @@ This structure holds information on which versions of a plugin are dirty or clea **Required.** The utility that was used to check the plugin for dirty edits. If available, the version of the utility used should also be included (e.g. ``TES5Edit v3.11``). The string will be interpreted as GitHub Flavored Markdown. -.. describe:: info +.. describe:: detail ``string`` or ``localised content list`` @@ -43,7 +43,7 @@ Equality -------- Two plugin cleaning data structures are equal if all their fields are equal. -`util` field equality is case-sensitive. If the `info` field is a string, it +`util` field equality is case-sensitive. If the `detail` field is a string, it is treated as a localised content data structure. Examples @@ -53,7 +53,7 @@ A dirty plugin:: crc: 0x3DF62ABC util: '[TES5Edit](http://www.nexusmods.com/skyrim/mods/25859) v3.1.1' - info: 'A cleaning guide is available [here](http://www.creationkit.com/index.php?title=TES5Edit_Cleaning_Guide_-_TES5Edit).' + detail: 'A cleaning guide is available [here](http://www.creationkit.com/index.php?title=TES5Edit_Cleaning_Guide_-_TES5Edit).' itm: 4 udr: 160 diff --git a/include/loot/metadata/plugin_cleaning_data.h b/include/loot/metadata/plugin_cleaning_data.h index 634d79ac..dbe4939f 100644 --- a/include/loot/metadata/plugin_cleaning_data.h +++ b/include/loot/metadata/plugin_cleaning_data.h @@ -41,7 +41,7 @@ public: /** * Construct a PluginCleaningData object with zero CRC, ITM count, deleted * reference count and deleted navmesh count values, an empty utility string - * and no info. + * and no detail. * @return A PluginCleaningData object. */ LOOT_API explicit PluginCleaningData(); @@ -49,7 +49,7 @@ public: /** * Construct a PluginCleaningData object with the given CRC and utility, * zero ITM count, deleted reference count and deleted navmesh count - * values and no info. + * values and no detail. * @param crc * The CRC of a plugin. * @param utility @@ -65,7 +65,7 @@ public: * A clean or dirty plugin's CRC. * @param utility * The utility that the plugin cleanliness was checked with. - * @param info + * @param detail * A vector of localised information message strings about the plugin * cleanliness. * @param itm @@ -78,7 +78,7 @@ public: */ LOOT_API explicit PluginCleaningData(uint32_t crc, const std::string& utility, - const std::vector& info, + const std::vector& detail, unsigned int itm, unsigned int ref, unsigned int nav); @@ -135,16 +135,16 @@ public: * cleaning steps. * @return A vector of localised MessageContent objects. */ - LOOT_API std::vector GetInfo() const; + LOOT_API std::vector GetDetail() const; /** - * Choose an info MessageContent object given a preferred language. + * Choose a detail MessageContent object given a preferred language. * @param language * The preferred language's code. * @return The MessageContent object for the preferred language, or if one * does not exist, the English-language MessageContent object. */ - LOOT_API MessageContent ChooseInfo(const std::string& language) const; + LOOT_API MessageContent ChooseDetail(const std::string& language) const; private: uint32_t crc_; @@ -152,7 +152,7 @@ private: unsigned int ref_; unsigned int nav_; std::string utility_; - std::vector info_; + std::vector detail_; }; /** diff --git a/src/api/metadata/plugin_cleaning_data.cpp b/src/api/metadata/plugin_cleaning_data.cpp index ed7b0eca..074b472d 100644 --- a/src/api/metadata/plugin_cleaning_data.cpp +++ b/src/api/metadata/plugin_cleaning_data.cpp @@ -41,7 +41,7 @@ PluginCleaningData::PluginCleaningData(uint32_t crc, PluginCleaningData::PluginCleaningData(uint32_t crc, const std::string& utility, - const std::vector& info, + const std::vector& detail, unsigned int itm, unsigned int ref, unsigned int nav) : @@ -50,7 +50,7 @@ PluginCleaningData::PluginCleaningData(uint32_t crc, ref_(ref), nav_(nav), utility_(utility), - info_(info) {} + detail_(detail) {} bool PluginCleaningData::operator<(const PluginCleaningData& rhs) const { if (crc_ < rhs.crc_) { @@ -93,11 +93,11 @@ bool PluginCleaningData::operator<(const PluginCleaningData& rhs) const { return false; } - return info_ < rhs.info_; + return detail_ < rhs.detail_; } bool PluginCleaningData::operator==(const PluginCleaningData& rhs) const { - return crc_ == rhs.crc_ && utility_ == rhs.utility_ && info_ == rhs.info_ && + return crc_ == rhs.crc_ && utility_ == rhs.utility_ && detail_ == rhs.detail_ && itm_ == rhs.itm_ && ref_ == rhs.ref_ && nav_ == rhs.nav_; } @@ -113,13 +113,13 @@ unsigned int PluginCleaningData::GetDeletedNavmeshCount() const { return nav_; } std::string PluginCleaningData::GetCleaningUtility() const { return utility_; } -std::vector PluginCleaningData::GetInfo() const { - return info_; +std::vector PluginCleaningData::GetDetail() const { + return detail_; } -MessageContent PluginCleaningData::ChooseInfo( +MessageContent PluginCleaningData::ChooseDetail( const std::string& language) const { - return MessageContent::Choose(info_, language); + return MessageContent::Choose(detail_, language); } bool operator!=(const PluginCleaningData& lhs, const PluginCleaningData& rhs) { diff --git a/src/api/metadata/yaml/plugin_cleaning_data.h b/src/api/metadata/yaml/plugin_cleaning_data.h index e2c5f450..1aae874d 100644 --- a/src/api/metadata/yaml/plugin_cleaning_data.h +++ b/src/api/metadata/yaml/plugin_cleaning_data.h @@ -41,7 +41,7 @@ struct convert { Node node; node["crc"] = rhs.GetCRC(); node["util"] = rhs.GetCleaningUtility(); - node["info"] = rhs.GetInfo(); + node["detail"] = rhs.GetDetail(); if (rhs.GetITMCount() > 0) node["itm"] = rhs.GetITMCount(); @@ -78,20 +78,20 @@ struct convert { std::string utility = node["util"].as(); - std::vector info; - if (node["info"]) { - if (node["info"].IsSequence()) - info = node["info"].as>(); + std::vector detail; + if (node["detail"]) { + if (node["detail"].IsSequence()) + detail = node["detail"].as>(); else { - info.push_back(loot::MessageContent(node["info"].as())); + detail.push_back(loot::MessageContent(node["detail"].as())); } } // Check now that at least one item in info is English if there are multiple // items. - if (info.size() > 1) { + if (detail.size() > 1) { bool found = false; - for (const auto& mc : info) { + for (const auto& mc : detail) { if (mc.GetLanguage() == loot::MessageContent::defaultLanguage) found = true; } @@ -101,7 +101,7 @@ struct convert { "must contain an English info string"); } - rhs = loot::PluginCleaningData(crc, utility, info, itm, ref, nav); + rhs = loot::PluginCleaningData(crc, utility, detail, itm, ref, nav); return true; } @@ -111,12 +111,12 @@ inline Emitter& operator<<(Emitter& out, const loot::PluginCleaningData& rhs) { out << BeginMap << Key << "crc" << Value << Hex << rhs.GetCRC() << Dec << Key << "util" << Value << YAML::SingleQuoted << rhs.GetCleaningUtility(); - if (!rhs.GetInfo().empty()) { - if (rhs.GetInfo().size() == 1) - out << Key << "info" << Value << YAML::SingleQuoted - << rhs.GetInfo().front().GetText(); + if (!rhs.GetDetail().empty()) { + if (rhs.GetDetail().size() == 1) + out << Key << "detail" << Value << YAML::SingleQuoted + << rhs.GetDetail().front().GetText(); else - out << Key << "info" << Value << rhs.GetInfo(); + out << Key << "detail" << Value << rhs.GetDetail(); } if (rhs.GetITMCount() > 0) diff --git a/src/tests/api/internals/metadata/plugin_cleaning_data_test.h b/src/tests/api/internals/metadata/plugin_cleaning_data_test.h index 9d21427c..22b2c988 100644 --- a/src/tests/api/internals/metadata/plugin_cleaning_data_test.h +++ b/src/tests/api/internals/metadata/plugin_cleaning_data_test.h @@ -57,7 +57,7 @@ TEST_P(PluginCleaningDataTest, EXPECT_EQ(0, info.GetDeletedReferenceCount()); EXPECT_EQ(0, info.GetDeletedNavmeshCount()); EXPECT_TRUE(info.GetCleaningUtility().empty()); - EXPECT_TRUE(info.GetInfo().empty()); + EXPECT_TRUE(info.GetDetail().empty()); } TEST_P(PluginCleaningDataTest, contentConstructorShouldStoreAllGivenData) { @@ -67,7 +67,7 @@ TEST_P(PluginCleaningDataTest, contentConstructorShouldStoreAllGivenData) { EXPECT_EQ(10, info.GetDeletedReferenceCount()); EXPECT_EQ(30, info.GetDeletedNavmeshCount()); EXPECT_EQ("cleaner", info.GetCleaningUtility()); - EXPECT_EQ(info_, info.GetInfo()); + EXPECT_EQ(info_, info.GetDetail()); } TEST_P(PluginCleaningDataTest, equalityShouldCheckEqualityOfAllFields) { @@ -319,24 +319,24 @@ TEST_P( } TEST_P(PluginCleaningDataTest, - chooseInfoShouldCreateADefaultContentObjectIfNoneExists) { + chooseDetailShouldCreateADefaultContentObjectIfNoneExists) { PluginCleaningData dirtyInfo( 0xDEADBEEF, "cleaner", std::vector(), 2, 10, 30); EXPECT_EQ(MessageContent(), - dirtyInfo.ChooseInfo(MessageContent::defaultLanguage)); + dirtyInfo.ChooseDetail(MessageContent::defaultLanguage)); } TEST_P(PluginCleaningDataTest, - chooseInfoShouldLeaveTheContentUnchangedIfOnlyOneStringExists) { + chooseDetailShouldLeaveTheContentUnchangedIfOnlyOneStringExists) { PluginCleaningData dirtyInfo(0xDEADBEEF, "cleaner", info_, 2, 10, 30); - EXPECT_EQ(info_[0], dirtyInfo.ChooseInfo(french)); - EXPECT_EQ(info_[0], dirtyInfo.ChooseInfo(MessageContent::defaultLanguage)); + EXPECT_EQ(info_[0], dirtyInfo.ChooseDetail(french)); + EXPECT_EQ(info_[0], dirtyInfo.ChooseDetail(MessageContent::defaultLanguage)); } TEST_P( PluginCleaningDataTest, - chooseInfoShouldSelectTheEnglishStringIfNoStringExistsForTheGivenLanguage) { + chooseDetailShouldSelectTheEnglishStringIfNoStringExistsForTheGivenLanguage) { MessageContent content("content1", MessageContent::defaultLanguage); std::vector info({ content, @@ -344,11 +344,11 @@ TEST_P( }); PluginCleaningData dirtyInfo(0xDEADBEEF, "cleaner", info, 2, 10, 30); - EXPECT_EQ(content, dirtyInfo.ChooseInfo(french)); + EXPECT_EQ(content, dirtyInfo.ChooseDetail(french)); } TEST_P(PluginCleaningDataTest, - chooseInfoShouldSelectTheStringForTheGivenLanguageIfOneExists) { + chooseDetailShouldSelectTheStringForTheGivenLanguageIfOneExists) { MessageContent frenchContent("content3", french); std::vector info({ MessageContent("content1", german), @@ -357,7 +357,7 @@ TEST_P(PluginCleaningDataTest, }); PluginCleaningData dirtyInfo(0xDEADBEEF, "cleaner", info, 2, 10, 30); - EXPECT_EQ(frenchContent, dirtyInfo.ChooseInfo(french)); + EXPECT_EQ(frenchContent, dirtyInfo.ChooseDetail(french)); } TEST_P(PluginCleaningDataTest, emittingAsYamlShouldOutputAllNonZeroCounts) { @@ -366,7 +366,7 @@ TEST_P(PluginCleaningDataTest, emittingAsYamlShouldOutputAllNonZeroCounts) { emitter << info; EXPECT_STREQ( - "crc: 0x12345678\nutil: 'cleaner'\ninfo: 'info'\nitm: 2\nudr: 10\nnav: " + "crc: 0x12345678\nutil: 'cleaner'\ndetail: 'info'\nitm: 2\nudr: 10\nnav: " "30", emitter.c_str()); } @@ -376,7 +376,7 @@ TEST_P(PluginCleaningDataTest, emittingAsYamlShouldOmitAllZeroCounts) { YAML::Emitter emitter; emitter << info; - EXPECT_STREQ("crc: 0x12345678\nutil: 'cleaner'\ninfo: 'info'", + EXPECT_STREQ("crc: 0x12345678\nutil: 'cleaner'\ndetail: 'info'", emitter.c_str()); } @@ -387,7 +387,7 @@ TEST_P(PluginCleaningDataTest, encodingAsYamlShouldOmitAllZeroCountFields) { EXPECT_EQ(0x12345678, node["crc"].as()); EXPECT_EQ("cleaner", node["util"].as()); - EXPECT_EQ(info_, node["info"].as>()); + EXPECT_EQ(info_, node["detail"].as>()); EXPECT_FALSE(node["itm"]); EXPECT_FALSE(node["udr"]); EXPECT_FALSE(node["nav"]); @@ -401,7 +401,7 @@ TEST_P(PluginCleaningDataTest, EXPECT_EQ(0x12345678, node["crc"].as()); EXPECT_EQ("cleaner", node["util"].as()); - EXPECT_EQ(info_, node["info"].as>()); + EXPECT_EQ(info_, node["detail"].as>()); EXPECT_EQ(2, node["itm"].as()); EXPECT_EQ(10, node["udr"].as()); EXPECT_EQ(30, node["nav"].as()); @@ -413,7 +413,7 @@ TEST_P(PluginCleaningDataTest, PluginCleaningData info = node.as(); EXPECT_EQ(0x12345678, info.GetCRC()); - EXPECT_TRUE(info.GetInfo().empty()); + EXPECT_TRUE(info.GetDetail().empty()); EXPECT_EQ(0, info.GetITMCount()); EXPECT_EQ(0, info.GetDeletedReferenceCount()); EXPECT_EQ(0, info.GetDeletedNavmeshCount()); @@ -422,11 +422,11 @@ TEST_P(PluginCleaningDataTest, TEST_P(PluginCleaningDataTest, decodingFromYamlShouldStoreAllNonZeroCounts) { YAML::Node node = YAML::Load( - "{crc: 0x12345678, util: cleaner, info: info, itm: 2, udr: 10, nav: 30}"); + "{crc: 0x12345678, util: cleaner, detail: info, itm: 2, udr: 10, nav: 30}"); PluginCleaningData info = node.as(); EXPECT_EQ(0x12345678, info.GetCRC()); - EXPECT_EQ(info_, info.GetInfo()); + EXPECT_EQ(info_, info.GetDetail()); EXPECT_EQ(2, info.GetITMCount()); EXPECT_EQ(10, info.GetDeletedReferenceCount()); EXPECT_EQ(30, info.GetDeletedNavmeshCount()); diff --git a/src/tests/api/internals/metadata/plugin_metadata_test.h b/src/tests/api/internals/metadata/plugin_metadata_test.h index 5a93b63c..f00fe0dd 100644 --- a/src/tests/api/internals/metadata/plugin_metadata_test.h +++ b/src/tests/api/internals/metadata/plugin_metadata_test.h @@ -714,7 +714,7 @@ TEST_P(PluginMetadataTest, "dirty:\n" " - crc: 0x5\n" " util: 'utility'\n" - " info: 'info'\n" + " detail: 'info'\n" " udr: 1\n" " nav: 2", emitter.c_str());