Be a bit more consistent with function naming

This makes it so that all non-public functions use camelCase and all public functions use PascalCase.

I regret choosing to use PascalCase for function names, but it's not worth breaking the whole public API to change that, and at least this approach has precedent in how Go decides if a function is public or private.
This commit is contained in:
Oliver Hamlet
2025-07-26 21:49:49 +01:00
parent e6ced54842
commit d6be961095
5 changed files with 15 additions and 17 deletions
+4 -3
View File
@@ -67,7 +67,7 @@ loot::rust::LogLevel convert(LogLevel level) {
}
}
void logging_callback(uint8_t level, const char* message, void* context) {
void loggingCallback(uint8_t level, const char* message, void* context) {
auto& callback = *static_cast<Callback*>(context);
callback(convert(level), message);
@@ -75,9 +75,10 @@ void logging_callback(uint8_t level, const char* message, void* context) {
}
namespace loot {
LOOT_API void SetLoggingCallback(Callback callback) {
LOOT_API void SetLoggingCallback(
std::function<void(LogLevel, std::string_view)> callback) {
STORED_CALLBACK = callback;
libloot_set_logging_callback(logging_callback, &STORED_CALLBACK);
libloot_set_logging_callback(loggingCallback, &STORED_CALLBACK);
}
LOOT_API void SetLogLevel(LogLevel level) {
@@ -56,11 +56,9 @@ std::string describeEdgeType(EdgeType edgeType) {
return "Unknown";
}
}
}
namespace loot {
// A.esp --[Master Flag]-> B.esp --Group->
std::string describeCycle(const std::vector<Vertex>& cycle) {
std::string describeCycle(const std::vector<loot::Vertex>& cycle) {
std::string text;
for (const auto& vertex : cycle) {
text += vertex.GetName();
@@ -76,7 +74,9 @@ std::string describeCycle(const std::vector<Vertex>& cycle) {
return text;
}
}
namespace loot {
CyclicInteractionError::CyclicInteractionError(std::vector<Vertex> cycle) :
std::runtime_error("Cyclic interaction detected: " + describeCycle(cycle)),
cycle_(cycle) {}
+6 -6
View File
@@ -67,7 +67,7 @@ loot::rust::GameType convert(loot::GameType gameType) {
}
}
std::filesystem::path to_path(const rust::String& string) {
std::filesystem::path toPath(const rust::String& string) {
return std::filesystem::u8path(string.begin(), string.end());
}
@@ -87,7 +87,7 @@ rust::Box<loot::rust::Game> constructGame(
}
}
std::vector<::rust::Str> as_str_refs(const std::vector<std::string>& vector) {
std::vector<::rust::Str> asStrRefs(const std::vector<std::string>& vector) {
std::vector<::rust::Str> strings;
for (const auto& str : vector) {
strings.push_back(str);
@@ -120,7 +120,7 @@ std::vector<std::filesystem::path> Game::GetAdditionalDataPaths() const {
try {
std::vector<std::filesystem::path> paths;
for (const auto& path_string : game_->additional_data_paths()) {
paths.push_back(to_path(path_string));
paths.push_back(toPath(path_string));
}
return paths;
@@ -199,7 +199,7 @@ std::vector<std::shared_ptr<const PluginInterface>> Game::GetLoadedPlugins()
std::vector<std::string> Game::SortPlugins(
const std::vector<std::string>& pluginFilenames) {
const auto strs = as_str_refs(pluginFilenames);
const auto strs = asStrRefs(pluginFilenames);
try {
const auto results = game_->sort_plugins(::rust::Slice(strs));
@@ -228,7 +228,7 @@ bool Game::IsLoadOrderAmbiguous() const {
std::filesystem::path Game::GetActivePluginsFilePath() const {
try {
return to_path(game_->active_plugins_file_path());
return toPath(game_->active_plugins_file_path());
} catch (const ::rust::Error& e) {
std::rethrow_exception(mapError(e));
}
@@ -243,7 +243,7 @@ std::vector<std::string> Game::GetLoadOrder() const {
}
void Game::SetLoadOrder(const std::vector<std::string>& loadOrder) {
const auto strs = as_str_refs(loadOrder);
const auto strs = asStrRefs(loadOrder);
try {
game_->set_load_order(::rust::Slice(strs));
-3
View File
@@ -17,9 +17,6 @@ public:
const std::filesystem::path& gamePath,
const std::filesystem::path& gameLocalDataPath = "");
// Game Interface Methods //
////////////////////////////
GameType GetType() const override;
std::vector<std::filesystem::path> GetAdditionalDataPaths() const override;
+2 -2
View File
@@ -51,7 +51,7 @@ std::vector<T> mergeVectors(std::vector<T> first,
return first;
}
std::string TrimDotGhostExtension(std::string&& filename) {
std::string trimDotGhostExtension(std::string&& filename) {
using std::string_view_literals::operator""sv;
// If the name passed ends in '.ghost', that should be trimmed.
constexpr std::string_view GHOST_FILE_EXTENSION = ".ghost"sv;
@@ -81,7 +81,7 @@ std::string TrimDotGhostExtension(std::string&& filename) {
namespace loot {
// If the name passed ends in '.ghost', that should be trimmed.
PluginMetadata::PluginMetadata(std::string_view n) :
name_(TrimDotGhostExtension(std::string(n))) {}
name_(trimDotGhostExtension(std::string(n))) {}
void PluginMetadata::MergeMetadata(const PluginMetadata& plugin) {
if (plugin.HasNameOnly())