diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index f278d773..ddee2140 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -70,7 +70,6 @@ set(LIBLOOT_SRC_API_CPP_FILES "${CMAKE_SOURCE_DIR}/src/api/exception/cyclic_interaction_error.cpp" "${CMAKE_SOURCE_DIR}/src/api/exception/exception.cpp" "${CMAKE_SOURCE_DIR}/src/api/exception/undefined_group_error.cpp" - "${CMAKE_SOURCE_DIR}/src/api/metadata/conditional_metadata.cpp" "${CMAKE_SOURCE_DIR}/src/api/metadata/file.cpp" "${CMAKE_SOURCE_DIR}/src/api/metadata/filename.cpp" "${CMAKE_SOURCE_DIR}/src/api/metadata/group.cpp" @@ -97,7 +96,6 @@ set(LIBLOOT_INCLUDE_H_FILES "${CMAKE_SOURCE_DIR}/include/loot/enum/message_type.h" "${CMAKE_SOURCE_DIR}/include/loot/game_interface.h" "${CMAKE_SOURCE_DIR}/include/loot/loot_version.h" - "${CMAKE_SOURCE_DIR}/include/loot/metadata/conditional_metadata.h" "${CMAKE_SOURCE_DIR}/include/loot/metadata/file.h" "${CMAKE_SOURCE_DIR}/include/loot/metadata/filename.h" "${CMAKE_SOURCE_DIR}/include/loot/metadata/group.h" diff --git a/cpp/cmake/tests.cmake b/cpp/cmake/tests.cmake index e0f196b4..d48f717d 100644 --- a/cpp/cmake/tests.cmake +++ b/cpp/cmake/tests.cmake @@ -47,7 +47,6 @@ set(LIBLOOT_SRC_TESTS_INTERFACE_H_FILES "${CMAKE_SOURCE_DIR}/src/tests/api/interface/database_interface_test.h" "${CMAKE_SOURCE_DIR}/src/tests/api/interface/game_interface_test.h" "${CMAKE_SOURCE_DIR}/src/tests/api/interface/is_compatible_test.h" - "${CMAKE_SOURCE_DIR}/src/tests/api/interface/metadata/conditional_metadata_test.h" "${CMAKE_SOURCE_DIR}/src/tests/api/interface/metadata/file_test.h" "${CMAKE_SOURCE_DIR}/src/tests/api/interface/metadata/group_test.h" "${CMAKE_SOURCE_DIR}/src/tests/api/interface/metadata/location_test.h" diff --git a/cpp/docs/api/reference.rst b/cpp/docs/api/reference.rst index fbeef358..ff5691fd 100644 --- a/cpp/docs/api/reference.rst +++ b/cpp/docs/api/reference.rst @@ -56,9 +56,6 @@ Interfaces Classes ======= -.. doxygenclass:: loot::ConditionalMetadata - :members: - .. doxygenclass:: loot::Filename :members: diff --git a/cpp/include/loot/metadata/conditional_metadata.h b/cpp/include/loot/metadata/conditional_metadata.h deleted file mode 100644 index eddb0f1e..00000000 --- a/cpp/include/loot/metadata/conditional_metadata.h +++ /dev/null @@ -1,68 +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 - . - */ -#ifndef LOOT_METADATA_CONDITIONAL_METADATA -#define LOOT_METADATA_CONDITIONAL_METADATA - -#include -#include - -#include "loot/api_decorator.h" - -namespace loot { -/** - * A base class for metadata that can be conditional based on the result of - * evaluating a condition string. - */ -class ConditionalMetadata { -public: - /** - * Construct a ConditionalMetadata object with an empty condition string. - */ - LOOT_API ConditionalMetadata() = default; - - /** - * Construct a ConditionalMetadata object with a given condition string. - * @param condition - * A condition string, as defined in the LOOT metadata syntax - * documentation. - */ - LOOT_API explicit ConditionalMetadata(std::string_view condition); - - /** - * Check if the condition string is non-empty. - * @return True if the condition string is not empty, false otherwise. - */ - LOOT_API bool IsConditional() const; - - /** - * Get the condition string. - * @return The object's condition string. - */ - LOOT_API std::string GetCondition() const; - -private: - std::string condition_; -}; -} -#endif diff --git a/cpp/include/loot/metadata/file.h b/cpp/include/loot/metadata/file.h index 2411b053..1ab3fda7 100644 --- a/cpp/include/loot/metadata/file.h +++ b/cpp/include/loot/metadata/file.h @@ -28,7 +28,6 @@ #include #include "loot/api_decorator.h" -#include "loot/metadata/conditional_metadata.h" #include "loot/metadata/filename.h" #include "loot/metadata/message_content.h" @@ -36,7 +35,7 @@ namespace loot { /** * Represents a file in a game's Data folder, including files in subdirectories. */ -class File : public ConditionalMetadata { +class File { public: /** * Construct a File with blank name, display and condition strings. @@ -87,6 +86,12 @@ public: */ LOOT_API std::vector GetDetail() const; + /** + * Get the condition string. + * @return The file's condition string. + */ + LOOT_API std::string GetCondition() const; + /** * Get the constraint that applies to the file. * @return The file's constraint. @@ -97,6 +102,7 @@ private: Filename name_; std::string display_; std::vector detail_; + std::string condition_; std::string constraint_; }; diff --git a/cpp/include/loot/metadata/message.h b/cpp/include/loot/metadata/message.h index ac43f029..ca805eb7 100644 --- a/cpp/include/loot/metadata/message.h +++ b/cpp/include/loot/metadata/message.h @@ -30,14 +30,13 @@ #include "loot/api_decorator.h" #include "loot/enum/message_type.h" -#include "loot/metadata/conditional_metadata.h" #include "loot/metadata/message_content.h" namespace loot { /** * Represents a message with localisable text content. */ -class Message : public ConditionalMetadata { +class Message { public: /** * Construct a Message object of type 'say' with blank content and condition @@ -85,9 +84,16 @@ public: */ LOOT_API std::vector GetContent() const; + /** + * Get the condition string. + * @return The message's condition string. + */ + LOOT_API std::string GetCondition() const; + private: MessageType type_{MessageType::say}; std::vector content_; + std::string condition_; }; /** diff --git a/cpp/include/loot/metadata/tag.h b/cpp/include/loot/metadata/tag.h index 0bd6477a..a88521bc 100644 --- a/cpp/include/loot/metadata/tag.h +++ b/cpp/include/loot/metadata/tag.h @@ -28,13 +28,12 @@ #include #include "loot/api_decorator.h" -#include "loot/metadata/conditional_metadata.h" namespace loot { /** * Represents a Bash Tag suggestion for a plugin. */ -class Tag : public ConditionalMetadata { +class Tag { public: /** * Construct a Tag object with an empty tag name suggested for addition, with @@ -68,9 +67,16 @@ public: */ LOOT_API std::string GetName() const; + /** + * Get the condition string. + * @return The tag's condition string. + */ + LOOT_API std::string GetCondition() const; + private: std::string name_; bool addTag_{true}; + std::string condition_; }; /** diff --git a/cpp/src/api/metadata/conditional_metadata.cpp b/cpp/src/api/metadata/conditional_metadata.cpp deleted file mode 100644 index c660ed80..00000000 --- a/cpp/src/api/metadata/conditional_metadata.cpp +++ /dev/null @@ -1,34 +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 - . - */ - -#include "loot/metadata/conditional_metadata.h" - -namespace loot { -ConditionalMetadata::ConditionalMetadata(std::string_view condition) : - condition_(condition) {} - -bool ConditionalMetadata::IsConditional() const { return !condition_.empty(); } - -std::string ConditionalMetadata::GetCondition() const { return condition_; } -} diff --git a/cpp/src/api/metadata/file.cpp b/cpp/src/api/metadata/file.cpp index c199ac3c..c872aff5 100644 --- a/cpp/src/api/metadata/file.cpp +++ b/cpp/src/api/metadata/file.cpp @@ -30,10 +30,10 @@ File::File(std::string_view name, std::string_view condition, const std::vector& detail, std::string_view constraint) : - ConditionalMetadata(condition), name_(Filename(name)), display_(display), detail_(detail), + condition_(condition), constraint_(constraint) {} Filename File::GetName() const { return name_; } @@ -42,6 +42,8 @@ std::string File::GetDisplayName() const { return display_; } std::vector File::GetDetail() const { return detail_; } +std::string File::GetCondition() const { return condition_; } + std::string File::GetConstraint() const { return constraint_; } bool operator==(const File& lhs, const File& rhs) { diff --git a/cpp/src/api/metadata/message.cpp b/cpp/src/api/metadata/message.cpp index c3dec404..d3b457e1 100644 --- a/cpp/src/api/metadata/message.cpp +++ b/cpp/src/api/metadata/message.cpp @@ -30,14 +30,12 @@ namespace loot { Message::Message(const MessageType type, std::string_view content, std::string_view condition) : - ConditionalMetadata(condition), - type_(type), - content_({MessageContent(content)}) {} + type_(type), content_({MessageContent(content)}), condition_(condition) {} Message::Message(const MessageType type, const std::vector& content, std::string_view condition) : - ConditionalMetadata(condition), type_(type), content_(content) { + type_(type), content_(content), condition_(condition) { if (content.size() > 1) { bool englishStringExists = false; for (const auto& mc : content) { @@ -55,6 +53,8 @@ MessageType Message::GetType() const { return type_; } std::vector Message::GetContent() const { return content_; } +std::string Message::GetCondition() const { return condition_; } + bool operator==(const Message& lhs, const Message& rhs) { return lhs.GetType() == rhs.GetType() && lhs.GetCondition() == rhs.GetCondition() && diff --git a/cpp/src/api/metadata/tag.cpp b/cpp/src/api/metadata/tag.cpp index 80640d0b..65fb2090 100644 --- a/cpp/src/api/metadata/tag.cpp +++ b/cpp/src/api/metadata/tag.cpp @@ -28,12 +28,14 @@ namespace loot { Tag::Tag(std::string_view tag, const bool isAddition, std::string_view condition) : - ConditionalMetadata(condition), name_(tag), addTag_(isAddition) {} + name_(tag), addTag_(isAddition), condition_(condition) {} bool Tag::IsAddition() const { return addTag_; } std::string Tag::GetName() const { return name_; } +std::string Tag::GetCondition() const { return condition_; } + bool operator==(const Tag& lhs, const Tag& rhs) { return lhs.IsAddition() == rhs.IsAddition() && lhs.GetName() == rhs.GetName() && diff --git a/cpp/src/tests/api/interface/main.cpp b/cpp/src/tests/api/interface/main.cpp index 8d063193..f278e612 100644 --- a/cpp/src/tests/api/interface/main.cpp +++ b/cpp/src/tests/api/interface/main.cpp @@ -25,7 +25,6 @@ #include #include "loot/api.h" -#include "tests/api/interface/metadata/conditional_metadata_test.h" #include "tests/api/interface/metadata/file_test.h" #include "tests/api/interface/metadata/group_test.h" #include "tests/api/interface/metadata/location_test.h" diff --git a/cpp/src/tests/api/interface/metadata/conditional_metadata_test.h b/cpp/src/tests/api/interface/metadata/conditional_metadata_test.h deleted file mode 100644 index 6f8b4804..00000000 --- a/cpp/src/tests/api/interface/metadata/conditional_metadata_test.h +++ /dev/null @@ -1,72 +0,0 @@ -/* LOOT - -A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and -Fallout: New Vegas. - -Copyright (C) 2014-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 -. -*/ - -#ifndef LOOT_TESTS_API_INTERFACE_METADATA_CONDITIONAL_METADATA_TEST -#define LOOT_TESTS_API_INTERFACE_METADATA_CONDITIONAL_METADATA_TEST - -#include "loot/metadata/conditional_metadata.h" -#include "tests/common_game_test_fixture.h" - -namespace loot { -namespace test { -class ConditionalMetadataTest : public CommonGameTestFixture, - public testing::WithParamInterface { -protected: - ConditionalMetadataTest() : CommonGameTestFixture(GetParam()) {} - ConditionalMetadata conditionalMetadata_; -}; - -// Pass an empty first argument, as it's a prefix for the test instantation, -// but we only have the one so no prefix is necessary. -INSTANTIATE_TEST_SUITE_P(, - ConditionalMetadataTest, - ::testing::ValuesIn(ALL_GAME_TYPES)); - -TEST_P(ConditionalMetadataTest, - defaultConstructorShouldSetEmptyConditionString) { - EXPECT_TRUE(conditionalMetadata_.GetCondition().empty()); -} - -TEST_P(ConditionalMetadataTest, - stringConstructorShouldSetConditionToGivenString) { - std::string condition("condition"); - conditionalMetadata_ = ConditionalMetadata(condition); - - EXPECT_EQ(condition, conditionalMetadata_.GetCondition()); -} - -TEST_P(ConditionalMetadataTest, - isConditionalShouldBeFalseForAnEmptyConditionString) { - EXPECT_FALSE(conditionalMetadata_.IsConditional()); -} - -TEST_P(ConditionalMetadataTest, - isConditionalShouldBeTrueForANonEmptyConditionString) { - conditionalMetadata_ = ConditionalMetadata("condition"); - EXPECT_TRUE(conditionalMetadata_.IsConditional()); -} -} -} - -#endif