Run clang-format on whole repository

Using:

shopt -s globstar
/mnt/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2019/Community/VC/Tools/Llvm/bin/clang-format.exe -i include/**/*.h  src/**/*.h src/**/*.cpp
This commit is contained in:
Oliver Hamlet
2022-02-06 18:31:41 +00:00
parent b5cde3b303
commit d595bcf56e
64 changed files with 402 additions and 401 deletions
+16 -9
View File
@@ -43,9 +43,11 @@
namespace loot {
/**@}*/
/**********************************************************************//**
* @name Logging Functions
*************************************************************************/
/**********************************************************************/ /**
* @name
*Logging
*Functions
*************************************************************************/
/**@{*/
/**
@@ -60,9 +62,11 @@ LOOT_API void SetLoggingCallback(
std::function<void(LogLevel, const char*)> callback);
/**@}*/
/**********************************************************************//**
* @name Version Functions
*************************************************************************/
/**********************************************************************/ /**
* @name
*Version
*Functions
*************************************************************************/
/**@{*/
/**
@@ -83,9 +87,12 @@ LOOT_API bool IsCompatible(const unsigned int major,
const unsigned int patch);
/**@}*/
/**********************************************************************//**
* @name Lifecycle Management Functions
*************************************************************************/
/**********************************************************************/ /**
* @name
*Lifecycle
*Management
*Functions
*************************************************************************/
/**@{*/
/**
+4 -3
View File
@@ -62,9 +62,10 @@ public:
* 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;
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.
+19 -16
View File
@@ -47,6 +47,7 @@ public:
LOOT_API explicit Filename(const std::string& filename);
LOOT_API explicit operator std::string() const;
private:
std::string filename_;
};
@@ -56,7 +57,7 @@ private:
* @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);
LOOT_API bool operator==(const Filename& lhs, const Filename& rhs);
/**
* Check if two Filename objects are not equal.
@@ -65,32 +66,34 @@ LOOT_API bool operator==(const Filename& lhs,const Filename& rhs);
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.
* 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);
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.
* 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.
* 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.
* 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);
}
+2 -2
View File
@@ -54,8 +54,8 @@ public:
* @return A Group object.
*/
LOOT_API explicit Group(const std::string& name,
const std::vector<std::string>& afterGroups = {},
const std::string& description = "");
const std::vector<std::string>& afterGroups = {},
const std::string& description = "");
/**
* Check if two Group objects are equal by comparing their names.
+8 -7
View File
@@ -49,12 +49,13 @@ public:
* 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 = "");
LOOT_API explicit Location(const std::string& url,
const std::string& name = "");
/**
* A less-than operator implemented with no semantics so that Location objects
* can be stored in sets.
* @returns True if this Location is less than the given Location, false
* @returns True if this Location is less than the given Location, false
* otherwise.
*/
LOOT_API bool operator<(const Location& rhs) const;
@@ -89,7 +90,7 @@ private:
LOOT_API bool operator!=(const Location& lhs, const Location& rhs);
/**
* Check if the first Location object is greater than the second Location
* 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.
@@ -97,17 +98,17 @@ LOOT_API bool operator!=(const Location& lhs, const Location& rhs);
LOOT_API bool operator>(const Location& lhs, const Location& rhs);
/**
* Check if the first Location object is less than or equal to the second
* 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
* @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
* 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
* @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);
+8 -6
View File
@@ -58,8 +58,8 @@ public:
* @return A Message object.
*/
LOOT_API explicit Message(const MessageType type,
const std::string& content,
const std::string& condition = "");
const std::string& content,
const std::string& condition = "");
/**
* Construct a Message object with the given type, content and condition
@@ -73,8 +73,8 @@ public:
* @return A Message object.
*/
LOOT_API explicit Message(const MessageType type,
const std::vector<MessageContent>& content,
const std::string& condition = "");
const std::vector<MessageContent>& content,
const std::string& condition = "");
/**
* Construct a Message object from a SimpleMessage object.
@@ -117,7 +117,8 @@ public:
* @return A MessageContent object for the preferred language, or for English
* if a MessageContent object is not available for the given language.
*/
LOOT_API std::optional<MessageContent> GetContent(const std::string& language) const;
LOOT_API std::optional<MessageContent> GetContent(
const std::string& language) const;
/**
* Get the message as a SimpleMessage given a language.
@@ -126,7 +127,8 @@ public:
* @return A SimpleMessage object for the preferred language, or for English
* if message text is not available for the given language.
*/
LOOT_API std::optional<SimpleMessage> ToSimpleMessage(const std::string& language) const;
LOOT_API std::optional<SimpleMessage> ToSimpleMessage(
const std::string& language) const;
private:
MessageType type_;
+4 -3
View File
@@ -24,9 +24,9 @@
#ifndef LOOT_METADATA_MESSAGE_CONTENT
#define LOOT_METADATA_MESSAGE_CONTENT
#include <optional>
#include <string>
#include <vector>
#include <optional>
#include "loot/api_decorator.h"
@@ -56,8 +56,9 @@ public:
* The language that the message is written in.
* @return A MessageContent object.
*/
LOOT_API explicit MessageContent(const std::string& text,
const std::string& language = defaultLanguage);
LOOT_API explicit MessageContent(
const std::string& text,
const std::string& language = defaultLanguage);
/**
* Get the message text.
+9 -7
View File
@@ -76,12 +76,13 @@ public:
* The number of deleted navmeshes found in the plugin.
* @return A PluginCleaningData object.
*/
LOOT_API explicit PluginCleaningData(uint32_t crc,
const std::string& utility,
const std::vector<MessageContent>& detail,
unsigned int itm,
unsigned int ref,
unsigned int nav);
LOOT_API explicit PluginCleaningData(
uint32_t crc,
const std::string& utility,
const std::vector<MessageContent>& detail,
unsigned int itm,
unsigned int ref,
unsigned int nav);
/**
* A less-than operator implemented with no semantics so that
* PluginCleaningData objects can be stored in sets.
@@ -144,7 +145,8 @@ public:
* @return The MessageContent object for the preferred language, or if one
* does not exist, the English-language MessageContent object.
*/
LOOT_API std::optional<MessageContent> ChooseDetail(const std::string& language) const;
LOOT_API std::optional<MessageContent> ChooseDetail(
const std::string& language) const;
private:
uint32_t crc_;
+4 -4
View File
@@ -95,15 +95,15 @@ LOOT_API bool operator!=(const Tag& lhs, const Tag& rhs);
/**
* Check if the first Tag object is greater than the second Tag object.
* @returns True if the second Tag object is less than the first Tag object,
* @returns True if the second Tag object is less than the first Tag object,
* false otherwise.
*/
LOOT_API bool operator>(const Tag& lhs, const Tag& rhs);
/**
* Check if the first Tag object is less than or equal to the second Tag
* Check if the first Tag object is less than or equal to the second Tag
* object.
* @returns True if the first Tag object is not greater than the second Tag
* @returns True if the first Tag object is not greater than the second Tag
* object, false otherwise.
*/
LOOT_API bool operator<=(const Tag& lhs, const Tag& rhs);
@@ -111,7 +111,7 @@ LOOT_API bool operator<=(const Tag& lhs, const Tag& rhs);
/**
* Check if the first Tag object is greater than or equal to the second Tag
* object.
* @returns True if the first Tag object is not less than the second Tag
* @returns True if the first Tag object is not less than the second Tag
* object, false otherwise.
*/
LOOT_API bool operator>=(const Tag& lhs, const Tag& rhs);
+2 -2
View File
@@ -37,8 +37,8 @@ namespace loot {
class Game : public GameInterface {
public:
explicit Game(const GameType gameType,
const std::filesystem::path& gamePath,
const std::filesystem::path& gameLocalDataPath = "");
const std::filesystem::path& gamePath,
const std::filesystem::path& gameLocalDataPath = "");
// Internal Methods //
//////////////////////
+2 -3
View File
@@ -26,12 +26,11 @@
#define LOOT_API_GAME_LOAD_ORDER_HANDLER
#include <filesystem>
#include <libloadorder.hpp>
#include <list>
#include <vector>
#include <string>
#include <unordered_set>
#include <libloadorder.hpp>
#include <vector>
#include "loot/enum/game_type.h"
+1 -3
View File
@@ -24,12 +24,10 @@
#include "api/helpers/crc.h"
#include <boost/crc.hpp>
#include <fstream>
#include <boost/crc.hpp>
#include "api/helpers/logging.h"
#include "loot/exception/file_access_error.h"
using std::string;
+1 -1
View File
@@ -30,8 +30,8 @@
#define NOMINMAX
#endif
#include <spdlog/spdlog.h>
#include <spdlog/sinks/base_sink.h>
#include <spdlog/spdlog.h>
#include "loot/enum/log_level.h"
+48 -42
View File
@@ -43,8 +43,7 @@ void HandleError(const std::string operation, int returnCode) {
lci_get_error_message(&message);
if (message == nullptr) {
err += "Error code: " + std::to_string(returnCode);
}
else {
} else {
err += "Details: " + std::string(message);
}
@@ -58,26 +57,28 @@ void HandleError(const std::string operation, int returnCode) {
int mapGameType(GameType gameType) {
switch (gameType) {
case GameType::tes3:
return LCI_GAME_MORROWIND;
case GameType::tes4:
return LCI_GAME_OBLIVION;
case GameType::tes5:
return LCI_GAME_SKYRIM;
case GameType::tes5se:
return LCI_GAME_SKYRIM_SE;
case GameType::tes5vr:
return LCI_GAME_SKYRIM_VR;
case GameType::fo3:
return LCI_GAME_FALLOUT_3;
case GameType::fonv:
return LCI_GAME_FALLOUT_NV;
case GameType::fo4:
return LCI_GAME_FALLOUT_4;
case GameType::fo4vr:
return LCI_GAME_FALLOUT_4_VR;
default:
throw std::runtime_error("Unrecognised game type encountered while mapping for condition evaluation.");
case GameType::tes3:
return LCI_GAME_MORROWIND;
case GameType::tes4:
return LCI_GAME_OBLIVION;
case GameType::tes5:
return LCI_GAME_SKYRIM;
case GameType::tes5se:
return LCI_GAME_SKYRIM_SE;
case GameType::tes5vr:
return LCI_GAME_SKYRIM_VR;
case GameType::fo3:
return LCI_GAME_FALLOUT_3;
case GameType::fonv:
return LCI_GAME_FALLOUT_NV;
case GameType::fo4:
return LCI_GAME_FALLOUT_4;
case GameType::fo4vr:
return LCI_GAME_FALLOUT_4_VR;
default:
throw std::runtime_error(
"Unrecognised game type encountered while mapping for condition "
"evaluation.");
}
}
@@ -87,19 +88,21 @@ std::string IntToHexString(const uint32_t value) {
return stream.str();
}
ConditionEvaluator::ConditionEvaluator(
const GameType gameType,
const std::filesystem::path& dataPath) {
lci_state * state = nullptr;
ConditionEvaluator::ConditionEvaluator(const GameType gameType,
const std::filesystem::path& dataPath) {
lci_state* state = nullptr;
// This probably isn't correct for API users other than LOOT.
// But that probably doesn't matter, as the only things conditional
// on LOOT's version are LOOT-specific messages.
auto lootPath = std::filesystem::absolute("LOOT.exe");
int result = lci_state_create(&state, mapGameType(gameType), dataPath.u8string().c_str(), lootPath.u8string().c_str());
HandleError("create state object for condition evaluation", result);
// This probably isn't correct for API users other than LOOT.
// But that probably doesn't matter, as the only things conditional
// on LOOT's version are LOOT-specific messages.
auto lootPath = std::filesystem::absolute("LOOT.exe");
int result = lci_state_create(&state,
mapGameType(gameType),
dataPath.u8string().c_str(),
lootPath.u8string().c_str());
HandleError("create state object for condition evaluation", result);
lciState_ = std::shared_ptr<lci_state>(state, lci_state_destroy);
lciState_ = std::shared_ptr<lci_state>(state, lci_state_destroy);
}
bool ConditionEvaluator::Evaluate(const std::string& condition) {
@@ -119,7 +122,8 @@ bool ConditionEvaluator::Evaluate(const std::string& condition) {
return result == LCI_RESULT_TRUE;
}
PluginMetadata ConditionEvaluator::EvaluateAll(const PluginMetadata& pluginMetadata) {
PluginMetadata ConditionEvaluator::EvaluateAll(
const PluginMetadata& pluginMetadata) {
PluginMetadata evaluatedMetadata(pluginMetadata.GetName());
evaluatedMetadata.SetLocations(pluginMetadata.GetLocations());
@@ -190,7 +194,7 @@ void ConditionEvaluator::RefreshActivePluginsState(
std::vector<std::string> activePluginNames) {
ClearConditionCache();
std::vector<const char *> activePluginNameCStrings;
std::vector<const char*> activePluginNameCStrings;
for (auto& pluginName : activePluginNames) {
activePluginNameCStrings.push_back(pluginName.c_str());
}
@@ -202,7 +206,8 @@ void ConditionEvaluator::RefreshActivePluginsState(
cActivePluginNames = &activePluginNameCStrings[0];
}
int result = lci_state_set_active_plugins(lciState_.get(), cActivePluginNames, activePluginNameCStrings.size());
int result = lci_state_set_active_plugins(
lciState_.get(), cActivePluginNames, activePluginNameCStrings.size());
HandleError("cache active plugins for condition evaluation", result);
}
@@ -244,8 +249,8 @@ void ConditionEvaluator::RefreshLoadedPluginsState(
cPluginVersions = &pluginVersions[0];
}
int result = lci_state_set_plugin_versions(lciState_.get(), cPluginVersions,
pluginVersions.size());
int result = lci_state_set_plugin_versions(
lciState_.get(), cPluginVersions, pluginVersions.size());
HandleError("cache plugin versions for condition evaluation", result);
const plugin_crc* cPluginCrcs;
@@ -255,17 +260,18 @@ void ConditionEvaluator::RefreshLoadedPluginsState(
cPluginCrcs = &pluginCrcs[0];
}
result = lci_state_set_crc_cache(lciState_.get(), cPluginCrcs,
pluginCrcs.size());
result =
lci_state_set_crc_cache(lciState_.get(), cPluginCrcs, pluginCrcs.size());
HandleError("fill CRC cache for condition evaluation", result);
}
bool ConditionEvaluator::Evaluate(const PluginCleaningData& cleaningData,
const std::string& pluginName) {
const std::string& pluginName) {
if (pluginName.empty())
return false;
return Evaluate("checksum(\"" + pluginName + "\", " + IntToHexString(cleaningData.GetCRC()) + ")");
return Evaluate("checksum(\"" + pluginName + "\", " +
IntToHexString(cleaningData.GetCRC()) + ")");
}
void ParseCondition(const std::string& condition) {
+6 -5
View File
@@ -25,11 +25,11 @@
#ifndef LOOT_API_METADATA_CONDITION_EVALUATOR
#define LOOT_API_METADATA_CONDITION_EVALUATOR
#include <loot_condition_interpreter.h>
#include <filesystem>
#include <string>
#include <loot_condition_interpreter.h>
#include "api/game/game_cache.h"
#include "api/game/load_order_handler.h"
#include "loot/metadata/plugin_cleaning_data.h"
@@ -39,18 +39,19 @@ namespace loot {
class ConditionEvaluator {
public:
explicit ConditionEvaluator(const GameType gameType,
const std::filesystem::path& dataPath);
const std::filesystem::path& dataPath);
bool Evaluate(const std::string& condition);
PluginMetadata EvaluateAll(const PluginMetadata& pluginMetadata);
void ClearConditionCache();
void RefreshActivePluginsState(std::vector<std::string> activePluginNames);
void RefreshLoadedPluginsState(std::vector<std::shared_ptr<const PluginInterface>> plugins);
void RefreshLoadedPluginsState(
std::vector<std::shared_ptr<const PluginInterface>> plugins);
private:
bool Evaluate(const PluginCleaningData& cleaningData,
const std::string& pluginName);
const std::string& pluginName);
std::shared_ptr<lci_state> lciState_;
};
+2 -1
View File
@@ -84,7 +84,8 @@ std::string File::GetDisplayName() const {
std::vector<MessageContent> File::GetDetail() const { return detail_; }
std::optional<MessageContent> File::ChooseDetail(const std::string& language) const {
std::optional<MessageContent> File::ChooseDetail(
const std::string& language) const {
return MessageContent::Choose(detail_, language);
}
+10 -5
View File
@@ -29,8 +29,7 @@
namespace loot {
Filename::Filename() {}
Filename::Filename(const std::string& filename) :
filename_(filename) {}
Filename::Filename(const std::string& filename) : filename_(filename) {}
Filename::operator std::string() const { return filename_; }
@@ -38,7 +37,9 @@ bool operator==(const Filename& lhs, const Filename& rhs) {
return CompareFilenames(std::string(lhs), std::string(rhs)) == 0;
}
bool operator!=(const Filename& lhs, const Filename& rhs) { return !(lhs == rhs); }
bool operator!=(const Filename& lhs, const Filename& rhs) {
return !(lhs == rhs);
}
bool operator<(const Filename& lhs, const Filename& rhs) {
return CompareFilenames(std::string(lhs), std::string(rhs)) < 0;
@@ -46,7 +47,11 @@ bool operator<(const Filename& lhs, const Filename& rhs) {
bool operator>(const Filename& lhs, const Filename& rhs) { return rhs < lhs; }
bool operator<=(const Filename& lhs, const Filename& rhs) { return !(lhs > rhs); }
bool operator<=(const Filename& lhs, const Filename& rhs) {
return !(lhs > rhs);
}
bool operator>=(const Filename& lhs, const Filename& rhs) { return !(lhs < rhs); }
bool operator>=(const Filename& lhs, const Filename& rhs) {
return !(lhs < rhs);
}
}
+3 -9
View File
@@ -32,9 +32,7 @@ Group::Group() : name_("default") {}
Group::Group(const std::string& name,
const std::vector<std::string>& afterGroups,
const std::string& description) :
name_(name),
afterGroups_(afterGroups),
description_(description) {}
name_(name), afterGroups_(afterGroups), description_(description) {}
bool Group::operator==(const Group& rhs) const {
return name_ == rhs.name_ && description_ == rhs.description_ &&
@@ -65,13 +63,9 @@ std::string Group::GetName() const { return name_; }
std::string Group::GetDescription() const { return description_; }
std::vector<std::string> Group::GetAfterGroups() const {
return afterGroups_;
}
std::vector<std::string> Group::GetAfterGroups() const { return afterGroups_; }
bool operator!=(const Group& lhs, const Group& rhs) {
return !(lhs == rhs);
}
bool operator!=(const Group& lhs, const Group& rhs) { return !(lhs == rhs); }
bool operator>(const Group& lhs, const Group& rhs) { return rhs < lhs; }
+1 -2
View File
@@ -28,8 +28,7 @@ namespace loot {
Location::Location() {}
Location::Location(const std::string& url, const std::string& name) :
url_(url),
name_(name) {}
url_(url), name_(name) {}
bool Location::operator<(const Location& rhs) const {
if (url_ < rhs.url_) {
+2 -4
View File
@@ -34,16 +34,14 @@ Message::Message() : type_(MessageType::say) {}
Message::Message(const MessageType type,
const std::string& content,
const std::string& condition) :
type_(type),
type_(type),
content_({MessageContent(content)}),
ConditionalMetadata(condition) {}
Message::Message(const MessageType type,
const std::vector<MessageContent>& content,
const std::string& condition) :
type_(type),
content_(content),
ConditionalMetadata(condition) {
type_(type), content_(content), ConditionalMetadata(condition) {
if (content.size() > 1) {
bool englishStringExists = false;
for (const auto& mc : content) {

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