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.
This commit is contained in:
Oliver Hamlet
2021-05-22 19:26:29 +01:00
parent fc22d3d7a4
commit a9a71998f1
6 changed files with 52 additions and 52 deletions
+3 -3
View File
@@ -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
+8 -8
View File
@@ -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<MessageContent>& info,
const std::vector<MessageContent>& 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<MessageContent> GetInfo() const;
LOOT_API std::vector<MessageContent> 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<MessageContent> info_;
std::vector<MessageContent> detail_;
};
/**
+8 -8
View File
@@ -41,7 +41,7 @@ PluginCleaningData::PluginCleaningData(uint32_t crc,
PluginCleaningData::PluginCleaningData(uint32_t crc,
const std::string& utility,
const std::vector<MessageContent>& info,
const std::vector<MessageContent>& 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<MessageContent> PluginCleaningData::GetInfo() const {
return info_;
std::vector<MessageContent> 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) {
+14 -14
View File
@@ -41,7 +41,7 @@ struct convert<loot::PluginCleaningData> {
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<loot::PluginCleaningData> {
std::string utility = node["util"].as<std::string>();
std::vector<loot::MessageContent> info;
if (node["info"]) {
if (node["info"].IsSequence())
info = node["info"].as<std::vector<loot::MessageContent>>();
std::vector<loot::MessageContent> detail;
if (node["detail"]) {
if (node["detail"].IsSequence())
detail = node["detail"].as<std::vector<loot::MessageContent>>();
else {
info.push_back(loot::MessageContent(node["info"].as<std::string>()));
detail.push_back(loot::MessageContent(node["detail"].as<std::string>()));
}
}
// 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<loot::PluginCleaningData> {
"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)
@@ -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<MessageContent>(), 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<MessageContent> 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<MessageContent> 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<uint32_t>());
EXPECT_EQ("cleaner", node["util"].as<std::string>());
EXPECT_EQ(info_, node["info"].as<std::vector<MessageContent>>());
EXPECT_EQ(info_, node["detail"].as<std::vector<MessageContent>>());
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<uint32_t>());
EXPECT_EQ("cleaner", node["util"].as<std::string>());
EXPECT_EQ(info_, node["info"].as<std::vector<MessageContent>>());
EXPECT_EQ(info_, node["detail"].as<std::vector<MessageContent>>());
EXPECT_EQ(2, node["itm"].as<unsigned int>());
EXPECT_EQ(10, node["udr"].as<unsigned int>());
EXPECT_EQ(30, node["nav"].as<unsigned int>());
@@ -413,7 +413,7 @@ TEST_P(PluginCleaningDataTest,
PluginCleaningData info = node.as<PluginCleaningData>();
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<PluginCleaningData>();
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());
@@ -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());