Remove SimpleMessage

It's no longer used by LOOT.
This commit is contained in:
Oliver Hamlet
2023-09-12 19:56:53 +01:00
parent dd52ad5dfd
commit 2408a7b3ba
8 changed files with 7 additions and 169 deletions
-1
View File
@@ -238,7 +238,6 @@ set(LIBLOOT_INCLUDE_H_FILES
"${CMAKE_SOURCE_DIR}/include/loot/metadata/plugin_metadata.h"
"${CMAKE_SOURCE_DIR}/include/loot/metadata/tag.h"
"${CMAKE_SOURCE_DIR}/include/loot/plugin_interface.h"
"${CMAKE_SOURCE_DIR}/include/loot/struct/simple_message.h"
"${CMAKE_SOURCE_DIR}/include/loot/vertex.h")
set(LIBLOOT_SRC_API_H_FILES
+7
View File
@@ -41,6 +41,13 @@ Fixed
wrong parameter name.
- Cross-compiling from Linux to Windows using MinGW-w64.
Removed
-------
- The ``loot::SimpleMessage`` struct.
- The ``loot::ToSimpleMessage()`` function.
- The ``loot::ToSimpleMessages()`` function.
0.19.4 - 2023-05-06
===================
-10
View File
@@ -24,12 +24,6 @@ Enumerations
.. doxygenenum:: loot::MessageType
Public-Field Data Structures
============================
.. doxygenstruct:: loot::SimpleMessage
:members:
Functions
=========
@@ -45,10 +39,6 @@ Functions
.. doxygenfunction:: loot::SelectMessageContent
.. doxygenfunction:: loot::ToSimpleMessage
.. doxygenfunction:: loot::ToSimpleMessages
Interfaces
==========
-1
View File
@@ -33,7 +33,6 @@
#include "loot/metadata/group.h"
#include "loot/metadata/message.h"
#include "loot/metadata/plugin_metadata.h"
#include "loot/struct/simple_message.h"
namespace loot {
/** @brief The interface provided by API's database handle. */
-37
View File
@@ -31,7 +31,6 @@
#include "loot/enum/message_type.h"
#include "loot/metadata/conditional_metadata.h"
#include "loot/metadata/message_content.h"
#include "loot/struct/simple_message.h"
namespace loot {
/**
@@ -76,14 +75,6 @@ public:
const std::vector<MessageContent>& content,
const std::string& condition = "");
/**
* Construct a Message object from a SimpleMessage object.
* @param message
* The SimpleMessage object.
* @return A Message object.
*/
LOOT_API explicit Message(const SimpleMessage& message);
/**
* Get the message type.
* @return The message type.
@@ -143,34 +134,6 @@ LOOT_API bool operator<=(const Message& lhs, const Message& rhs);
* Message object, false otherwise.
*/
LOOT_API bool operator>=(const Message& lhs, const Message& rhs);
/**
* Get a given Message as a SimpleMessage given a language.
* @param message
* The message to convert.
* @param language
* The preferred language for the message content.
* @return A SimpleMessage object for the preferred language, or for English
* if message text is not available for the given language.
*/
LOOT_API std::optional<SimpleMessage> ToSimpleMessage(
const Message& message,
const std::string& language);
/**
* Get the given messages as simple messages given a language.
* @param messages
* The messages to convert.
* @param language
* The preferred language for the message content.
* @return A vector of SimpleMessage objects for the preferred language, or for
* English if message text is not available for the given language. The
* order of the input Message objects is preserved, though any messages
* without the preferred language or English content will be omitted.
*/
LOOT_API std::vector<SimpleMessage> ToSimpleMessages(
const std::vector<Message>& messages,
const std::string& language);
}
#endif
-50
View File
@@ -1,50 +0,0 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2012-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_SIMPLE_MESSAGE
#define LOOT_SIMPLE_MESSAGE
#include <string>
#include "loot/enum/message_type.h"
namespace loot {
/**
* A structure that holds the type of a message and the message string itself.
*/
struct SimpleMessage {
/** The type of the message. */
MessageType type{MessageType::say};
/** The language the message string is written in. */
std::string language;
/** The message string, which may be formatted using CommonMark. */
std::string text;
/** The message's condition string. */
std::string condition;
};
}
#endif
-37
View File
@@ -53,11 +53,6 @@ Message::Message(const MessageType type,
}
}
Message::Message(const SimpleMessage& message) :
ConditionalMetadata(message.condition),
type_(message.type),
content_({MessageContent(message.text, message.language)}) {}
MessageType Message::GetType() const { return type_; }
std::vector<MessageContent> Message::GetContent() const { return content_; }
@@ -97,36 +92,4 @@ bool operator>(const Message& lhs, const Message& rhs) { return rhs < lhs; }
bool operator<=(const Message& lhs, const Message& rhs) { return !(lhs > rhs); }
bool operator>=(const Message& lhs, const Message& rhs) { return !(lhs < rhs); }
std::optional<SimpleMessage> ToSimpleMessage(const Message& message,
const std::string& language) {
auto content = SelectMessageContent(message.GetContent(), language);
if (!content.has_value()) {
return std::nullopt;
}
SimpleMessage simpleMessage;
simpleMessage.type = message.GetType();
simpleMessage.language = content.value().GetLanguage();
simpleMessage.text = content.value().GetText();
simpleMessage.condition = message.GetCondition();
return simpleMessage;
}
std::vector<SimpleMessage> ToSimpleMessages(
const std::vector<Message>& messages,
const std::string& language) {
std::vector<SimpleMessage> simpleMessages;
for (const auto& message : messages) {
auto simpleMessage = ToSimpleMessage(message, language);
if (simpleMessage.has_value()) {
simpleMessages.push_back(simpleMessage.value());
}
}
return simpleMessages;
}
}
@@ -81,22 +81,6 @@ TEST_P(
std::invalid_argument);
}
TEST_P(MessageTest,
simpleMessageConstructorShouldCreateAMessageWithASingleContentString) {
SimpleMessage simple;
simple.type = MessageType::error;
simple.text = "ERROR";
simple.language = "fr";
simple.condition = "condition";
Message message(simple);
EXPECT_EQ(MessageType::error, message.GetType());
EXPECT_EQ(MessageContents({MessageContent(simple.text, simple.language)}),
message.GetContent());
EXPECT_EQ("condition", message.GetCondition());
}
TEST_P(MessageTest, equalityShouldRequireEqualMessageTypes) {
Message message1(MessageType::say, "content");
Message message2(MessageType::say, "content");
@@ -363,23 +347,6 @@ TEST_P(
EXPECT_TRUE(message2 >= message1);
}
TEST(ToSimpleMessage, shouldSelectTextAndLanguageUsingGetContent) {
Message message(MessageType::warn,
std::vector<MessageContent>({
MessageContent("content1", "de"),
MessageContent("content2"),
MessageContent("content3", "fr"),
}),
"condition1");
SimpleMessage simpleMessage = ToSimpleMessage(message, "fr").value();
EXPECT_EQ(MessageType::warn, simpleMessage.type);
EXPECT_EQ("content3", simpleMessage.text);
EXPECT_EQ("fr", simpleMessage.language);
EXPECT_EQ("condition1", simpleMessage.condition);
}
TEST_P(MessageTest, emittingAsYamlShouldOutputNoteMessageTypeCorrectly) {
Message message(MessageType::say, "content1");
YAML::Emitter emitter;