From c47ea48b6b3ff466fa9fa3b4d68b4f90c502e26f Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 10 Mar 2021 12:26:09 +0100 Subject: [PATCH] Open search paths for assets, gdts and source in Linker --- docs/FolderStructure.md | 5 + src/Linker/Linker.cpp | 202 ++++++++++++++++------ src/Linker/LinkerArgs.cpp | 194 +++++++++++++++++++-- src/Linker/LinkerArgs.h | 38 +++- src/ObjLoading/SearchPath/SearchPaths.cpp | 31 ---- src/ObjLoading/SearchPath/SearchPaths.h | 12 +- 6 files changed, 370 insertions(+), 112 deletions(-) diff --git a/docs/FolderStructure.md b/docs/FolderStructure.md index 3f773cdb..d59b53fc 100644 --- a/docs/FolderStructure.md +++ b/docs/FolderStructure.md @@ -12,6 +12,7 @@ The result should be oriented at the original game's modding tools. │ ├───source_data │ ├───zone_raw │ └───zone_source +├───zone_out ├───zone_raw └───zone_source ``` @@ -39,6 +40,10 @@ Contains all data dumped using Unlinker which includes raw assets in ``zone_raw` Separating the data of dumped files serves the purpose of separating it from manually created zones and prevents accidentally overwriting self created data. +## zone_out + +The folder that contains the output of the linking process. + ## zone_raw Contains raw assets that should only be used for a zone with the same name as its subfolder. diff --git a/src/Linker/Linker.cpp b/src/Linker/Linker.cpp index d34ae922..48b93e2b 100644 --- a/src/Linker/Linker.cpp +++ b/src/Linker/Linker.cpp @@ -16,15 +16,17 @@ #include "LinkerArgs.h" #include "Utils/ObjFileStream.h" +#include "Zone/Definition/ZoneDefinitionStream.h" namespace fs = std::filesystem; class Linker::Impl { LinkerArgs m_args; - SearchPaths m_search_paths; - SearchPathFilesystem* m_last_zone_search_path; - std::set m_absolute_search_paths; + std::vector> m_loaded_zone_search_paths; + SearchPaths m_asset_search_paths; + SearchPaths m_gdt_search_paths; + SearchPaths m_source_search_paths; /** * \brief Loads a search path. @@ -53,34 +55,33 @@ class Linker::Impl ObjLoading::UnloadIWDsInSearchPath(searchPath); } - - /** - * \brief Loads all search paths that are valid for the specified zone and returns them. - * \param zonePath The path to the zone file that should be prepared for. - * \return A \c SearchPaths object that contains all search paths that should be considered when loading the specified zone. - */ - SearchPaths GetSearchPathsForZone(const std::string& zonePath) + + SearchPaths GetAssetSearchPathsForZone(const std::string& zoneName) { SearchPaths searchPathsForZone; - const auto absoluteZoneDirectory = fs::absolute(std::filesystem::path(zonePath).remove_filename()).string(); - if (m_last_zone_search_path != nullptr && m_last_zone_search_path->GetPath() == absoluteZoneDirectory) + for (const auto& searchPathStr : m_args.GetAssetSearchPathsForZone(zoneName)) { - searchPathsForZone.IncludeSearchPath(m_last_zone_search_path); - } - else if (m_absolute_search_paths.find(absoluteZoneDirectory) == m_absolute_search_paths.end()) - { - if (m_last_zone_search_path != nullptr) + auto absolutePath = fs::absolute(searchPathStr); + + if (!fs::is_directory(absolutePath)) { - UnloadSearchPath(m_last_zone_search_path); - delete m_last_zone_search_path; + if (m_args.m_verbose) + std::cout << "Adding asset search path (Not found): " << absolutePath.string() << std::endl; + continue; } - m_last_zone_search_path = new SearchPathFilesystem(absoluteZoneDirectory); - searchPathsForZone.IncludeSearchPath(m_last_zone_search_path); - LoadSearchPath(m_last_zone_search_path); + if (m_args.m_verbose) + std::cout << "Adding asset search path: " << absolutePath.string() << std::endl; + + auto searchPath = std::make_unique(searchPathStr); + LoadSearchPath(searchPath.get()); + searchPathsForZone.IncludeSearchPath(searchPath.get()); + m_loaded_zone_search_paths.emplace_back(std::move(searchPath)); } + searchPathsForZone.IncludeSearchPath(&m_asset_search_paths); + for (auto* iwd : IWD::Repository) { searchPathsForZone.IncludeSearchPath(iwd); @@ -88,62 +89,159 @@ class Linker::Impl return searchPathsForZone; } + + SearchPaths GetGdtSearchPathsForZone(const std::string& zoneName) + { + SearchPaths searchPathsForZone; + + for (const auto& searchPathStr : m_args.GetGdtSearchPathsForZone(zoneName)) + { + auto absolutePath = fs::absolute(searchPathStr); + + if (!fs::is_directory(absolutePath)) + { + if (m_args.m_verbose) + std::cout << "Adding gdt search path (Not found): " << absolutePath.string() << std::endl; + continue; + } + + if (m_args.m_verbose) + std::cout << "Adding gdt search path: " << absolutePath.string() << std::endl; + + searchPathsForZone.CommitSearchPath(std::make_unique(searchPathStr)); + } + + searchPathsForZone.IncludeSearchPath(&m_gdt_search_paths); + + return searchPathsForZone; + } + + SearchPaths GetSourceSearchPathsForZone(const std::string& zoneName) + { + SearchPaths searchPathsForZone; + + for (const auto& searchPathStr : m_args.GetSourceSearchPathsForZone(zoneName)) + { + auto absolutePath = fs::absolute(searchPathStr); + + if (!fs::is_directory(absolutePath)) + { + if (m_args.m_verbose) + std::cout << "Adding source search path (Not found): " << absolutePath.string() << std::endl; + continue; + } + + if (m_args.m_verbose) + std::cout << "Adding source search path: " << absolutePath.string() << std::endl; + + searchPathsForZone.CommitSearchPath(std::make_unique(searchPathStr)); + } + + searchPathsForZone.IncludeSearchPath(&m_source_search_paths); + + return searchPathsForZone; + } /** * \brief Initializes the Linker object's search paths based on the user's input. * \return \c true if building the search paths was successful, otherwise \c false. */ - bool BuildSearchPaths() + bool BuildZoneIndependentSearchPaths() { - for (const auto& path : m_args.m_user_search_paths) + for (const auto& path : m_args.GetZoneIndependentAssetSearchPaths()) { auto absolutePath = fs::absolute(path); if (!fs::is_directory(absolutePath)) { - printf("Could not find directory of search path: \"%s\"\n", path.c_str()); - return false; + if(m_args.m_verbose) + std::cout << "Adding asset search path (Not found): " << absolutePath.string() << std::endl; + continue; } + if(m_args.m_verbose) + std::cout << "Adding asset search path: " << absolutePath.string() << std::endl; + auto searchPath = std::make_unique(absolutePath.string()); LoadSearchPath(searchPath.get()); - m_search_paths.CommitSearchPath(std::move(searchPath)); - - m_absolute_search_paths.insert(absolutePath.string()); + m_asset_search_paths.CommitSearchPath(std::move(searchPath)); } - if (m_args.m_verbose) + for (const auto& path : m_args.GetZoneIndependentGdtSearchPaths()) { - printf("%u SearchPaths%s\n", m_absolute_search_paths.size(), !m_absolute_search_paths.empty() ? ":" : ""); - for (const auto& absoluteSearchPath : m_absolute_search_paths) + auto absolutePath = fs::absolute(path); + + if (!fs::is_directory(absolutePath)) { - printf(" \"%s\"\n", absoluteSearchPath.c_str()); + if (m_args.m_verbose) + std::cout << "Loading gdt search path (Not found): " << absolutePath.string() << std::endl; + continue; } - if (!m_absolute_search_paths.empty()) + if (m_args.m_verbose) + std::cout << "Adding gdt search path: " << absolutePath.string() << std::endl; + + m_gdt_search_paths.CommitSearchPath(std::make_unique(absolutePath.string())); + } + + for (const auto& path : m_args.GetZoneIndependentSourceSearchPaths()) + { + auto absolutePath = fs::absolute(path); + + if (!fs::is_directory(absolutePath)) { - puts(""); + if (m_args.m_verbose) + std::cout << "Loading source search path (Not found): " << absolutePath.string() << std::endl; + continue; } + + if (m_args.m_verbose) + std::cout << "Adding source search path: " << absolutePath.string() << std::endl; + + m_source_search_paths.CommitSearchPath(std::make_unique(absolutePath.string())); } return true; } - - /** - * \brief Performs the tasks specified by the command line arguments on the specified zone. - * \param zone The zone to handle. - * \return \c true if handling the zone was successful, otherwise \c false. - */ - bool BuildZone(const std::string& zoneName) const + + bool BuildZone(const std::string& zoneName) { + auto assetSearchPaths = GetAssetSearchPathsForZone(zoneName); + auto gdtSearchPaths = GetGdtSearchPathsForZone(zoneName); + auto sourceSearchPaths = GetSourceSearchPathsForZone(zoneName); + + std::unique_ptr zoneDefinition; + { + const auto definitionFileName = zoneName + ".zone"; + const auto definitionStream = sourceSearchPaths.Open(definitionFileName); + if (!definitionStream) + { + std::cout << "Could not find zone definition file for zone \"" << zoneName << "\"." << std::endl; + return false; + } + + ZoneDefinitionInputStream zoneDefinitionInputStream(*definitionStream, definitionFileName, m_args.m_verbose); + zoneDefinition = zoneDefinitionInputStream.ReadDefinition(); + } + + if(!zoneDefinition) + { + std::cout << "Failed to read zone definition file for zone \"" << zoneName << "\"." << std::endl; + return false; + } + + for(const auto& loadedSearchPath : m_loaded_zone_search_paths) + { + UnloadSearchPath(loadedSearchPath.get()); + } + m_loaded_zone_search_paths.clear(); + return true; } public: Impl() - { - m_last_zone_search_path = nullptr; - } + = default; /** * \copydoc Linker::Start @@ -153,7 +251,7 @@ public: if (!m_args.ParseArgs(argc, argv)) return false; - if (!BuildSearchPaths()) + if (!BuildZoneIndependentSearchPaths()) return false; std::vector> zones; @@ -168,9 +266,6 @@ public: auto absoluteZoneDirectory = absolute(std::filesystem::path(zonePath).remove_filename()).string(); - auto searchPathsForZone = GetSearchPathsForZone(absoluteZoneDirectory); - searchPathsForZone.IncludeSearchPath(&m_search_paths); - auto zone = std::unique_ptr(ZoneLoading::LoadZone(zonePath)); if (zone == nullptr) { @@ -182,13 +277,10 @@ public: { printf("Loaded zone \"%s\"\n", zone->m_name.c_str()); } - - ObjLoading::LoadReferencedContainersForZone(&searchPathsForZone, zone.get()); - ObjLoading::LoadObjDataForZone(&searchPathsForZone, zone.get()); } auto result = true; - for(const auto& zone : m_args.m_zones_to_build) + for (const auto& zone : m_args.m_zones_to_build) { if (!BuildZone(zone)) { @@ -197,10 +289,6 @@ public: } } - for(const auto& zone : zones) - { - ObjLoading::UnloadContainersOfZone(zone.get()); - } zones.clear(); return result; diff --git a/src/Linker/LinkerArgs.cpp b/src/Linker/LinkerArgs.cpp index 3f111366..8e3589b8 100644 --- a/src/Linker/LinkerArgs.cpp +++ b/src/Linker/LinkerArgs.cpp @@ -1,5 +1,6 @@ #include "LinkerArgs.h" +#include #include #include @@ -8,6 +9,8 @@ #include "ObjWriting.h" #include "Utils/FileUtils.h" +namespace fs = std::filesystem; + const CommandLineOption* const OPTION_HELP = CommandLineOption::Builder::Create() .WithShortName("?") @@ -22,19 +25,40 @@ const CommandLineOption* const OPTION_VERBOSE = .WithDescription("Outputs a lot more and more detailed messages.") .Build(); +const CommandLineOption* const OPTION_BASE_FOLDER = + CommandLineOption::Builder::Create() + .WithShortName("b") + .WithLongName("base-folder") + .WithDescription("Specifies the base folder that can be used to specify other folders. Defaults to the current directory.") + .WithParameter("baseFolderPath") + .Build(); + const CommandLineOption* const OPTION_OUTPUT_FOLDER = CommandLineOption::Builder::Create() - .WithShortName("o") .WithLongName("output-folder") - .WithDescription("Specifies the output folder containing the contents of the unlinked zones. Defaults to ./%zoneName%") + .WithDescription("Specifies the output folder containing the contents of the unlinked zones. Defaults to \"" + std::string(LinkerArgs::DEFAULT_OUTPUT_FOLDER) + "\".") .WithParameter("outputFolderPath") .Build(); -const CommandLineOption* const OPTION_SEARCH_PATH = +const CommandLineOption* const OPTION_ASSET_SEARCH_PATH = CommandLineOption::Builder::Create() - .WithLongName("search-path") - .WithDescription("Specifies a semi-colon separated list of paths to search for additional game files.") - .WithParameter("searchPathString") + .WithLongName("asset-search-path") + .WithDescription("Specifies the search paths used for assets. Defaults to \"" + std::string(LinkerArgs::DEFAULT_ASSET_SEARCH_PATH) + "\".") + .WithParameter("assetSearchPathString") + .Build(); + +const CommandLineOption* const OPTION_GDT_SEARCH_PATH = + CommandLineOption::Builder::Create() + .WithLongName("gdt-search-path") + .WithDescription("Specifies the search paths used for assets. Defaults to \"" + std::string(LinkerArgs::DEFAULT_GDT_SEARCH_PATH) + "\".") + .WithParameter("gdtSearchPathString") + .Build(); + +const CommandLineOption* const OPTION_SOURCE_SEARCH_PATH = + CommandLineOption::Builder::Create() + .WithLongName("source-search-path") + .WithDescription("Specifies the search paths used for assets. Defaults to \"" + std::string(LinkerArgs::DEFAULT_SOURCE_SEARCH_PATH) + "\".") + .WithParameter("sourceSearchPathString") .Build(); const CommandLineOption* const OPTION_LOAD = @@ -50,14 +74,20 @@ const CommandLineOption* const COMMAND_LINE_OPTIONS[] { OPTION_HELP, OPTION_VERBOSE, + OPTION_BASE_FOLDER, OPTION_OUTPUT_FOLDER, - OPTION_SEARCH_PATH, + OPTION_ASSET_SEARCH_PATH, + OPTION_GDT_SEARCH_PATH, + OPTION_SOURCE_SEARCH_PATH, OPTION_LOAD }; LinkerArgs::LinkerArgs() : m_argument_parser(COMMAND_LINE_OPTIONS, std::extent::value), - m_output_folder("zone_out/%zoneName%"), + m_base_pattern(R"(\?base\?)"), + m_zone_pattern(R"(\?zone\?)"), + m_base_folder_depends_on_zone(false), + m_out_folder_depends_on_zone(false), m_verbose(false) { } @@ -84,6 +114,69 @@ void LinkerArgs::SetVerbose(const bool isVerbose) ObjWriting::Configuration.Verbose = isVerbose; } +std::string LinkerArgs::GetBasePathForZone(const std::string& zoneName) const +{ + return std::regex_replace(m_base_folder, m_zone_pattern, zoneName); +} + +void LinkerArgs::SetDefaultBasePath() +{ + const auto currentDir = fs::absolute(fs::current_path()); + + if (currentDir.filename() == "bin") + { + m_base_folder = currentDir.parent_path().string(); + } + else + { + m_base_folder = currentDir.string(); + } +} + +std::set LinkerArgs::GetZoneIndependentSearchPaths(const std::set& set) const +{ + std::set out; + + for(const auto& path : set) + { + if(path.find(PATTERN_ZONE) != std::string::npos) + continue; + + if(path.find(PATTERN_BASE) != std::string::npos) + { + if(m_base_folder_depends_on_zone) + continue; + + out.emplace(std::regex_replace(path, m_base_pattern, m_base_folder)); + } + else + { + out.emplace(path); + } + } + + return out; +} + +std::set LinkerArgs::GetSearchPathsForZone(const std::set& set, const std::string& zoneName) const +{ + std::set out; + const auto basePath = GetBasePathForZone(zoneName); + + for (const auto& path : set) + { + if (path.find(PATTERN_ZONE) == std::string::npos + && (!m_base_folder_depends_on_zone || path.find(PATTERN_BASE) == std::string::npos)) + { + continue; + } + + out.emplace(std::regex_replace(std::regex_replace(path, m_zone_pattern, zoneName), m_base_pattern, basePath)); + } + + return out; +} + bool LinkerArgs::ParseArgs(const int argc, const char** argv) { if (!m_argument_parser.ParseArguments(argc - 1, &argv[1])) @@ -110,18 +203,57 @@ bool LinkerArgs::ParseArgs(const int argc, const char** argv) // -v; --verbose SetVerbose(m_argument_parser.IsOptionSpecified(OPTION_VERBOSE)); - // -o; --output-folder - if (m_argument_parser.IsOptionSpecified(OPTION_OUTPUT_FOLDER)) - m_output_folder = m_argument_parser.GetValueForOption(OPTION_OUTPUT_FOLDER); + // b; --base-folder + if (m_argument_parser.IsOptionSpecified(OPTION_BASE_FOLDER)) + m_base_folder = m_argument_parser.GetValueForOption(OPTION_BASE_FOLDER); + else + SetDefaultBasePath(); + m_base_folder_depends_on_zone = m_base_folder.find(PATTERN_ZONE) != std::string::npos; - // --search-path - if (m_argument_parser.IsOptionSpecified(OPTION_SEARCH_PATH)) + // --output-folder + if (m_argument_parser.IsOptionSpecified(OPTION_OUTPUT_FOLDER)) + m_out_folder = m_argument_parser.GetValueForOption(OPTION_OUTPUT_FOLDER); + else + m_out_folder = DEFAULT_OUTPUT_FOLDER; + m_out_folder_depends_on_zone = m_out_folder.find(PATTERN_ZONE) != std::string::npos; + + // --asset-search-path + if (m_argument_parser.IsOptionSpecified(OPTION_ASSET_SEARCH_PATH)) { - if (!FileUtils::ParsePathsString(m_argument_parser.GetValueForOption(OPTION_SEARCH_PATH), m_user_search_paths)) + if (!FileUtils::ParsePathsString(m_argument_parser.GetValueForOption(OPTION_ASSET_SEARCH_PATH), m_asset_search_paths)) + return false; + } + else + { + if (!FileUtils::ParsePathsString(DEFAULT_ASSET_SEARCH_PATH, m_asset_search_paths)) return false; } - if(m_argument_parser.IsOptionSpecified(OPTION_LOAD)) + // --gdt-search-path + if (m_argument_parser.IsOptionSpecified(OPTION_GDT_SEARCH_PATH)) + { + if (!FileUtils::ParsePathsString(m_argument_parser.GetValueForOption(OPTION_GDT_SEARCH_PATH), m_gdt_search_paths)) + return false; + } + else + { + if (!FileUtils::ParsePathsString(DEFAULT_GDT_SEARCH_PATH, m_gdt_search_paths)) + return false; + } + + // --source-search-path + if (m_argument_parser.IsOptionSpecified(OPTION_SOURCE_SEARCH_PATH)) + { + if (!FileUtils::ParsePathsString(m_argument_parser.GetValueForOption(OPTION_SOURCE_SEARCH_PATH), m_source_search_paths)) + return false; + } + else + { + if (!FileUtils::ParsePathsString(DEFAULT_SOURCE_SEARCH_PATH, m_source_search_paths)) + return false; + } + + if (m_argument_parser.IsOptionSpecified(OPTION_LOAD)) m_zones_to_load = m_argument_parser.GetParametersForOption(OPTION_LOAD); return true; @@ -129,5 +261,35 @@ bool LinkerArgs::ParseArgs(const int argc, const char** argv) std::string LinkerArgs::GetOutputFolderPathForZone(const std::string& zoneName) const { - return std::regex_replace(m_output_folder, std::regex("%zoneName%"), zoneName); + return std::regex_replace(std::regex_replace(m_out_folder, m_zone_pattern, zoneName), m_base_pattern, GetBasePathForZone(zoneName)); +} + +std::set LinkerArgs::GetZoneIndependentAssetSearchPaths() const +{ + return GetZoneIndependentSearchPaths(m_asset_search_paths); +} + +std::set LinkerArgs::GetZoneIndependentGdtSearchPaths() const +{ + return GetZoneIndependentSearchPaths(m_gdt_search_paths); +} + +std::set LinkerArgs::GetZoneIndependentSourceSearchPaths() const +{ + return GetZoneIndependentSearchPaths(m_source_search_paths); +} + +std::set LinkerArgs::GetAssetSearchPathsForZone(const std::string& zoneName) const +{ + return GetSearchPathsForZone(m_asset_search_paths, zoneName); +} + +std::set LinkerArgs::GetGdtSearchPathsForZone(const std::string& zoneName) const +{ + return GetSearchPathsForZone(m_gdt_search_paths, zoneName); +} + +std::set LinkerArgs::GetSourceSearchPathsForZone(const std::string& zoneName) const +{ + return GetSearchPathsForZone(m_source_search_paths, zoneName); } diff --git a/src/Linker/LinkerArgs.h b/src/Linker/LinkerArgs.h index 80df390f..60b040c1 100644 --- a/src/Linker/LinkerArgs.h +++ b/src/Linker/LinkerArgs.h @@ -1,6 +1,7 @@ #pragma once #include #include +#include #include "Utils/ClassUtils.h" #include "Utils/Arguments/ArgumentParser.h" @@ -8,7 +9,21 @@ class LinkerArgs { +public: + static constexpr const char* PATTERN_BASE = "?base?"; + static constexpr const char* PATTERN_ZONE = "?zone?"; + + static constexpr const char* DEFAULT_BASE_FOLDER = "."; + static constexpr const char* DEFAULT_BASE_FOLDER_MOD_TOOLS = ".."; + static constexpr const char* DEFAULT_OUTPUT_FOLDER = "?base?/zone_out/?zone?"; + static constexpr const char* DEFAULT_ASSET_SEARCH_PATH = "?base?/raw;?base?/zone_raw/?zone?"; + static constexpr const char* DEFAULT_GDT_SEARCH_PATH = "?base?/source_data"; + static constexpr const char* DEFAULT_SOURCE_SEARCH_PATH = "?base?/zone_source;?base?/zone_raw/?zone?/zone_source"; + +private: ArgumentParser m_argument_parser; + std::regex m_base_pattern; + std::regex m_zone_pattern; /** * \brief Prints a command line usage help text for the Linker tool to stdout. @@ -17,12 +32,23 @@ class LinkerArgs void SetVerbose(bool isVerbose); + _NODISCARD std::string GetBasePathForZone(const std::string& zoneName) const; + void SetDefaultBasePath(); + _NODISCARD std::set GetZoneIndependentSearchPaths(const std::set& set) const; + _NODISCARD std::set GetSearchPathsForZone(const std::set& set, const std::string& zoneName) const; + public: std::vector m_zones_to_load; std::vector m_zones_to_build; - std::set m_user_search_paths; - std::string m_output_folder; + std::string m_base_folder; + std::string m_out_folder; + bool m_base_folder_depends_on_zone; + bool m_out_folder_depends_on_zone; + + std::set m_asset_search_paths; + std::set m_gdt_search_paths; + std::set m_source_search_paths; bool m_verbose; @@ -35,4 +61,12 @@ public: * \return An output path for the zone based on the user input. */ _NODISCARD std::string GetOutputFolderPathForZone(const std::string& zoneName) const; + + _NODISCARD std::set GetZoneIndependentAssetSearchPaths() const; + _NODISCARD std::set GetZoneIndependentGdtSearchPaths() const; + _NODISCARD std::set GetZoneIndependentSourceSearchPaths() const; + + _NODISCARD std::set GetAssetSearchPathsForZone(const std::string& zoneName) const; + _NODISCARD std::set GetGdtSearchPathsForZone(const std::string& zoneName) const; + _NODISCARD std::set GetSourceSearchPathsForZone(const std::string& zoneName) const; }; diff --git a/src/ObjLoading/SearchPath/SearchPaths.cpp b/src/ObjLoading/SearchPath/SearchPaths.cpp index aaf681ac..9c6a02b4 100644 --- a/src/ObjLoading/SearchPath/SearchPaths.cpp +++ b/src/ObjLoading/SearchPath/SearchPaths.cpp @@ -2,37 +2,6 @@ #include -SearchPaths::SearchPaths() = default; - -SearchPaths::~SearchPaths() -= default; - -SearchPaths::SearchPaths(const SearchPaths& other) - : m_search_paths(other.m_search_paths) -{ - -} - -SearchPaths::SearchPaths(SearchPaths&& other) noexcept - : m_search_paths(std::move(other.m_search_paths)) -{ - -} - -SearchPaths& SearchPaths::operator=(const SearchPaths& other) -{ - m_search_paths = other.m_search_paths; - - return *this; -} - -SearchPaths& SearchPaths::operator=(SearchPaths&& other) noexcept -{ - m_search_paths = std::move(other.m_search_paths); - - return *this; -} - std::unique_ptr SearchPaths::Open(const std::string& fileName) { for(auto* searchPathEntry : m_search_paths) diff --git a/src/ObjLoading/SearchPath/SearchPaths.h b/src/ObjLoading/SearchPath/SearchPaths.h index 01b7989c..71d3c213 100644 --- a/src/ObjLoading/SearchPath/SearchPaths.h +++ b/src/ObjLoading/SearchPath/SearchPaths.h @@ -12,17 +12,17 @@ class SearchPaths final : public ISearchPath public: using iterator = std::vector::iterator; - SearchPaths(); - ~SearchPaths() override; + SearchPaths() = default; + ~SearchPaths() override = default; std::unique_ptr Open(const std::string& fileName) override; std::string GetPath() override; void Find(const SearchPathSearchOptions& options, const std::function& callback) override; - SearchPaths(const SearchPaths& other); - SearchPaths(SearchPaths&& other) noexcept; - SearchPaths& operator=(const SearchPaths& other); - SearchPaths& operator=(SearchPaths&& other) noexcept; + SearchPaths(const SearchPaths& other) = delete; + SearchPaths(SearchPaths&& other) noexcept = default; + SearchPaths& operator=(const SearchPaths& other) = delete; + SearchPaths& operator=(SearchPaths&& other) noexcept = default; /** * \brief Adds a search path that gets deleted upon destruction of the \c SearchPaths object.