From 52382ddb208259529dd0d603e70f04177a01bfb8 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sat, 28 Jan 2017 12:50:01 +0000 Subject: [PATCH] Refactor metadata class headers This is unfinished, as there are a couple of classes that have methods that take Game objects to eval metadata, and these will probably not end up exposed in the API. None of the classes are documented either. YAML encode/decode code is now stored in separate headers that depend on yaml-cpp and boost, and which will not be part of the API proper. --- CMakeLists.txt | 35 +++-- .../helpers => include/loot}/language.h | 5 +- .../loot}/metadata/conditional_metadata.h | 4 +- include/loot/metadata/file.h | 49 ++++++ include/loot/metadata/location.h | 47 ++++++ include/loot/metadata/message.h | 59 +++++++ include/loot/metadata/message_content.h | 51 ++++++ include/loot/metadata/plugin_cleaning_data.h | 71 +++++++++ include/loot/metadata/plugin_metadata.h | 129 +++++++++++++++ .../loot}/metadata/priority.h | 4 +- include/loot/metadata/tag.h | 50 ++++++ .../metadata => include/loot/yaml}/file.h | 43 +++-- .../metadata => include/loot/yaml}/location.h | 33 ++-- .../metadata => include/loot/yaml}/message.h | 56 +++---- .../loot/yaml}/message_content.h | 34 ++-- .../loot/yaml}/plugin_cleaning_data.h | 68 ++++---- .../loot/yaml}/plugin_metadata.h | 147 +++++++----------- .../loot/yaml/set.h | 0 .../metadata => include/loot/yaml}/tag.h | 39 ++--- src/api/api_database.cpp | 3 + src/backend/game/game.cpp | 1 + src/backend/helpers/language.cpp | 2 +- src/backend/masterlist.cpp | 1 + src/backend/metadata/condition_evaluator.cpp | 2 + src/backend/metadata/conditional_metadata.cpp | 2 +- src/backend/metadata/file.cpp | 25 +-- src/backend/metadata/location.cpp | 16 +- src/backend/metadata/message.cpp | 30 +--- src/backend/metadata/message_content.cpp | 18 +-- src/backend/metadata/plugin_cleaning_data.cpp | 28 +--- src/backend/metadata/plugin_metadata.cpp | 54 +------ src/backend/metadata/priority.cpp | 2 +- src/backend/metadata/tag.cpp | 24 +-- src/backend/metadata_list.cpp | 1 + src/backend/metadata_list.h | 2 +- src/backend/plugin/plugin.h | 2 +- src/gui/editor_message.h | 4 +- src/gui/loot_app.cpp | 2 +- src/gui/query/copy_metadata_query.h | 1 + src/gui/query/get_languages_query.h | 2 +- src/gui/query_handler.h | 2 +- src/gui/state/loot_settings.h | 2 +- src/gui/state/loot_state.cpp | 3 +- src/tests/backend/helpers/language_test.h | 2 +- .../backend/helpers/yaml_set_helpers_test.h | 2 +- .../metadata/conditional_metadata_test.h | 2 +- src/tests/backend/metadata/file_test.h | 4 +- src/tests/backend/metadata/location_test.h | 4 +- .../backend/metadata/message_content_test.h | 4 +- src/tests/backend/metadata/message_test.h | 3 +- .../metadata/plugin_cleaning_data_test.h | 3 +- .../backend/metadata/plugin_metadata_test.h | 4 +- src/tests/backend/metadata/priority_test.h | 2 +- src/tests/backend/metadata/tag_test.h | 4 +- src/tests/printers.h | 12 +- 55 files changed, 722 insertions(+), 477 deletions(-) rename {src/backend/helpers => include/loot}/language.h (91%) rename {src/backend => include/loot}/metadata/conditional_metadata.h (92%) create mode 100644 include/loot/metadata/file.h create mode 100644 include/loot/metadata/location.h create mode 100644 include/loot/metadata/message.h create mode 100644 include/loot/metadata/message_content.h create mode 100644 include/loot/metadata/plugin_cleaning_data.h create mode 100644 include/loot/metadata/plugin_metadata.h rename {src/backend => include/loot}/metadata/priority.h (95%) create mode 100644 include/loot/metadata/tag.h rename {src/backend/metadata => include/loot/yaml}/file.h (77%) rename {src/backend/metadata => include/loot/yaml}/location.h (79%) rename {src/backend/metadata => include/loot/yaml}/message.h (78%) rename {src/backend/metadata => include/loot/yaml}/message_content.h (75%) rename {src/backend/metadata => include/loot/yaml}/plugin_cleaning_data.h (70%) rename {src/backend/metadata => include/loot/yaml}/plugin_metadata.h (55%) rename src/backend/helpers/yaml_set_helpers.h => include/loot/yaml/set.h (100%) rename {src/backend/metadata => include/loot/yaml}/tag.h (81%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f0d6f79..63010b60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -189,15 +189,6 @@ set (LOOT_SRC "${CMAKE_BINARY_DIR}/generated/loot_version.cpp" set (LOOT_HEADERS "${CMAKE_SOURCE_DIR}/src/backend/metadata/condition_evaluator.h" "${CMAKE_SOURCE_DIR}/src/backend/metadata/condition_grammar.h" - "${CMAKE_SOURCE_DIR}/src/backend/metadata/conditional_metadata.h" - "${CMAKE_SOURCE_DIR}/src/backend/metadata/file.h" - "${CMAKE_SOURCE_DIR}/src/backend/metadata/location.h" - "${CMAKE_SOURCE_DIR}/src/backend/metadata/message.h" - "${CMAKE_SOURCE_DIR}/src/backend/metadata/message_content.h" - "${CMAKE_SOURCE_DIR}/src/backend/metadata/plugin_cleaning_data.h" - "${CMAKE_SOURCE_DIR}/src/backend/metadata/plugin_metadata.h" - "${CMAKE_SOURCE_DIR}/src/backend/metadata/priority.h" - "${CMAKE_SOURCE_DIR}/src/backend/metadata/tag.h" "${CMAKE_SOURCE_DIR}/src/backend/game/game.h" "${CMAKE_SOURCE_DIR}/src/backend/game/game_cache.h" "${CMAKE_SOURCE_DIR}/src/backend/game/game_settings.h" @@ -208,10 +199,7 @@ set (LOOT_HEADERS "${CMAKE_SOURCE_DIR}/src/backend/metadata/condition_evaluator. "${CMAKE_SOURCE_DIR}/src/backend/plugin/plugin_sorter.h" "${CMAKE_SOURCE_DIR}/src/backend/helpers/git_helper.h" "${CMAKE_SOURCE_DIR}/src/backend/helpers/helpers.h" - "${CMAKE_SOURCE_DIR}/src/gui/query/json.h" - "${CMAKE_SOURCE_DIR}/src/backend/helpers/language.h" "${CMAKE_SOURCE_DIR}/src/backend/helpers/version.h" - "${CMAKE_SOURCE_DIR}/src/backend/helpers/yaml_set_helpers.h" "${CMAKE_SOURCE_DIR}/include/loot/api_decorator.h" "${CMAKE_SOURCE_DIR}/include/loot/exception/error_categories.h" "${CMAKE_SOURCE_DIR}/include/loot/exception/condition_syntax_error.h" @@ -221,8 +209,26 @@ set (LOOT_HEADERS "${CMAKE_SOURCE_DIR}/src/backend/metadata/condition_evaluator. "${CMAKE_SOURCE_DIR}/include/loot/exception/git_state_error.h" "${CMAKE_SOURCE_DIR}/include/loot/enum/game_type.h" "${CMAKE_SOURCE_DIR}/include/loot/enum/language_code.h" - "${CMAKE_SOURCE_DIR}/include/loot/loot_version.h" - "${CMAKE_SOURCE_DIR}/include/loot/enum/message_type.h") + "${CMAKE_SOURCE_DIR}/include/loot/enum/message_type.h" + "${CMAKE_SOURCE_DIR}/include/loot/metadata/conditional_metadata.h" + "${CMAKE_SOURCE_DIR}/include/loot/metadata/file.h" + "${CMAKE_SOURCE_DIR}/include/loot/metadata/location.h" + "${CMAKE_SOURCE_DIR}/include/loot/metadata/message.h" + "${CMAKE_SOURCE_DIR}/include/loot/metadata/message_content.h" + "${CMAKE_SOURCE_DIR}/include/loot/metadata/plugin_cleaning_data.h" + "${CMAKE_SOURCE_DIR}/include/loot/metadata/plugin_metadata.h" + "${CMAKE_SOURCE_DIR}/include/loot/metadata/priority.h" + "${CMAKE_SOURCE_DIR}/include/loot/metadata/tag.h" + "${CMAKE_SOURCE_DIR}/include/loot/yaml/file.h" + "${CMAKE_SOURCE_DIR}/include/loot/yaml/location.h" + "${CMAKE_SOURCE_DIR}/include/loot/yaml/message.h" + "${CMAKE_SOURCE_DIR}/include/loot/yaml/message_content.h" + "${CMAKE_SOURCE_DIR}/include/loot/yaml/plugin_cleaning_data.h" + "${CMAKE_SOURCE_DIR}/include/loot/yaml/plugin_metadata.h" + "${CMAKE_SOURCE_DIR}/include/loot/yaml/set.h" + "${CMAKE_SOURCE_DIR}/include/loot/yaml/tag.h" + "${CMAKE_SOURCE_DIR}/include/loot/language.h" + "${CMAKE_SOURCE_DIR}/include/loot/loot_version.h") set (LOOT_GUI_SRC "${CMAKE_SOURCE_DIR}/src/gui/main.cpp" "${CMAKE_SOURCE_DIR}/src/gui/helpers.cpp" @@ -240,6 +246,7 @@ set (LOOT_GUI_HEADERS "${CMAKE_SOURCE_DIR}/src/gui/editor_message.h" "${CMAKE_SOURCE_DIR}/src/gui/loot_handler.h" "${CMAKE_SOURCE_DIR}/src/gui/loot_app.h" "${CMAKE_SOURCE_DIR}/src/gui/loot_scheme_handler_factory.h" + "${CMAKE_SOURCE_DIR}/src/gui/query/json.h" "${CMAKE_SOURCE_DIR}/src/gui/query/query.h" "${CMAKE_SOURCE_DIR}/src/gui/query/apply_sort_query.h" "${CMAKE_SOURCE_DIR}/src/gui/query/cancel_find_query.h" diff --git a/src/backend/helpers/language.h b/include/loot/language.h similarity index 91% rename from src/backend/helpers/language.h rename to include/loot/language.h index 3e422f05..918f8b94 100644 --- a/src/backend/helpers/language.h +++ b/include/loot/language.h @@ -22,8 +22,8 @@ . */ -#ifndef LOOT_BACKEND_HELPERS_LANGUAGE -#define LOOT_BACKEND_HELPERS_LANGUAGE +#ifndef LOOT_LANGUAGE +#define LOOT_LANGUAGE #include #include @@ -31,7 +31,6 @@ #include "loot/enum/language_code.h" namespace loot { - //Language class for simpler language support. class Language { public: diff --git a/src/backend/metadata/conditional_metadata.h b/include/loot/metadata/conditional_metadata.h similarity index 92% rename from src/backend/metadata/conditional_metadata.h rename to include/loot/metadata/conditional_metadata.h index e6745cf2..af758709 100644 --- a/src/backend/metadata/conditional_metadata.h +++ b/include/loot/metadata/conditional_metadata.h @@ -21,8 +21,8 @@ along with LOOT. If not, see . */ -#ifndef LOOT_BACKEND_METADATA_CONDITIONAL_METADATA -#define LOOT_BACKEND_METADATA_CONDITIONAL_METADATA +#ifndef LOOT_METADATA_CONDITIONAL_METADATA +#define LOOT_METADATA_CONDITIONAL_METADATA #include diff --git a/include/loot/metadata/file.h b/include/loot/metadata/file.h new file mode 100644 index 00000000..c6082f9e --- /dev/null +++ b/include/loot/metadata/file.h @@ -0,0 +1,49 @@ +/* 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_FILE +#define LOOT_METADATA_FILE + +#include + +#include "loot/metadata/conditional_metadata.h" + +namespace loot { +class File : public ConditionalMetadata { +public: + File(); + File(const std::string& name, const std::string& display = "", + const std::string& condition = ""); + + bool operator < (const File& rhs) const; + bool operator == (const File& rhs) const; + + std::string Name() const; + std::string DisplayName() const; +private: + std::string name_; + std::string display_; +}; +} + +#endif diff --git a/include/loot/metadata/location.h b/include/loot/metadata/location.h new file mode 100644 index 00000000..39af217f --- /dev/null +++ b/include/loot/metadata/location.h @@ -0,0 +1,47 @@ +/* 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_LOCATION +#define LOOT_METADATA_LOCATION + +#include +#include + +namespace loot { +class Location { +public: + Location(); + Location(const std::string& url, const std::string& name = ""); + + bool operator < (const Location& rhs) const; + bool operator == (const Location& rhs) const; + + std::string URL() const; + std::string Name() const; +private: + std::string url_; + std::string name_; +}; +} + +#endif diff --git a/include/loot/metadata/message.h b/include/loot/metadata/message.h new file mode 100644 index 00000000..a72b1774 --- /dev/null +++ b/include/loot/metadata/message.h @@ -0,0 +1,59 @@ +/* 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_MESSAGE +#define LOOT_METADATA_MESSAGE + +#include +#include + +#include "loot/metadata/conditional_metadata.h" +#include "loot/metadata/message_content.h" +#include "loot/enum/language_code.h" +#include "loot/enum/message_type.h" +#include "loot/struct/simple_message.h" + +namespace loot { +class Message : public ConditionalMetadata { +public: + Message(); + Message(const MessageType type, const std::string& content, + const std::string& condition = ""); + Message(const MessageType type, const std::vector& content, + const std::string& condition = ""); + + bool operator < (const Message& rhs) const; + bool operator == (const Message& rhs) const; + + MessageType GetType() const; + std::vector GetContent() const; + MessageContent GetContent(const LanguageCode language) const; + + SimpleMessage ToSimpleMessage(const LanguageCode language) const; +private: + MessageType type_; + std::vector content_; +}; +} + +#endif diff --git a/include/loot/metadata/message_content.h b/include/loot/metadata/message_content.h new file mode 100644 index 00000000..276ed07c --- /dev/null +++ b/include/loot/metadata/message_content.h @@ -0,0 +1,51 @@ +/* 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_MESSAGE_CONTENT +#define LOOT_METADATA_MESSAGE_CONTENT + +#include + +#include "loot/language.h" + +namespace loot { +class MessageContent { +public: + MessageContent(); + MessageContent(const std::string& text, const LanguageCode language); + + std::string GetText() const; + LanguageCode GetLanguage() const; + + bool operator < (const MessageContent& rhs) const; + bool operator == (const MessageContent& rhs) const; + + static MessageContent Choose(const std::vector content, + const LanguageCode language); +private: + std::string text_; + LanguageCode language_; +}; +} + +#endif diff --git a/include/loot/metadata/plugin_cleaning_data.h b/include/loot/metadata/plugin_cleaning_data.h new file mode 100644 index 00000000..330b45eb --- /dev/null +++ b/include/loot/metadata/plugin_cleaning_data.h @@ -0,0 +1,71 @@ +/* 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_PLUGIN_CLEANING_DATA +#define LOOT_METADATA_PLUGIN_CLEANING_DATA + +#include +#include + +#include "loot/metadata/message.h" + +namespace loot { +class Game; + +class PluginCleaningData { +public: + PluginCleaningData(); + PluginCleaningData(uint32_t crc, const std::string& utility); + PluginCleaningData(uint32_t crc, + const std::string& utility, + const std::vector& info, + unsigned int itm, + unsigned int ref, + unsigned int nav); + + bool operator < (const PluginCleaningData& rhs) const; + bool operator == (const PluginCleaningData& rhs) const; + + uint32_t CRC() const; + unsigned int ITMs() const; + unsigned int DeletedRefs() const; + unsigned int DeletedNavmeshes() const; + std::string CleaningUtility() const; + std::vector Info() const; + + MessageContent ChooseInfo(const LanguageCode language) const; + Message AsMessage() const; + + bool EvalCondition(Game& game, const std::string& pluginName) const; +private: + uint32_t crc_; + unsigned int itm_; + unsigned int ref_; + unsigned int nav_; + std::string utility_; + std::vector info_; +}; +} + +#endif diff --git a/include/loot/metadata/plugin_metadata.h b/include/loot/metadata/plugin_metadata.h new file mode 100644 index 00000000..959975bb --- /dev/null +++ b/include/loot/metadata/plugin_metadata.h @@ -0,0 +1,129 @@ +/* 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_PLUGIN_METADATA +#define LOOT_METADATA_PLUGIN_METADATA + +#include +#include +#include +#include +#include +#include + +#include "loot/yaml/set.h" +#include "loot/metadata/file.h" +#include "loot/metadata/location.h" +#include "loot/metadata/message.h" +#include "loot/metadata/plugin_cleaning_data.h" +#include "loot/metadata/priority.h" +#include "loot/metadata/tag.h" + +namespace loot { +class Game; + +class PluginMetadata { +public: + PluginMetadata(); + PluginMetadata(const std::string& name); + + //Merges from the given plugin into this one, unless there is already equal metadata present. + //For 'enabled' and 'priority' metadata, use the given plugin's values, but if the 'priority' user value is zero, ignore it. + void MergeMetadata(const PluginMetadata& plugin); + + //Returns the difference in metadata between the two plugins. + //For 'enabled', use this plugin's value. + //For 'priority', use 0 if the two plugin priorities are equal, and make it not explicit. Otherwise use this plugin's value. + PluginMetadata DiffMetadata(const PluginMetadata& plugin) const; + + // Returns metadata in this plugin not in the given plugin. + //For 'enabled', use this plugin's value. + //For 'priority', use 0 if the two plugin priorities are equal, and make it not explicit. Otherwise use this plugin's value. + PluginMetadata NewMetadata(const PluginMetadata& plugin) const; + + std::string Name() const; + std::string LowercasedName() const; + bool Enabled() const; + Priority LocalPriority() const; + Priority GlobalPriority() const; + std::set LoadAfter() const; + std::set Reqs() const; + std::set Incs() const; + std::vector Messages() const; + std::set Tags() const; + std::set DirtyInfo() const; + std::set CleanInfo() const; + std::set Locations() const; + + std::vector SimpleMessages(const LanguageCode language) const; + + void Enabled(const bool enabled); + void LocalPriority(const Priority& priority); + void GlobalPriority(const Priority& priority); + void LoadAfter(const std::set& after); + void Reqs(const std::set& reqs); + void Incs(const std::set& incs); + void Messages(const std::vector& messages); + void Tags(const std::set& tags); + void DirtyInfo(const std::set& info); + void CleanInfo(const std::set& info); + void Locations(const std::set& locations); + + PluginMetadata& EvalAllConditions(Game& game); + bool HasNameOnly() const; + bool IsRegexPlugin() const; + + //Compare name strings. + bool operator == (const PluginMetadata& rhs) const; + bool operator != (const PluginMetadata& rhs) const; + + //Compare name string. + bool operator == (const std::string& rhs) const; + bool operator != (const std::string& rhs) const; +protected: + std::vector messages_; + std::set tags_; +private: + std::string name_; + bool enabled_; //Default to true. + Priority localPriority_; + Priority globalPriority_; + std::set loadAfter_; + std::set requirements_; + std::set incompatibilities_; + std::set dirtyInfo_; + std::set cleanInfo_; + std::set locations_; +}; +} + +namespace std { +template<> +struct hash { + size_t operator() (const loot::PluginMetadata& plugin) const { + return hash()(plugin.LowercasedName()); + } +}; +} + +#endif diff --git a/src/backend/metadata/priority.h b/include/loot/metadata/priority.h similarity index 95% rename from src/backend/metadata/priority.h rename to include/loot/metadata/priority.h index 0b6f131f..eb6dc307 100644 --- a/src/backend/metadata/priority.h +++ b/include/loot/metadata/priority.h @@ -21,8 +21,8 @@ along with LOOT. If not, see . */ -#ifndef LOOT_BACKEND_METADATA_PRIORITY -#define LOOT_BACKEND_METADATA_PRIORITY +#ifndef LOOT_METADATA_PRIORITY +#define LOOT_METADATA_PRIORITY #include diff --git a/include/loot/metadata/tag.h b/include/loot/metadata/tag.h new file mode 100644 index 00000000..f666ee71 --- /dev/null +++ b/include/loot/metadata/tag.h @@ -0,0 +1,50 @@ +/* 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_TAG +#define LOOT_METADATA_TAG + +#include + +#include "loot/metadata/conditional_metadata.h" + +namespace loot { +class Tag : public ConditionalMetadata { +public: + Tag(); + Tag(const std::string& tag, + const bool isAddition = true, + const std::string& condition = ""); + + bool operator < (const Tag& rhs) const; + bool operator == (const Tag& rhs) const; + + bool IsAddition() const; + std::string Name() const; +private: + std::string name_; + bool addTag_; +}; +} + +#endif diff --git a/src/backend/metadata/file.h b/include/loot/yaml/file.h similarity index 77% rename from src/backend/metadata/file.h rename to include/loot/yaml/file.h index 06dffea3..9fe7141b 100644 --- a/src/backend/metadata/file.h +++ b/include/loot/yaml/file.h @@ -21,32 +21,14 @@ along with LOOT. If not, see . */ -#ifndef LOOT_BACKEND_METADATA_FILE -#define LOOT_BACKEND_METADATA_FILE +#ifndef LOOT_YAML_FILE +#define LOOT_YAML_FILE #include #include -#include "backend/metadata/conditional_metadata.h" - -namespace loot { -class File : public ConditionalMetadata { -public: - File(); - File(const std::string& name, const std::string& display = "", - const std::string& condition = ""); - - bool operator < (const File& rhs) const; - bool operator == (const File& rhs) const; - - std::string Name() const; - std::string DisplayName() const; -private: - std::string name_; - std::string display_; -}; -} +#include "loot/metadata/file.h" namespace YAML { template<> @@ -93,7 +75,24 @@ struct convert { } }; -Emitter& operator << (Emitter& out, const loot::File& rhs); +inline Emitter& operator << (Emitter& out, const loot::File& rhs) { + if (!rhs.IsConditional() && (rhs.DisplayName().empty() || rhs.DisplayName() == rhs.Name())) + out << YAML::SingleQuoted << rhs.Name(); + else { + out << BeginMap + << Key << "name" << Value << YAML::SingleQuoted << rhs.Name(); + + if (rhs.IsConditional()) + out << Key << "condition" << Value << YAML::SingleQuoted << rhs.Condition(); + + if (rhs.DisplayName() != rhs.Name()) + out << Key << "display" << Value << YAML::SingleQuoted << rhs.DisplayName(); + + out << EndMap; + } + + return out; +} } #endif diff --git a/src/backend/metadata/location.h b/include/loot/yaml/location.h similarity index 79% rename from src/backend/metadata/location.h rename to include/loot/yaml/location.h index ae543776..7dc04762 100644 --- a/src/backend/metadata/location.h +++ b/include/loot/yaml/location.h @@ -21,30 +21,15 @@ along with LOOT. If not, see . */ -#ifndef LOOT_BACKEND_METADATA_LOCATION -#define LOOT_BACKEND_METADATA_LOCATION +#ifndef LOOT_YAML_LOCATION +#define LOOT_YAML_LOCATION #include #include #include -namespace loot { -class Location { -public: - Location(); - Location(const std::string& url, const std::string& name = ""); - - bool operator < (const Location& rhs) const; - bool operator == (const Location& rhs) const; - - std::string URL() const; - std::string Name() const; -private: - std::string url_; - std::string name_; -}; -} +#include "loot/metadata/location.h" namespace YAML { template<> @@ -82,7 +67,17 @@ struct convert { } }; -Emitter& operator << (Emitter& out, const loot::Location& rhs); +inline Emitter& operator << (Emitter& out, const loot::Location& rhs) { + if (rhs.Name().empty()) + out << YAML::SingleQuoted << rhs.URL(); + else { + out << BeginMap + << Key << "link" << Value << YAML::SingleQuoted << rhs.URL() + << Key << "name" << Value << YAML::SingleQuoted << rhs.Name() + << EndMap; + } + return out; +} } #endif diff --git a/src/backend/metadata/message.h b/include/loot/yaml/message.h similarity index 78% rename from src/backend/metadata/message.h rename to include/loot/yaml/message.h index 6e58efe8..cf2fdfd9 100644 --- a/src/backend/metadata/message.h +++ b/include/loot/yaml/message.h @@ -21,8 +21,8 @@ along with LOOT. If not, see . */ -#ifndef LOOT_BACKEND_METADATA_MESSAGE -#define LOOT_BACKEND_METADATA_MESSAGE +#ifndef LOOT_YAML_MESSAGE +#define LOOT_YAML_MESSAGE #include #include @@ -31,34 +31,7 @@ #include #include -#include "backend/metadata/conditional_metadata.h" -#include "backend/metadata/message_content.h" -#include "loot/enum/language_code.h" -#include "loot/enum/message_type.h" -#include "loot/struct/simple_message.h" - -namespace loot { -class Message : public ConditionalMetadata { -public: - Message(); - Message(const MessageType type, const std::string& content, - const std::string& condition = ""); - Message(const MessageType type, const std::vector& content, - const std::string& condition = ""); - - bool operator < (const Message& rhs) const; - bool operator == (const Message& rhs) const; - - MessageType GetType() const; - std::vector GetContent() const; - MessageContent GetContent(const LanguageCode language) const; - - SimpleMessage ToSimpleMessage(const LanguageCode language) const; -private: - MessageType type_; - std::vector content_; -}; -} +#include "loot/metadata/message.h" namespace YAML { template<> @@ -150,7 +123,28 @@ struct convert { } }; -Emitter& operator << (Emitter& out, const loot::Message& rhs); +inline Emitter& operator << (Emitter& out, const loot::Message& rhs) { + out << BeginMap; + + if (rhs.GetType() == loot::MessageType::say) + out << Key << "type" << Value << "say"; + else if (rhs.GetType() == loot::MessageType::warn) + out << Key << "type" << Value << "warn"; + else + out << Key << "type" << Value << "error"; + + if (rhs.GetContent().size() == 1) + out << Key << "content" << Value << YAML::SingleQuoted << rhs.GetContent().front().GetText(); + else + out << Key << "content" << Value << rhs.GetContent(); + + if (rhs.IsConditional()) + out << Key << "condition" << Value << YAML::SingleQuoted << rhs.Condition(); + + out << EndMap; + + return out; +} } #endif diff --git a/src/backend/metadata/message_content.h b/include/loot/yaml/message_content.h similarity index 75% rename from src/backend/metadata/message_content.h rename to include/loot/yaml/message_content.h index d80d57a2..3f49ca43 100644 --- a/src/backend/metadata/message_content.h +++ b/include/loot/yaml/message_content.h @@ -28,27 +28,7 @@ #include -#include "backend/helpers/language.h" - -namespace loot { -class MessageContent { -public: - MessageContent(); - MessageContent(const std::string& text, const LanguageCode language); - - std::string GetText() const; - LanguageCode GetLanguage() const; - - bool operator < (const MessageContent& rhs) const; - bool operator == (const MessageContent& rhs) const; - - static MessageContent Choose(const std::vector content, - const LanguageCode language); -private: - std::string text_; - LanguageCode language_; -}; -} +#include "loot/metadata/message_content.h" namespace YAML { template<> @@ -78,7 +58,17 @@ struct convert { } }; -Emitter& operator << (Emitter& out, const loot::MessageContent& rhs); +inline Emitter& operator << (Emitter& out, const loot::MessageContent& rhs) { + out << BeginMap; + + out << Key << "lang" << Value << loot::Language(rhs.GetLanguage()).GetLocale(); + + out << Key << "text" << Value << YAML::SingleQuoted << rhs.GetText(); + + out << EndMap; + + return out; +} } #endif diff --git a/src/backend/metadata/plugin_cleaning_data.h b/include/loot/yaml/plugin_cleaning_data.h similarity index 70% rename from src/backend/metadata/plugin_cleaning_data.h rename to include/loot/yaml/plugin_cleaning_data.h index 4e2a1ae5..03f7d6c4 100644 --- a/src/backend/metadata/plugin_cleaning_data.h +++ b/include/loot/yaml/plugin_cleaning_data.h @@ -22,53 +22,15 @@ . */ -#ifndef LOOT_BACKEND_METADATA_PLUGIN_CLEANING_DATA -#define LOOT_BACKEND_METADATA_PLUGIN_CLEANING_DATA +#ifndef LOOT_YAML_PLUGIN_CLEANING_DATA +#define LOOT_YAML_PLUGIN_CLEANING_DATA #include #include #include -#include "backend/metadata/message.h" - -namespace loot { -class Game; - -class PluginCleaningData { -public: - PluginCleaningData(); - PluginCleaningData(uint32_t crc, const std::string& utility); - PluginCleaningData(uint32_t crc, - const std::string& utility, - const std::vector& info, - unsigned int itm, - unsigned int ref, - unsigned int nav); - - bool operator < (const PluginCleaningData& rhs) const; - bool operator == (const PluginCleaningData& rhs) const; - - uint32_t CRC() const; - unsigned int ITMs() const; - unsigned int DeletedRefs() const; - unsigned int DeletedNavmeshes() const; - std::string CleaningUtility() const; - std::vector Info() const; - - MessageContent ChooseInfo(const LanguageCode language) const; - Message AsMessage() const; - - bool EvalCondition(Game& game, const std::string& pluginName) const; -private: - uint32_t crc_; - unsigned int itm_; - unsigned int ref_; - unsigned int nav_; - std::string utility_; - std::vector info_; -}; -} +#include "loot/metadata/plugin_cleaning_data.h" namespace YAML { template<> @@ -135,7 +97,29 @@ struct convert { } }; -Emitter& operator << (Emitter& out, const loot::PluginCleaningData& rhs); +inline Emitter& operator << (Emitter& out, const loot::PluginCleaningData& rhs) { + out << BeginMap + << Key << "crc" << Value << Hex << rhs.CRC() << Dec + << Key << "util" << Value << YAML::SingleQuoted << rhs.CleaningUtility(); + + if (!rhs.Info().empty()) { + if (rhs.Info().size() == 1) + out << Key << "info" << Value << YAML::SingleQuoted << rhs.Info().front().GetText(); + else + out << Key << "info" << Value << rhs.Info(); + } + + if (rhs.ITMs() > 0) + out << Key << "itm" << Value << rhs.ITMs(); + if (rhs.DeletedRefs() > 0) + out << Key << "udr" << Value << rhs.DeletedRefs(); + if (rhs.DeletedNavmeshes() > 0) + out << Key << "nav" << Value << rhs.DeletedNavmeshes(); + + out << EndMap; + + return out; +} } #endif diff --git a/src/backend/metadata/plugin_metadata.h b/include/loot/yaml/plugin_metadata.h similarity index 55% rename from src/backend/metadata/plugin_metadata.h rename to include/loot/yaml/plugin_metadata.h index cd674ae4..2cb96dc6 100644 --- a/src/backend/metadata/plugin_metadata.h +++ b/include/loot/yaml/plugin_metadata.h @@ -31,102 +31,17 @@ #include #include -#include #include -#include "backend/helpers/yaml_set_helpers.h" -#include "backend/metadata/file.h" -#include "backend/metadata/location.h" -#include "backend/metadata/message.h" -#include "backend/metadata/plugin_cleaning_data.h" -#include "backend/metadata/priority.h" -#include "backend/metadata/tag.h" +#include "loot/metadata/plugin_metadata.h" -namespace loot { -class Game; - -class PluginMetadata { -public: - PluginMetadata(); - PluginMetadata(const std::string& name); - - //Merges from the given plugin into this one, unless there is already equal metadata present. - //For 'enabled' and 'priority' metadata, use the given plugin's values, but if the 'priority' user value is zero, ignore it. - void MergeMetadata(const PluginMetadata& plugin); - - //Returns the difference in metadata between the two plugins. - //For 'enabled', use this plugin's value. - //For 'priority', use 0 if the two plugin priorities are equal, and make it not explicit. Otherwise use this plugin's value. - PluginMetadata DiffMetadata(const PluginMetadata& plugin) const; - - // Returns metadata in this plugin not in the given plugin. - //For 'enabled', use this plugin's value. - //For 'priority', use 0 if the two plugin priorities are equal, and make it not explicit. Otherwise use this plugin's value. - PluginMetadata NewMetadata(const PluginMetadata& plugin) const; - - std::string Name() const; - bool Enabled() const; - Priority LocalPriority() const; - Priority GlobalPriority() const; - std::set LoadAfter() const; - std::set Reqs() const; - std::set Incs() const; - std::vector Messages() const; - std::set Tags() const; - std::set DirtyInfo() const; - std::set CleanInfo() const; - std::set Locations() const; - - std::vector SimpleMessages(const LanguageCode language) const; - - void Enabled(const bool enabled); - void LocalPriority(const Priority& priority); - void GlobalPriority(const Priority& priority); - void LoadAfter(const std::set& after); - void Reqs(const std::set& reqs); - void Incs(const std::set& incs); - void Messages(const std::vector& messages); - void Tags(const std::set& tags); - void DirtyInfo(const std::set& info); - void CleanInfo(const std::set& info); - void Locations(const std::set& locations); - - PluginMetadata& EvalAllConditions(Game& game); - bool HasNameOnly() const; - bool IsRegexPlugin() const; - - //Compare name strings. - bool operator == (const PluginMetadata& rhs) const; - bool operator != (const PluginMetadata& rhs) const; - - //Compare name string. - bool operator == (const std::string& rhs) const; - bool operator != (const std::string& rhs) const; -protected: - std::vector messages_; - std::set tags_; -private: - std::string name_; - bool enabled_; //Default to true. - Priority localPriority_; - Priority globalPriority_; - std::set loadAfter_; - std::set requirements_; - std::set incompatibilities_; - std::set dirtyInfo_; - std::set cleanInfo_; - std::set locations_; -}; -} - -namespace std { -template<> -struct hash { - size_t operator() (const loot::PluginMetadata& plugin) const { - return hash()(boost::locale::to_lower(plugin.Name())); - } -}; -} +#include "loot/yaml/file.h" +#include "loot/yaml/location.h" +#include "loot/yaml/message_content.h" +#include "loot/yaml/message.h" +#include "loot/yaml/plugin_cleaning_data.h" +#include "loot/yaml/set.h" +#include "loot/yaml/tag.h" namespace YAML { template<> @@ -223,7 +138,51 @@ struct convert { } }; -Emitter& operator << (Emitter& out, const loot::PluginMetadata& rhs); +inline Emitter& operator << (Emitter& out, const loot::PluginMetadata& rhs) { + if (!rhs.HasNameOnly()) { + out << BeginMap + << Key << "name" << Value << YAML::SingleQuoted << rhs.Name(); + + if (!rhs.Enabled()) + out << Key << "enabled" << Value << rhs.Enabled(); + + if (rhs.LocalPriority().isExplicit()) { + out << Key << "priority" << Value << rhs.LocalPriority().getValue(); + } + + if (rhs.GlobalPriority().isExplicit()) { + out << Key << "global_priority" << Value << rhs.GlobalPriority().getValue(); + } + + if (!rhs.LoadAfter().empty()) + out << Key << "after" << Value << rhs.LoadAfter(); + + if (!rhs.Reqs().empty()) + out << Key << "req" << Value << rhs.Reqs(); + + if (!rhs.Incs().empty()) + out << Key << "inc" << Value << rhs.Incs(); + + if (!rhs.Messages().empty()) + out << Key << "msg" << Value << rhs.Messages(); + + if (!rhs.Tags().empty()) + out << Key << "tag" << Value << rhs.Tags(); + + if (!rhs.DirtyInfo().empty()) + out << Key << "dirty" << Value << rhs.DirtyInfo(); + + if (!rhs.CleanInfo().empty()) + out << Key << "clean" << Value << rhs.CleanInfo(); + + if (!rhs.Locations().empty()) + out << Key << "url" << Value << rhs.Locations(); + + out << EndMap; + } + + return out; +} } #endif diff --git a/src/backend/helpers/yaml_set_helpers.h b/include/loot/yaml/set.h similarity index 100% rename from src/backend/helpers/yaml_set_helpers.h rename to include/loot/yaml/set.h diff --git a/src/backend/metadata/tag.h b/include/loot/yaml/tag.h similarity index 81% rename from src/backend/metadata/tag.h rename to include/loot/yaml/tag.h index 0a5aa7af..c2c47d93 100644 --- a/src/backend/metadata/tag.h +++ b/include/loot/yaml/tag.h @@ -28,24 +28,7 @@ #include -#include "backend/metadata/conditional_metadata.h" - -namespace loot { -class Tag : public ConditionalMetadata { -public: - Tag(); - Tag(const std::string& tag, const bool isAddition = true, const std::string& condition = ""); - - bool operator < (const Tag& rhs) const; - bool operator == (const Tag& rhs) const; - - bool IsAddition() const; - std::string Name() const; -private: - std::string name_; - bool addTag_; -}; -} +#include "loot/metadata/tag.h" namespace YAML { template<> @@ -92,7 +75,25 @@ struct convert { } }; -Emitter& operator << (Emitter& out, const loot::Tag& rhs); +inline Emitter& operator << (Emitter& out, const loot::Tag& rhs) { + if (!rhs.IsConditional()) { + if (rhs.IsAddition()) + out << rhs.Name(); + else + out << ('-' + rhs.Name()); + } else { + out << BeginMap; + if (rhs.IsAddition()) + out << Key << "name" << Value << rhs.Name(); + else + out << Key << "name" << Value << ('-' + rhs.Name()); + + out << Key << "condition" << Value << YAML::SingleQuoted << rhs.Condition() + << EndMap; + } + + return out; +} } #endif diff --git a/src/api/api_database.cpp b/src/api/api_database.cpp index 5703225f..4a979b70 100644 --- a/src/api/api_database.cpp +++ b/src/api/api_database.cpp @@ -27,7 +27,10 @@ #include #include +#include + #include "loot/exception/file_access_error.h" +#include "loot/yaml/plugin_metadata.h" #include "backend/game/game.h" #include "backend/plugin/plugin_sorter.h" diff --git a/src/backend/game/game.cpp b/src/backend/game/game.cpp index f531a95e..735a819d 100644 --- a/src/backend/game/game.cpp +++ b/src/backend/game/game.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include diff --git a/src/backend/helpers/language.cpp b/src/backend/helpers/language.cpp index 770c135f..3d7ffa41 100644 --- a/src/backend/helpers/language.cpp +++ b/src/backend/helpers/language.cpp @@ -22,7 +22,7 @@ . */ -#include "backend/helpers/language.h" +#include "loot/language.h" namespace loot { const std::vector Language::codes({ diff --git a/src/backend/masterlist.cpp b/src/backend/masterlist.cpp index 8188d751..abfbc408 100644 --- a/src/backend/masterlist.cpp +++ b/src/backend/masterlist.cpp @@ -24,6 +24,7 @@ #include "backend/masterlist.h" +#include #include #include "loot/exception/file_access_error.h" diff --git a/src/backend/metadata/condition_evaluator.cpp b/src/backend/metadata/condition_evaluator.cpp index b7608295..236b36c9 100644 --- a/src/backend/metadata/condition_evaluator.cpp +++ b/src/backend/metadata/condition_evaluator.cpp @@ -24,6 +24,8 @@ #include "backend/metadata/condition_evaluator.h" +#include +#include #include #include "backend/helpers/helpers.h" diff --git a/src/backend/metadata/conditional_metadata.cpp b/src/backend/metadata/conditional_metadata.cpp index 4876d39d..d801933c 100644 --- a/src/backend/metadata/conditional_metadata.cpp +++ b/src/backend/metadata/conditional_metadata.cpp @@ -22,7 +22,7 @@ . */ -#include "backend/metadata/conditional_metadata.h" +#include "loot/metadata/conditional_metadata.h" #include #include diff --git a/src/backend/metadata/file.cpp b/src/backend/metadata/file.cpp index b21c5672..0eb385b1 100644 --- a/src/backend/metadata/file.cpp +++ b/src/backend/metadata/file.cpp @@ -22,10 +22,12 @@ . */ -#include "backend/metadata/file.h" +#include "loot/metadata/file.h" #include +#include "loot/yaml/file.h" + namespace loot { File::File() {} @@ -51,24 +53,3 @@ std::string File::DisplayName() const { return display_; } } - -namespace YAML { -Emitter& operator << (Emitter& out, const loot::File& rhs) { - if (!rhs.IsConditional() && (rhs.DisplayName().empty() || rhs.DisplayName() == rhs.Name())) - out << YAML::SingleQuoted << rhs.Name(); - else { - out << BeginMap - << Key << "name" << Value << YAML::SingleQuoted << rhs.Name(); - - if (rhs.IsConditional()) - out << Key << "condition" << Value << YAML::SingleQuoted << rhs.Condition(); - - if (rhs.DisplayName() != rhs.Name()) - out << Key << "display" << Value << YAML::SingleQuoted << rhs.DisplayName(); - - out << EndMap; - } - - return out; -} -} diff --git a/src/backend/metadata/location.cpp b/src/backend/metadata/location.cpp index 12be5213..5751ca19 100644 --- a/src/backend/metadata/location.cpp +++ b/src/backend/metadata/location.cpp @@ -22,7 +22,7 @@ . */ -#include "location.h" +#include "loot/metadata/location.h" #include @@ -47,17 +47,3 @@ std::string Location::Name() const { return name_; } } - -namespace YAML { -Emitter& operator << (Emitter& out, const loot::Location& rhs) { - if (rhs.Name().empty()) - out << YAML::SingleQuoted << rhs.URL(); - else { - out << BeginMap - << Key << "link" << Value << YAML::SingleQuoted << rhs.URL() - << Key << "name" << Value << YAML::SingleQuoted << rhs.Name() - << EndMap; - } - return out; -} -} diff --git a/src/backend/metadata/message.cpp b/src/backend/metadata/message.cpp index 0b6146ef..e823c7cb 100644 --- a/src/backend/metadata/message.cpp +++ b/src/backend/metadata/message.cpp @@ -22,12 +22,13 @@ . */ -#include "backend/metadata/message.h" +#include "loot/metadata/message.h" +#include #include #include "backend/game/game.h" -#include "backend/helpers/language.h" +#include "loot/language.h" namespace loot { Message::Message() : type_(MessageType::say) {} @@ -84,28 +85,3 @@ SimpleMessage Message::ToSimpleMessage(const LanguageCode language) const { return simpleMessage; } } - -namespace YAML { -Emitter& operator << (Emitter& out, const loot::Message& rhs) { - out << BeginMap; - - if (rhs.GetType() == loot::MessageType::say) - out << Key << "type" << Value << "say"; - else if (rhs.GetType() == loot::MessageType::warn) - out << Key << "type" << Value << "warn"; - else - out << Key << "type" << Value << "error"; - - if (rhs.GetContent().size() == 1) - out << Key << "content" << Value << YAML::SingleQuoted << rhs.GetContent().front().GetText(); - else - out << Key << "content" << Value << rhs.GetContent(); - - if (rhs.IsConditional()) - out << Key << "condition" << Value << YAML::SingleQuoted << rhs.Condition(); - - out << EndMap; - - return out; -} -} diff --git a/src/backend/metadata/message_content.cpp b/src/backend/metadata/message_content.cpp index 3b530cb0..ede2d298 100644 --- a/src/backend/metadata/message_content.cpp +++ b/src/backend/metadata/message_content.cpp @@ -22,11 +22,11 @@ . */ -#include "backend/metadata/message_content.h" +#include "loot/metadata/message_content.h" #include -#include "backend/helpers/language.h" +#include "loot/language.h" namespace loot { MessageContent::MessageContent() : language_(LanguageCode::english) {} @@ -66,17 +66,3 @@ MessageContent MessageContent::Choose(const std::vector content, } } } - -namespace YAML { -Emitter& operator << (Emitter& out, const loot::MessageContent& rhs) { - out << BeginMap; - - out << Key << "lang" << Value << loot::Language(rhs.GetLanguage()).GetLocale(); - - out << Key << "text" << Value << YAML::SingleQuoted << rhs.GetText(); - - out << EndMap; - - return out; -} -} diff --git a/src/backend/metadata/plugin_cleaning_data.cpp b/src/backend/metadata/plugin_cleaning_data.cpp index 2552821b..c4cf3fb7 100644 --- a/src/backend/metadata/plugin_cleaning_data.cpp +++ b/src/backend/metadata/plugin_cleaning_data.cpp @@ -22,7 +22,7 @@ . */ -#include "backend/metadata/plugin_cleaning_data.h" +#include "loot/metadata/plugin_cleaning_data.h" #include #include @@ -147,29 +147,3 @@ bool PluginCleaningData::EvalCondition(Game& game, const std::string& pluginName return crc_ == crc; } } - -namespace YAML { -Emitter& operator << (Emitter& out, const loot::PluginCleaningData& rhs) { - out << BeginMap - << Key << "crc" << Value << Hex << rhs.CRC() << Dec - << Key << "util" << Value << YAML::SingleQuoted << rhs.CleaningUtility(); - - if (!rhs.Info().empty()) { - if (rhs.Info().size() == 1) - out << Key << "info" << Value << YAML::SingleQuoted << rhs.Info().front().GetText(); - else - out << Key << "info" << Value << rhs.Info(); - } - - if (rhs.ITMs() > 0) - out << Key << "itm" << Value << rhs.ITMs(); - if (rhs.DeletedRefs() > 0) - out << Key << "udr" << Value << rhs.DeletedRefs(); - if (rhs.DeletedNavmeshes() > 0) - out << Key << "nav" << Value << rhs.DeletedNavmeshes(); - - out << EndMap; - - return out; -} -} diff --git a/src/backend/metadata/plugin_metadata.cpp b/src/backend/metadata/plugin_metadata.cpp index 15b1d5ea..98dd70e5 100644 --- a/src/backend/metadata/plugin_metadata.cpp +++ b/src/backend/metadata/plugin_metadata.cpp @@ -22,7 +22,7 @@ . */ -#include "plugin_metadata.h" +#include "loot/metadata/plugin_metadata.h" #include @@ -256,6 +256,10 @@ std::string PluginMetadata::Name() const { return name_; } +std::string PluginMetadata::LowercasedName() const { + return boost::locale::to_lower(name_); +} + bool PluginMetadata::Enabled() const { return enabled_; } @@ -455,51 +459,3 @@ bool PluginMetadata::operator != (const std::string& rhs) const { return !(*this == rhs); } } - -namespace YAML { -Emitter& operator << (Emitter& out, const loot::PluginMetadata& rhs) { - if (!rhs.HasNameOnly()) { - out << BeginMap - << Key << "name" << Value << YAML::SingleQuoted << rhs.Name(); - - if (!rhs.Enabled()) - out << Key << "enabled" << Value << rhs.Enabled(); - - if (rhs.LocalPriority().isExplicit()) { - out << Key << "priority" << Value << rhs.LocalPriority().getValue(); - } - - if (rhs.GlobalPriority().isExplicit()) { - out << Key << "global_priority" << Value << rhs.GlobalPriority().getValue(); - } - - if (!rhs.LoadAfter().empty()) - out << Key << "after" << Value << rhs.LoadAfter(); - - if (!rhs.Reqs().empty()) - out << Key << "req" << Value << rhs.Reqs(); - - if (!rhs.Incs().empty()) - out << Key << "inc" << Value << rhs.Incs(); - - if (!rhs.Messages().empty()) - out << Key << "msg" << Value << rhs.Messages(); - - if (!rhs.Tags().empty()) - out << Key << "tag" << Value << rhs.Tags(); - - if (!rhs.DirtyInfo().empty()) - out << Key << "dirty" << Value << rhs.DirtyInfo(); - - if (!rhs.CleanInfo().empty()) - out << Key << "clean" << Value << rhs.CleanInfo(); - - if (!rhs.Locations().empty()) - out << Key << "url" << Value << rhs.Locations(); - - out << EndMap; - } - - return out; -} -} diff --git a/src/backend/metadata/priority.cpp b/src/backend/metadata/priority.cpp index 6b7a5aec..111fc732 100644 --- a/src/backend/metadata/priority.cpp +++ b/src/backend/metadata/priority.cpp @@ -22,7 +22,7 @@ . */ -#include "backend/metadata/priority.h" +#include "loot/metadata/priority.h" namespace loot { Priority::Priority() : value_(0), isExplicitZeroValue_(false) {} diff --git a/src/backend/metadata/tag.cpp b/src/backend/metadata/tag.cpp index e8aa11e2..440537e3 100644 --- a/src/backend/metadata/tag.cpp +++ b/src/backend/metadata/tag.cpp @@ -22,7 +22,7 @@ . */ -#include "backend/metadata/tag.h" +#include "loot/metadata/tag.h" #include @@ -50,25 +50,3 @@ std::string Tag::Name() const { return name_; } } - -namespace YAML { -Emitter& operator << (Emitter& out, const loot::Tag& rhs) { - if (!rhs.IsConditional()) { - if (rhs.IsAddition()) - out << rhs.Name(); - else - out << ('-' + rhs.Name()); - } else { - out << BeginMap; - if (rhs.IsAddition()) - out << Key << "name" << Value << rhs.Name(); - else - out << Key << "name" << Value << ('-' + rhs.Name()); - - out << Key << "condition" << Value << YAML::SingleQuoted << rhs.Condition() - << EndMap; - } - - return out; -} -} diff --git a/src/backend/metadata_list.cpp b/src/backend/metadata_list.cpp index 7b743bbc..1455f764 100644 --- a/src/backend/metadata_list.cpp +++ b/src/backend/metadata_list.cpp @@ -29,6 +29,7 @@ #include #include "loot/exception/file_access_error.h" +#include "loot/yaml/plugin_metadata.h" #include "backend/game/game.h" namespace loot { diff --git a/src/backend/metadata_list.h b/src/backend/metadata_list.h index cba3d175..a3626fed 100644 --- a/src/backend/metadata_list.h +++ b/src/backend/metadata_list.h @@ -31,7 +31,7 @@ #include -#include "backend/metadata/plugin_metadata.h" +#include "loot/metadata/plugin_metadata.h" namespace loot { class Game; diff --git a/src/backend/plugin/plugin.h b/src/backend/plugin/plugin.h index 50917c08..05bba79a 100644 --- a/src/backend/plugin/plugin.h +++ b/src/backend/plugin/plugin.h @@ -33,7 +33,7 @@ #include #include -#include "backend/metadata/plugin_metadata.h" +#include "loot/metadata/plugin_metadata.h" #include "loot/enum/game_type.h" namespace loot { diff --git a/src/gui/editor_message.h b/src/gui/editor_message.h index c1178673..8d6259e0 100644 --- a/src/gui/editor_message.h +++ b/src/gui/editor_message.h @@ -24,7 +24,9 @@ #ifndef LOOT_GUI_EDITOR_MESSAGE #define LOOT_GUI_EDITOR_MESSAGE -#include "backend/metadata/message.h" +#include + +#include "loot/metadata/message.h" #include "loot/struct/simple_message.h" namespace loot { diff --git a/src/gui/loot_app.cpp b/src/gui/loot_app.cpp index c41feb3a..5899438c 100644 --- a/src/gui/loot_app.cpp +++ b/src/gui/loot_app.cpp @@ -30,7 +30,7 @@ #include "gui/state/loot_paths.h" #include "backend/helpers/helpers.h" -#include "backend/helpers/language.h" +#include "loot/language.h" #include "gui/loot_handler.h" #include "gui/loot_scheme_handler_factory.h" diff --git a/src/gui/query/copy_metadata_query.h b/src/gui/query/copy_metadata_query.h index a8f3c8ee..3f4b4466 100644 --- a/src/gui/query/copy_metadata_query.h +++ b/src/gui/query/copy_metadata_query.h @@ -28,6 +28,7 @@ along with LOOT. If not, see #include #include "gui/query/clipboard_query.h" +#include "loot/yaml/plugin_metadata.h" namespace loot { class CopyMetadataQuery : public ClipboardQuery { diff --git a/src/gui/query/get_languages_query.h b/src/gui/query/get_languages_query.h index 10bcc375..ac5460ab 100644 --- a/src/gui/query/get_languages_query.h +++ b/src/gui/query/get_languages_query.h @@ -26,7 +26,7 @@ along with LOOT. If not, see #define LOOT_GUI_QUERY_GET_LANGUAGES_QUERY #include "gui/query/json.h" -#include "backend/helpers/language.h" +#include "loot/language.h" #include "gui/query/query.h" namespace loot { diff --git a/src/gui/query_handler.h b/src/gui/query_handler.h index 215122ec..9420cd6d 100644 --- a/src/gui/query_handler.h +++ b/src/gui/query_handler.h @@ -30,7 +30,7 @@ #include "gui/state/loot_state.h" #include "backend/plugin/plugin.h" -#include "backend/metadata/plugin_metadata.h" +#include "loot/metadata/plugin_metadata.h" #include "gui/editor_message.h" #include "gui/query/query.h" diff --git a/src/gui/state/loot_settings.h b/src/gui/state/loot_settings.h index 2166b29e..1cc84a26 100644 --- a/src/gui/state/loot_settings.h +++ b/src/gui/state/loot_settings.h @@ -34,7 +34,7 @@ #include #include "backend/game/game_settings.h" -#include "backend/helpers/language.h" +#include "loot/language.h" namespace loot { class LootSettings { diff --git a/src/gui/state/loot_state.cpp b/src/gui/state/loot_state.cpp index b485af8f..425a140a 100644 --- a/src/gui/state/loot_state.cpp +++ b/src/gui/state/loot_state.cpp @@ -24,6 +24,7 @@ #include "gui/state/loot_state.h" +#include #include #include #include @@ -36,7 +37,7 @@ #include "loot/exception/game_detection_error.h" #include "backend/helpers/helpers.h" -#include "backend/helpers/language.h" +#include "loot/language.h" #include "gui/state/loot_paths.h" #include "loot/loot_version.h" diff --git a/src/tests/backend/helpers/language_test.h b/src/tests/backend/helpers/language_test.h index 2f806158..25fd6f61 100644 --- a/src/tests/backend/helpers/language_test.h +++ b/src/tests/backend/helpers/language_test.h @@ -25,7 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_TESTS_BACKEND_HELPERS_LANGUAGE_TEST #define LOOT_TESTS_BACKEND_HELPERS_LANGUAGE_TEST -#include "backend/helpers/language.h" +#include "loot/language.h" #include diff --git a/src/tests/backend/helpers/yaml_set_helpers_test.h b/src/tests/backend/helpers/yaml_set_helpers_test.h index dba2a55a..a040910e 100644 --- a/src/tests/backend/helpers/yaml_set_helpers_test.h +++ b/src/tests/backend/helpers/yaml_set_helpers_test.h @@ -25,7 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_TESTS_BACKEND_HELPERS_YAML_SET_HELPERS_TEST #define LOOT_TESTS_BACKEND_HELPERS_YAML_SET_HELPERS_TEST -#include "backend/helpers/yaml_set_helpers.h" +#include "loot/yaml/set.h" #include diff --git a/src/tests/backend/metadata/conditional_metadata_test.h b/src/tests/backend/metadata/conditional_metadata_test.h index 4280f095..f734fa0b 100644 --- a/src/tests/backend/metadata/conditional_metadata_test.h +++ b/src/tests/backend/metadata/conditional_metadata_test.h @@ -25,7 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_TESTS_BACKEND_METADATA_CONDITIONAL_METADATA_TEST #define LOOT_TESTS_BACKEND_METADATA_CONDITIONAL_METADATA_TEST -#include "backend/metadata/conditional_metadata.h" +#include "loot/metadata/conditional_metadata.h" #include "tests/common_game_test_fixture.h" diff --git a/src/tests/backend/metadata/file_test.h b/src/tests/backend/metadata/file_test.h index 88553fbc..853fde18 100644 --- a/src/tests/backend/metadata/file_test.h +++ b/src/tests/backend/metadata/file_test.h @@ -25,10 +25,12 @@ along with LOOT. If not, see #ifndef LOOT_TESTS_BACKEND_METADATA_FILE_TEST #define LOOT_TESTS_BACKEND_METADATA_FILE_TEST -#include "backend/metadata/file.h" +#include "loot/metadata/file.h" #include +#include "loot/yaml/file.h" + namespace loot { namespace test { TEST(File, defaultConstructorShouldInitialiseEmptyStrings) { diff --git a/src/tests/backend/metadata/location_test.h b/src/tests/backend/metadata/location_test.h index 0e362d4c..d4fa25ea 100644 --- a/src/tests/backend/metadata/location_test.h +++ b/src/tests/backend/metadata/location_test.h @@ -25,10 +25,12 @@ along with LOOT. If not, see #ifndef LOOT_TESTS_BACKEND_METADATA_LOCATION_TEST #define LOOT_TESTS_BACKEND_METADATA_LOCATION_TEST -#include "backend/metadata/location.h" +#include "loot/metadata/location.h" #include +#include "loot/yaml/location.h" + namespace loot { namespace test { TEST(Location, defaultConstructorShouldInitialiseEmptyStrings) { diff --git a/src/tests/backend/metadata/message_content_test.h b/src/tests/backend/metadata/message_content_test.h index 1d2e15a0..961346af 100644 --- a/src/tests/backend/metadata/message_content_test.h +++ b/src/tests/backend/metadata/message_content_test.h @@ -25,10 +25,12 @@ along with LOOT. If not, see #ifndef LOOT_TESTS_BACKEND_METADATA_MESSAGE_CONTENT_TEST #define LOOT_TESTS_BACKEND_METADATA_MESSAGE_CONTENT_TEST -#include "backend/metadata/message_content.h" +#include "loot/metadata/message_content.h" #include +#include "loot/yaml/message_content.h" + namespace loot { namespace test { TEST(MessageContent, defaultConstructorShouldSetEmptyEnglishLanguageString) { diff --git a/src/tests/backend/metadata/message_test.h b/src/tests/backend/metadata/message_test.h index 8f49d76a..e861c242 100644 --- a/src/tests/backend/metadata/message_test.h +++ b/src/tests/backend/metadata/message_test.h @@ -25,9 +25,10 @@ along with LOOT. If not, see #ifndef LOOT_TESTS_BACKEND_METADATA_MESSAGE_TEST #define LOOT_TESTS_BACKEND_METADATA_MESSAGE_TEST -#include "backend/metadata/message.h" +#include "loot/metadata/message.h" #include "backend/game/game.h" +#include "loot/yaml/message.h" #include "tests/common_game_test_fixture.h" namespace loot { diff --git a/src/tests/backend/metadata/plugin_cleaning_data_test.h b/src/tests/backend/metadata/plugin_cleaning_data_test.h index 153e4f6a..03144677 100644 --- a/src/tests/backend/metadata/plugin_cleaning_data_test.h +++ b/src/tests/backend/metadata/plugin_cleaning_data_test.h @@ -25,9 +25,10 @@ along with LOOT. If not, see #ifndef LOOT_TESTS_BACKEND_METADATA_PLUGIN_CLEANING_DATA #define LOOT_TESTS_BACKEND_METADATA_PLUGIN_CLEANING_DATA -#include "backend/metadata/plugin_cleaning_data.h" +#include "loot/metadata/plugin_cleaning_data.h" #include "backend/game/game.h" +#include "loot/yaml/plugin_cleaning_data.h" #include "tests/common_game_test_fixture.h" namespace loot { diff --git a/src/tests/backend/metadata/plugin_metadata_test.h b/src/tests/backend/metadata/plugin_metadata_test.h index 54e3c534..add940cf 100644 --- a/src/tests/backend/metadata/plugin_metadata_test.h +++ b/src/tests/backend/metadata/plugin_metadata_test.h @@ -25,10 +25,12 @@ along with LOOT. If not, see #ifndef LOOT_TESTS_BACKEND_METADATA_PLUGIN_METADATA_TEST #define LOOT_TESTS_BACKEND_METADATA_PLUGIN_METADATA_TEST -#include "backend/metadata/plugin_metadata.h" +#include "loot/metadata/plugin_metadata.h" #include "tests/common_game_test_fixture.h" +#include "loot/yaml/plugin_metadata.h" + namespace loot { namespace test { class PluginMetadataTest : public CommonGameTestFixture { diff --git a/src/tests/backend/metadata/priority_test.h b/src/tests/backend/metadata/priority_test.h index 418365cd..7b353ded 100644 --- a/src/tests/backend/metadata/priority_test.h +++ b/src/tests/backend/metadata/priority_test.h @@ -25,7 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_TESTS_BACKEND_METADATA_PRIORITY_TEST #define LOOT_TESTS_BACKEND_METADATA_PRIORITY_TEST -#include "backend/metadata/priority.h" +#include "loot/metadata/priority.h" #include diff --git a/src/tests/backend/metadata/tag_test.h b/src/tests/backend/metadata/tag_test.h index 75f7ec44..a1f27a7b 100644 --- a/src/tests/backend/metadata/tag_test.h +++ b/src/tests/backend/metadata/tag_test.h @@ -25,10 +25,12 @@ along with LOOT. If not, see #ifndef LOOT_TESTS_BACKEND_METADATA_TAG_TEST #define LOOT_TESTS_BACKEND_METADATA_TAG_TEST -#include "backend/metadata/tag.h" +#include "loot/metadata/tag.h" #include +#include "loot/yaml/tag.h" + namespace loot { namespace test { TEST(Tag, defaultConstructorShouldSetEmptyNameAndConditionStringsForATagAddition) { diff --git a/src/tests/printers.h b/src/tests/printers.h index 663d4a74..d5e86eab 100644 --- a/src/tests/printers.h +++ b/src/tests/printers.h @@ -29,13 +29,13 @@ along with LOOT. If not, see #include -#include "backend/metadata/file.h" -#include "backend/metadata/location.h" -#include "backend/metadata/message.h" +#include "loot/metadata/file.h" +#include "loot/metadata/location.h" +#include "loot/metadata/message.h" #include "backend/metadata/message_content.h" -#include "backend/metadata/plugin_cleaning_data.h" -#include "backend/metadata/plugin_metadata.h" -#include "backend/metadata/tag.h" +#include "loot/metadata/plugin_cleaning_data.h" +#include "loot/metadata/plugin_metadata.h" +#include "loot/metadata/tag.h" #include "backend/plugin/plugin.h" namespace loot {