Add libloot v0.25.3 public API headers

This commit is contained in:
Oliver Hamlet
2025-03-25 22:02:15 +00:00
parent 3fe91be7e5
commit 7b0add5e72
27 changed files with 2817 additions and 1 deletions
-1
View File
@@ -1,2 +1 @@
/build
/include
+116
View File
@@ -0,0 +1,116 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2013-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_API_H
#define LOOT_API_H
#include <filesystem>
#include <functional>
#include <memory>
#include <string>
#include "loot/api_decorator.h"
#include "loot/enum/game_type.h"
#include "loot/enum/log_level.h"
#include "loot/exception/condition_syntax_error.h"
#include "loot/exception/cyclic_interaction_error.h"
#include "loot/exception/error_categories.h"
#include "loot/exception/file_access_error.h"
#include "loot/exception/undefined_group_error.h"
#include "loot/game_interface.h"
#include "loot/loot_version.h"
namespace loot {
/**
* @}
* @name Logging Functions
* @{
*/
/**
* @brief Set the callback function that is called when logging.
* @details If this function is not called, the default behaviour is to
* print messages to the console.
* @param callback
* The function called when logging. The first parameter is the
* level of the message being logged, and the second is the message.
*/
LOOT_API void SetLoggingCallback(
std::function<void(LogLevel, const char*)> callback);
/**
* @}
* @name Version Functions
* @{
*/
/**
* @brief Checks for API compatibility.
* @details Checks whether the loaded API is compatible with the given
* version of the API, abstracting API stability policy away from
* clients. The version numbering used is major.minor.patch.
* @param major
* The major version number to check.
* @param minor
* The minor version number to check.
* @param patch
* The patch version number to check.
* @returns True if the API versions are compatible, false otherwise.
*/
LOOT_API bool IsCompatible(const unsigned int major,
const unsigned int minor,
const unsigned int patch);
/**
* @}
* @name Lifecycle Management Functions
* @{
*/
/**
* @brief Initialise a new game handle.
* @details Creates a handle for a game, which is then used by all
* game-specific functions.
* @param game
* A game code for which to create the handle.
* @param game_path
* The relative or absolute path to the directory containing the
* game's executable.
* @param game_local_path
* The relative or absolute path to the game's local data folder, or an
* empty path. The local data folder is usually in `%%LOCALAPPDATA%`, but
* Morrowind has no local data folder and OpenMW's is in the user's
* My Games folder on Windows and in `$HOME/.config` on Linux. If an
* empty path is provided, the API will attempt to look up the relevant
* local data path, which may fail in some situations (e.g. when running
* libloot natively on Linux for a game other than Morrowind or OpenMW).
* @returns The new game handle.
*/
LOOT_API std::unique_ptr<GameInterface> CreateGameHandle(
const GameType game,
const std::filesystem::path& game_path,
const std::filesystem::path& game_local_path = "");
}
#endif
+44
View File
@@ -0,0 +1,44 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2013-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_API_DECORATOR
#define LOOT_API_DECORATOR
/* set up dll import/export decorators
when compiling the dll on windows, ensure LOOT_EXPORT is defined. clients
that use this header do not need to define anything to import the symbols
properly. */
#if defined(_WIN32)
#ifdef LOOT_STATIC
#define LOOT_API
#elif defined LOOT_EXPORT
#define LOOT_API __declspec(dllexport)
#else
#define LOOT_API __declspec(dllimport)
#endif
#else
#define LOOT_API
#endif
#endif
+235
View File
@@ -0,0 +1,235 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2012-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_DATABASE_INTERFACE
#define LOOT_DATABASE_INTERFACE
#include <filesystem>
#include <optional>
#include <string>
#include <vector>
#include "loot/exception/cyclic_interaction_error.h"
#include "loot/metadata/group.h"
#include "loot/metadata/message.h"
#include "loot/metadata/plugin_metadata.h"
namespace loot {
/** @brief The interface provided by API's database handle. */
class DatabaseInterface {
public:
virtual ~DatabaseInterface() = default;
/**
* @name Data Reading & Writing
* @{
*/
/**
* @brief Loads the masterlist, userlist and masterlist prelude from the
* paths specified.
* @details Can be called multiple times, each time replacing the
* previously-loaded data.
* @param masterlist_path
* The relative or absolute path to the masterlist file that should be
* loaded.
* @param userlist_path
* The relative or absolute path to the userlist file that should be
* loaded, or an empty path. If an empty path, no userlist will be
* loaded.
* @param masterlist_prelude_path
* The relative or absolute path to the masterlist prelude file that
* should be loaded. If an empty path, no masterlist prelude will be
* loaded.
*/
virtual void LoadLists(
const std::filesystem::path& masterlist_path,
const std::filesystem::path& userlist_path = "",
const std::filesystem::path& masterlist_prelude_path = "") = 0;
/**
* Writes a metadata file containing all loaded user-added metadata.
* @param outputFile
* The path to which the file shall be written.
* @param overwrite
* If `false` and `outputFile` already exists, no data will be
* written. Otherwise, data will be written.
*/
virtual void WriteUserMetadata(const std::filesystem::path& outputFile,
const bool overwrite) const = 0;
/**
* @brief Writes a minimal metadata file that only contains plugins with
* Bash Tag suggestions and/or dirty info, plus the suggestions and
* info themselves.
* @param outputFile
* The path to which the file shall be written.
* @param overwrite
* If `false` and `outputFile` already exists, no data will be
* written. Otherwise, data will be written.
*/
virtual void WriteMinimalList(const std::filesystem::path& outputFile,
const bool overwrite) const = 0;
/**
* @}
* @name Non-plugin Data Access
* @{
*/
/**
* @brief Gets the Bash Tags that are listed in the loaded metadata lists.
* @details Bash Tag suggestions can include Bash Tags not in this list.
* @returns A set of Bash Tag names.
*/
virtual std::vector<std::string> GetKnownBashTags() const = 0;
/**
* @brief Get all general messages listen in the loaded metadata lists.
* @param evaluateConditions
* If true, any metadata conditions are evaluated before the metadata
* is returned, otherwise unevaluated metadata is returned. Evaluating
* general message conditions also clears the condition cache before
* evaluating conditions.
* @returns A vector of messages supplied in the metadata lists but not
* attached to any particular plugin.
*/
virtual std::vector<Message> GetGeneralMessages(
bool evaluateConditions = false) const = 0;
/**
* @brief Gets the groups that are defined in the loaded metadata lists.
* @param includeUserMetadata
* If true, any group metadata present in the userlist is included in
* the returned metadata, otherwise the metadata returned only includes
* metadata from the masterlist.
* @returns An vector of Group objects. Each Group's name is unique, if a
* group has masterlist and user metadata the two are merged into a
* single group object.
*/
virtual std::vector<Group> GetGroups(
bool includeUserMetadata = true) const = 0;
/**
* @brief Gets the groups that are defined or extended in the loaded userlist.
* @returns An unordered set of Group objects.
*/
virtual std::vector<Group> GetUserGroups() const = 0;
/**
* @brief Sets the group definitions to store in the userlist, overwriting any
* existing definitions there.
* @param groups
* The unordered set of Group objects to set.
*/
virtual void SetUserGroups(const std::vector<Group>& groups) = 0;
/**
* @brief Get the "shortest" path between the two given groups according to
* their load after metadata.
* @details The "shortest" path is defined as the path that maximises the
* amount of user metadata involved while minimising the amount of
* masterlist metadata involved. It's not the path involving the
* fewest groups.
* @param fromGroupName
* The name of the source group, that loads earlier.
* @param toGroupName
* The name of the destination group, that loads later.
* @returns A vector of Vertex elements representing the path from the source
* group to the destination group, or an empty vector if no path
* exists.
*/
virtual std::vector<Vertex> GetGroupsPath(
const std::string& fromGroupName,
const std::string& toGroupName) const = 0;
/**
* @}
* @name Plugin Data Access
* @{
*/
/**
* @brief Get all a plugin's loaded metadata.
* @param plugin
* The filename of the plugin to look up metadata for.
* @param includeUserMetadata
* If true, any user metadata the plugin has is included in the
* returned metadata, otherwise the metadata returned only includes
* metadata from the masterlist.
* @param evaluateConditions
* If true, any metadata conditions are evaluated before the metadata
* is returned, otherwise unevaluated metadata is returned. Evaluating
* plugin metadata conditions does not clear the condition cache.
* @returns If the plugin has metadata, an optional containing that metadata,
* otherwise an optional containing no value.
*/
virtual std::optional<PluginMetadata> GetPluginMetadata(
const std::string& plugin,
bool includeUserMetadata = true,
bool evaluateConditions = false) const = 0;
/**
* @brief Get a plugin's metadata loaded from the given userlist.
* @param plugin
* The filename of the plugin to look up user-added metadata for.
* @param evaluateConditions
* If true, any metadata conditions are evaluated before the metadata
* is returned, otherwise unevaluated metadata is returned. Evaluating
* plugin metadata conditions does not clear the condition cache.
* @returns If the plugin has user-added metadata, an optional containing
* that metadata, otherwise an optional containing no value.
*/
virtual std::optional<PluginMetadata> GetPluginUserMetadata(
const std::string& plugin,
bool evaluateConditions = false) const = 0;
/**
* @brief Sets a plugin's user metadata, overwriting any existing user
* metadata.
* @param pluginMetadata
* The user metadata you want to set, with plugin.Name() being the
* filename of the plugin the metadata is for.
*/
virtual void SetPluginUserMetadata(const PluginMetadata& pluginMetadata) = 0;
/**
* @brief Discards all loaded user metadata for the plugin with the given
* filename.
* @param plugin
* The filename of the plugin for which all user-added metadata
* should be deleted.
*/
virtual void DiscardPluginUserMetadata(const std::string& plugin) = 0;
/**
* @brief Discards all loaded user metadata for all plugins, and any
* user-added general messages and known bash tags.
*/
virtual void DiscardAllUserMetadata() = 0;
/** @} */
};
}
#endif
+53
View File
@@ -0,0 +1,53 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2012-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_EDGE_TYPE
#define LOOT_EDGE_TYPE
/**
* The namespace used by libloot.
*/
namespace loot {
/**
* @brief An enum representing the different possible types of interactions
* between plugins or groups.
*/
enum struct EdgeType : unsigned int {
hardcoded,
masterFlag,
master,
masterlistRequirement,
userRequirement,
masterlistLoadAfter,
userLoadAfter,
masterlistGroup,
userGroup,
recordOverlap,
assetOverlap,
tieBreak,
blueprintMaster,
};
}
#endif
+59
View File
@@ -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
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GAME_TYPE
#define LOOT_GAME_TYPE
/**
* The namespace used by libloot.
*/
namespace loot {
/** @brief Codes used to create database handles for specific games. */
enum struct GameType : unsigned int {
/** The Elder Scrolls IV: Oblivion */
tes4,
/** The Elder Scrolls V: Skyrim */
tes5,
/** Fallout 3 */
fo3,
/** Fallout: New Vegas */
fonv,
/** Fallout 4 */
fo4,
/** The Elder Scrolls V: Skyrim Special Edition */
tes5se,
/** Fallout 4 VR */
fo4vr,
/** Skyrim VR */
tes5vr,
/** The Elder Scrolls III: Morrowind */
tes3,
/** Starfield */
starfield,
/** OpenMW */
openmw
};
}
#endif
+45
View File
@@ -0,0 +1,45 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2012-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_LOG_LEVEL
#define LOOT_LOG_LEVEL
/**
* The namespace used by libloot.
*/
namespace loot {
/**
* @brief Codes used to specify different levels of API logging.
*/
enum struct LogLevel : unsigned int {
trace,
debug,
info,
warning,
error,
fatal
};
}
#endif
+49
View File
@@ -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
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_MESSAGE_TYPE
#define LOOT_MESSAGE_TYPE
/**
* The namespace used by libloot.
*/
namespace loot {
/** @brief Codes used to indicate the type of a message. */
enum struct MessageType : unsigned int {
/** A notification message that is of no significant severity. */
say,
/**
* A warning message, used to indicate that an issue may be present that the
* user may wish to act on.
*/
warn,
/**
* An error message, used to indicate that an issue that requires user action
* is present.
*/
error,
};
}
#endif
@@ -0,0 +1,41 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2012-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_EXCEPTION_CONDITION_SYNTAX_ERROR
#define LOOT_EXCEPTION_CONDITION_SYNTAX_ERROR
#include <stdexcept>
namespace loot {
/**
* @brief An exception class thrown if invalid syntax is encountered when
* parsing a metadata condition.
*/
class ConditionSyntaxError : public std::system_error {
public:
using std::system_error::system_error;
};
}
#endif
@@ -0,0 +1,61 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2012-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_EXCEPTION_CYCLIC_INTERACTION_ERROR
#define LOOT_EXCEPTION_CYCLIC_INTERACTION_ERROR
#include <stdexcept>
#include <vector>
#include "loot/api_decorator.h"
#include "loot/vertex.h"
namespace loot {
/**
* @brief An exception class thrown if a cyclic interaction is detected when
* sorting a load order.
*/
class CyclicInteractionError : public std::runtime_error {
public:
/**
* @brief Construct an exception detailing a plugin or group graph cycle.
* @param cycle A representation of the cyclic path.
*/
LOOT_API CyclicInteractionError(std::vector<Vertex> cycle);
/**
* @brief Get a representation of the cyclic path.
* @details Each Vertex is the name of a graph element (plugin or group) and
* the type of the edge going to the next Vertex. The last Vertex
* has an edge going to the first Vertex.
* @return A vector of Vertex elements representing the cyclic path.
*/
LOOT_API std::vector<Vertex> GetCycle() const;
private:
std::vector<Vertex> cycle_;
};
}
#endif
@@ -0,0 +1,58 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2012-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_ERROR_CATEGORIES
#define LOOT_ERROR_CATEGORIES
#include <system_error>
#include "loot/api_decorator.h"
namespace loot {
/**
* @brief Get the error category that can be used to identify system_error
* exceptions that are due to esplugin errors.
* @returns A reference to the static object of unspecified runtime type,
* derived from std::error_category.
*/
LOOT_API const std::error_category& esplugin_category();
/**
* @brief Get the error category that can be used to identify system_error
* exceptions that are due to libloadorder errors.
* @returns A reference to the static object of unspecified runtime type,
* derived from std::error_category.
*/
LOOT_API const std::error_category& libloadorder_category();
/**
* @brief Get the error category that can be used to identify system_error
* exceptions that are due to loot condition interpreter errors.
* @returns A reference to the static object of unspecified runtime type,
* derived from std::error_category.
*/
LOOT_API const std::error_category& loot_condition_interpreter_category();
}
#endif
@@ -0,0 +1,41 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2012-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_EXCEPTION_FILE_ACCESS_ERROR
#define LOOT_EXCEPTION_FILE_ACCESS_ERROR
#include <stdexcept>
namespace loot {
/**
* @brief An exception class thrown if an error is encountered while reading or
* writing a file.
*/
class FileAccessError : public std::runtime_error {
public:
using std::runtime_error::runtime_error;
};
}
#endif
@@ -0,0 +1,55 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2012-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_EXCEPTION_UNDEFINED_GROUP_ERROR
#define LOOT_EXCEPTION_UNDEFINED_GROUP_ERROR
#include <stdexcept>
#include "loot/api_decorator.h"
namespace loot {
/**
* @brief An exception class thrown if group is referenced but is undefined.
*/
class UndefinedGroupError : public std::runtime_error {
public:
/**
* @brief Construct an exception for an undefined group.
* @param groupName The name of the group that is undefined.
*/
LOOT_API UndefinedGroupError(const std::string& groupName);
/**
* Get the name of the undefined group.
* @return A group name.
*/
LOOT_API std::string GetGroupName() const;
private:
std::string groupName_;
};
}
#endif
+241
View File
@@ -0,0 +1,241 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2012-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GAME_INTERFACE
#define LOOT_GAME_INTERFACE
#include "loot/database_interface.h"
#include "loot/plugin_interface.h"
namespace loot {
/** @brief The interface provided for accessing game-specific functionality. */
class GameInterface {
public:
virtual ~GameInterface() = default;
/**
* @brief Get the game's type.
* @returns The game's type.
*/
virtual GameType GetType() const = 0;
/**
* @brief Gets the currently-set additional data paths.
* @details The following games are configured with additional data paths by
* default:
* - Fallout 4, when installed from the Microsoft Store
* - Starfield
* - OpenMW
*/
virtual std::vector<std::filesystem::path> GetAdditionalDataPaths() const = 0;
/**
* @brief Set additional data paths.
* @details The additional data paths are used when interacting with the load
* order, evaluating conditions and scanning for archives (BSA/BA2
* depending on the game). Additional data paths are used in the
* order they are given (except with OpenMW, which checks them in
* reverse order), and take precedence over the game's main data
* path.
*/
virtual void SetAdditionalDataPaths(
const std::vector<std::filesystem::path>& additionalDataPaths) = 0;
/**
* @name Metadata Access
* @{
*/
/**
* @brief Get the database interface used for accessing metadata-related
* functionality.
* @returns A reference to the game's DatabaseInterface. The reference remains
* valid for the lifetime of the GameInterface instance.
*/
virtual DatabaseInterface& GetDatabase() = 0;
/**
* @brief Get the database interface used for accessing metadata-related
* functionality.
* @returns A reference to the game's DatabaseInterface. The reference remains
* valid for the lifetime of the GameInterface instance.
*/
virtual const DatabaseInterface& GetDatabase() const = 0;
/**
* @}
* @name Plugin Data Access
* @{
*/
/**
* @brief Check if a file is a valid plugin.
* @details The validity check is not exhaustive: it generally checks that the
* file is a valid plugin file extension for the game and that its
* header (if applicable) can be parsed.
* @param pluginPath
* The path to the file to check. Relative paths are resolved relative
* to the game's plugins directory, while absolute paths are used
* as given.
* @returns True if the file is a valid plugin, false otherwise.
*/
virtual bool IsValidPlugin(const std::filesystem::path& pluginPath) const = 0;
/**
* @brief Parses plugins and loads their data.
* @details If a given plugin filename (or one that is case-insensitively
* equal) has already been loaded, its previously-loaded data
* data is discarded, invalidating any existing shared pointers to
* that plugin's PluginInterface object.
*
* If the game is Morrowind, OpenMW or Starfield, it's only valid to
* fully load a plugin if its masters are already loaded or included
* in the same input vector.
* @param pluginPaths
* The plugin paths to load. Relative paths are resolved relative to
* the game's plugins directory, while absolute paths are used as
* given. Each plugin filename must be unique within the vector.
* @param loadHeadersOnly
* If true, only the plugins' headers are loaded. If false, all records
* in the plugins are parsed.
*/
virtual void LoadPlugins(
const std::vector<std::filesystem::path>& pluginPaths,
bool loadHeadersOnly) = 0;
/**
* @brief Clears the plugins loaded by previous calls to `LoadPlugins()`.
* @details This invalidates any PluginInterface pointers retrieved using
* `GetPlugin()` or `GetLoadedPlugins()`.
*/
virtual void ClearLoadedPlugins() = 0;
/**
* @brief Get data for a loaded plugin.
* @param pluginName
* The filename of the plugin to get data for.
* @returns A shared pointer to a const PluginInterface implementation. The
* pointer is null if the given plugin has not been loaded. The
* pointer remains valid until the `ClearLoadedPlugins()` function
* is called, this GameInterface is destroyed, or until a plugin with
* a case-insensitively equal filename is loaded.
*/
virtual const PluginInterface* GetPlugin(
const std::string& pluginName) const = 0;
/**
* @brief Get a set of const references to all loaded plugins' PluginInterface
* objects.
* @returns A set of shared pointers to const PluginInterface. The pointers
* remain valid until the `ClearLoadedPlugins()` function is called,
* this GameInterface is destroyed, or until a plugin with a
* case-insensitively equal filename is loaded.
*/
virtual std::vector<const PluginInterface*> GetLoadedPlugins() const = 0;
/**
* @}
* @name Sorting
* @{
*/
/**
* @brief Calculates a new load order for the game's installed plugins
* (including inactive plugins) and outputs the sorted order.
* @details Pulls metadata from the masterlist and userlist if they are
* loaded, and reads the contents of each plugin. No changes are
* applied to the load order used by the game. This function does
* not load or evaluate the masterlist or userlist.
* @param pluginPaths
* The plugins to sort, in their current load order. All given plugins
* must have been loaded using `LoadPlugins()`.
* @returns A vector of the given plugin filenames in their sorted load
* order.
*/
virtual std::vector<std::string> SortPlugins(
const std::vector<std::string>& pluginFilenames) = 0;
/**
* @}
* @name Load Order Interaction
* @{
*/
/**
*
* @brief Load the current load order state, discarding any previously held
* state.
* @details This function should be called whenever the load order or active
* state of plugins "on disk" changes, so that the cached state is
* updated to reflect the changes.
*/
virtual void LoadCurrentLoadOrderState() = 0;
/**
* @brief Check if the load order is ambiguous.
* @details This checks that all plugins in the current load order state have
* a well-defined position in the "on disk" state, and that all data
* sources are consistent. If the load order is ambiguous, different
* applications may read different load orders from the same source
* data.
* @returns True if the load order is ambiguous, false otherwise.
*/
virtual bool IsLoadOrderAmbiguous() const = 0;
/**
* @brief Gets the path to the file that holds the list of active plugins.
* @details The active plugins file path is often within the game's local
path, but its name and location varies by game and game
configuration, so this function exposes the path that libloot
uses.
* @returns The file path.
*/
virtual std::filesystem::path GetActivePluginsFilePath() const = 0;
/**
* @brief Check if a plugin is active.
* @param plugin
* The filename of the plugin for which to check the active state.
* @returns True if the plugin is active, false otherwise.
*/
virtual bool IsPluginActive(const std::string& plugin) const = 0;
/**
* @brief Get the current load order.
* @returns A vector of plugin filenames in their load order.
*/
virtual std::vector<std::string> GetLoadOrder() const = 0;
/**
* @brief Set the game's load order.
* @details There is no way to persist the load order of inactive OpenMW
* plugins, so setting an OpenMW load order will have no effect if
* the relative order of active plugins is unchanged.
* @param loadOrder
* A vector of plugin filenames sorted in the load order to set.
*/
virtual void SetLoadOrder(const std::vector<std::string>& loadOrder) = 0;
};
}
#endif
+55
View File
@@ -0,0 +1,55 @@
/* 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
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_LOOT_VERSION
#define LOOT_LOOT_VERSION
#include <string>
#include "loot/api_decorator.h"
namespace loot {
/** @brief libloot's major version number. */
inline constexpr unsigned int LIBLOOT_VERSION_MAJOR = 0;
/** @brief libloot's minor version number. */
inline constexpr unsigned int LIBLOOT_VERSION_MINOR = 25;
/** @brief libloot's patch version number. */
inline constexpr unsigned int LIBLOOT_VERSION_PATCH = 3;
/**
* @brief Get the library version.
* @return A string of the form "major.minor.patch".
*/
LOOT_API std::string GetLiblootVersion();
/**
* @brief Get the source control revision that libloot was built from.
* @return A string containing the revision ID.
*/
LOOT_API std::string GetLiblootRevision();
}
#endif
@@ -0,0 +1,69 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2012-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_METADATA_CONDITIONAL_METADATA
#define LOOT_METADATA_CONDITIONAL_METADATA
#include <string>
#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.
* @return A ConditionalMetadata object.
*/
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.
* @return A ConditionalMetadata object.
*/
LOOT_API explicit ConditionalMetadata(const std::string& 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
+137
View File
@@ -0,0 +1,137 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2012-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_METADATA_FILE
#define LOOT_METADATA_FILE
#include <string>
#include "loot/api_decorator.h"
#include "loot/metadata/conditional_metadata.h"
#include "loot/metadata/filename.h"
#include "loot/metadata/message_content.h"
namespace loot {
/**
* Represents a file in a game's Data folder, including files in subdirectories.
*/
class File : public ConditionalMetadata {
public:
/**
* Construct a File with blank name, display and condition strings.
* @return A File object.
*/
LOOT_API File() = default;
/**
* Construct a File with the given name, display name and condition strings.
* @param name
* The filename of the file.
* @param display
* The name to be displayed for the file in messages, formatted using
* CommonMark.
* @param condition
* The File's condition string.
* @param detail
* The detail message content, which may be appended to any messages
* generated for this file. If multilingual, one language must be
* English.
* @return A File object.
*/
LOOT_API explicit File(const std::string& name,
const std::string& display = "",
const std::string& condition = "",
const std::vector<MessageContent>& detail = {});
/**
* Get the filename of the file.
* @return The file's filename.
*/
LOOT_API Filename GetName() const;
/**
* Get the display name of the file.
* @return The file's display name.
*/
LOOT_API std::string GetDisplayName() const;
/**
* Get the detail message content of the file.
*
* If this file causes an error message to be displayed, the detail message
* content should be appended to that message, as it provides more detail
* about the error (e.g. suggestions for how to resolve it).
*/
LOOT_API std::vector<MessageContent> GetDetail() const;
private:
Filename name_;
std::string display_;
std::vector<MessageContent> detail_;
};
/**
* Check if two File objects are equal by comparing their fields.
* @returns True if the objects' fields are equal, false otherwise.
*/
LOOT_API bool operator==(const File& lhs, const File& rhs);
/**
* Check if two File objects are not equal.
* @returns True if the File objects are not equal, false otherwise.
*/
LOOT_API bool operator!=(const File& lhs, const File& rhs);
/**
* A less-than operator implemented with no semantics so that File objects can
* be stored in sets.
* @returns True if the first File is less than the second File, false
* otherwise.
*/
LOOT_API bool operator<(const File& lhs, const File& rhs);
/**
* Check if the first File object is greater than the second File object.
* @returns True if the second File object is less than the first File object,
* false otherwise.
*/
LOOT_API bool operator>(const File& lhs, const File& rhs);
/**
* Check if the first File object is less than or equal to the second File
* object.
* @returns True if the first File object is not greater than the second File
* object, false otherwise.
*/
LOOT_API bool operator<=(const File& lhs, const File& rhs);
/**
* Check if the first File object is greater than or equal to the second File
* object.
* @returns True if the first File object is not less than the second File
* object, false otherwise.
*/
LOOT_API bool operator>=(const File& lhs, const File& rhs);
}
#endif
+104
View File
@@ -0,0 +1,104 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2012-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_METADATA_FILENAME
#define LOOT_METADATA_FILENAME
#include <string>
#include "loot/api_decorator.h"
namespace loot {
/**
* Represents a case-insensitive filename.
*/
class Filename {
public:
/**
* Construct a Filename using an empty string.
* @return A Filename object.
*/
LOOT_API Filename() = default;
/**
* Construct a Filename using the given string.
* @return A Filename object.
*/
LOOT_API explicit Filename(const std::string& filename);
/**
* Get this Filename as a string.
*/
LOOT_API explicit operator std::string() const;
private:
std::string filename_;
};
/**
* Check if two Filename objects are equal by comparing their fields.
* @returns True if the filenames are case-insensitively equal and all other
* fields are case-sensitively equal, false otherwise.
*/
LOOT_API bool operator==(const Filename& lhs, const Filename& rhs);
/**
* Check if two Filename objects are not equal.
* @returns True if the Filename objects are not equal, false otherwise.
*/
LOOT_API bool operator!=(const Filename& lhs, const Filename& rhs);
/**
* A less-than operator implemented with no semantics so that Filename objects
* can be stored in sets.
* @returns True if this Filename is less than the given Filename, false
* otherwise.
*/
LOOT_API bool operator<(const Filename& lhs, const Filename& rhs);
/**
* Check if the first Filename object is greater than the second Filename
* object.
* @returns True if the second Filename object is less than the first Filename
* object, false otherwise.
*/
LOOT_API bool operator>(const Filename& lhs, const Filename& rhs);
/**
* Check if the first Filename object is less than or equal to the second
* Filename object.
* @returns True if the first Filename object is not greater than the second
* Filename object, false otherwise.
*/
LOOT_API bool operator<=(const Filename& lhs, const Filename& rhs);
/**
* Check if the first Filename object is greater than or equal to the second
* Filename object.
* @returns True if the first Filename object is not less than the second
* Filename object, false otherwise.
*/
LOOT_API bool operator>=(const Filename& lhs, const Filename& rhs);
}
#endif
+134
View File
@@ -0,0 +1,134 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2018 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_METADATA_GROUP
#define LOOT_METADATA_GROUP
#include <string>
#include <vector>
#include "loot/api_decorator.h"
namespace loot {
/**
* Represents a group to which plugin metadata objects can belong.
*/
class Group {
public:
/**
* The name of the group to which all plugins belong by default.
*/
static constexpr const char* DEFAULT_NAME = "default";
/**
* Construct a Group with the name "default" and an empty set of groups to
* load after.
* @return A Group object.
*/
LOOT_API Group() = default;
/**
* Construct a Group with the given name, description and set of groups to
* load after.
* @param name
* The group name.
* @param afterGroups
* The names of groups this group loads after.
* @param description
* A description of the group.
* @return A Group object.
*/
LOOT_API explicit Group(const std::string& name,
const std::vector<std::string>& afterGroups = {},
const std::string& description = "");
/**
* Get the name of the group.
* @return The group's name.
*/
LOOT_API std::string GetName() const;
/**
* Get the description of the group.
* @return The group's description.
*/
LOOT_API std::string GetDescription() const;
/**
* Get the set of groups this group loads after.
* @return A set of group names.
*/
LOOT_API std::vector<std::string> GetAfterGroups() const;
private:
std::string name_{DEFAULT_NAME};
std::string description_;
std::vector<std::string> afterGroups_;
};
/**
* Check if two Group objects are equal by comparing their names.
* @returns True if the objects' fields are equal, false otherwise.
*/
LOOT_API bool operator==(const Group& lhs, const Group& rhs);
/**
* Check if two Group objects are not equal.
* @returns True if the Group objects are not equal, false otherwise.
*/
LOOT_API bool operator!=(const Group& lhs, const Group& rhs);
/**
* A less-than operator implemented with no semantics so that Group objects
* can be stored in sets.
* @returns True if the first Group is less than the second Group, false
* otherwise.
*/
LOOT_API bool operator<(const Group& lhs, const Group& rhs);
/**
* Check if the first Group object is greater than the second Group
* object.
* @returns True if the second Group object is less than the first Group
* object, false otherwise.
*/
LOOT_API bool operator>(const Group& lhs, const Group& rhs);
/**
* Check if the first Group object is less than or equal to the second
* Group object.
* @returns True if the first Group object is not greater than the second
* Group object, false otherwise.
*/
LOOT_API bool operator<=(const Group& lhs, const Group& rhs);
/**
* Check if the first Group object is greater than or equal to the second
* Group object.
* @returns True if the first Group object is not less than the second
* Group object, false otherwise.
*/
LOOT_API bool operator>=(const Group& lhs, const Group& rhs);
}
#endif
+117
View File
@@ -0,0 +1,117 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2012-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_METADATA_LOCATION
#define LOOT_METADATA_LOCATION
#include <string>
#include <vector>
#include "loot/api_decorator.h"
namespace loot {
/**
* Represents a URL at which the parent plugin can be found.
*/
class Location {
public:
/**
* Construct a Location with empty URL and name strings.
* @return A Location object.
*/
LOOT_API Location() = default;
/**
* Construct a Location with the given URL and name.
* @param url
* The URL at which the plugin can be found.
* @param name
* A name for the URL, eg. the page or site name.
* @return A Location object.
*/
LOOT_API explicit Location(const std::string& url,
const std::string& name = "");
/**
* Get the object's URL.
* @return A URL string.
*/
LOOT_API std::string GetURL() const;
/**
* Get the object's name.
* @return The name of the location.
*/
LOOT_API std::string GetName() const;
private:
std::string url_;
std::string name_;
};
/**
* Check if two Location objects are equal by comparing their fields.
* @returns True if the objects' fields are equal, false otherwise.
*/
LOOT_API bool operator==(const Location& lhs, const Location& rhs);
/**
* Check if two Location objects are not equal.
* @returns True if the Location objects are not equal, false otherwise.
*/
LOOT_API bool operator!=(const Location& lhs, const Location& rhs);
/**
* A less-than operator implemented with no semantics so that Location objects
* can be stored in sets.
* @returns True if the first Location is less than the second Location, false
* otherwise.
*/
LOOT_API bool operator<(const Location& lhs, const Location& rhs);
/**
* Check if the first Location object is greater than the second Location
* object.
* @returns True if the second Location object is less than the first Location
* object, false otherwise.
*/
LOOT_API bool operator>(const Location& lhs, const Location& rhs);
/**
* Check if the first Location object is less than or equal to the second
* Location object.
* @returns True if the first Location object is not greater than the second
* Location object, false otherwise.
*/
LOOT_API bool operator<=(const Location& lhs, const Location& rhs);
/**
* Check if the first Location object is greater than or equal to the second
* Location object.
* @returns True if the first Location object is not less than the second
* Location object, false otherwise.
*/
LOOT_API bool operator>=(const Location& lhs, const Location& rhs);
}
#endif

Some files were not shown because too many files have changed in this diff Show More