run clang-format

This commit is contained in:
Lucca Jiménez Könings 2024-06-26 14:06:06 +02:00
parent 3c80bcbf01
commit 29f4d0d286
19 changed files with 44 additions and 57 deletions

View File

@ -37,8 +37,8 @@
#include <filesystem>
namespace fs = std::filesystem;
#include "TConsole.h"
#include "Settings.h"
#include "TConsole.h"
struct Version {
uint8_t major;
@ -61,8 +61,6 @@ class Application final {
public:
// types
using TShutdownHandler = std::function<void()>;
// methods

View File

@ -17,7 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include "rapidjson/stringbuffer.h"
#include "rapidjson/prettywriter.h"
#include "rapidjson/document.h"
#include "rapidjson/prettywriter.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/writer.h"

View File

@ -23,8 +23,8 @@
* and write locks and read locks are mutually exclusive.
*/
#include <shared_mutex>
#include <mutex>
#include <shared_mutex>
// Use ReadLock(m) and WriteLock(m) to lock it.
using RWMutex = std::shared_mutex;

View File

@ -142,5 +142,3 @@ struct Settings {
void setConsoleInputAccessMapping(const ComposedKey& keyName, int value);
void setConsoleInputAccessMapping(const ComposedKey& keyName, bool value);
};

View File

@ -2,24 +2,21 @@
#include "Common.h"
#include <regex>
std::chrono::high_resolution_clock::duration ChronoWrapper::TimeFromStringWithLiteral(const std::string& time_str)
{
std::chrono::high_resolution_clock::duration ChronoWrapper::TimeFromStringWithLiteral(const std::string& time_str) {
// const std::regex time_regex(R"((\d+\.{0,1}\d*)(min|ms|us|ns|[dhs]))"); //i.e one of: "25ns, 6us, 256ms, 2s, 13min, 69h, 356d" will get matched (only available in newer C++ versions)
const std::regex time_regex(R"((\d+\.{0,1}\d*)(min|[dhs]))"); // i.e one of: "2.01s, 13min, 69h, 356.69d" will get matched
std::smatch match;
float time_value;
if (!std::regex_search(time_str, match, time_regex)) return std::chrono::nanoseconds(0);
if (!std::regex_search(time_str, match, time_regex))
return std::chrono::nanoseconds(0);
time_value = stof(match.str(1));
if (match.str(2) == "d") {
return std::chrono::seconds((uint64_t)(time_value * 86400)); // 86400 seconds in a day
}
else if (match.str(2) == "h") {
} else if (match.str(2) == "h") {
return std::chrono::seconds((uint64_t)(time_value * 3600)); // 3600 seconds in an hour
}
else if (match.str(2) == "min") {
} else if (match.str(2) == "min") {
return std::chrono::seconds((uint64_t)(time_value * 60));
}
else if (match.str(2) == "s") {
} else if (match.str(2) == "s") {
return std::chrono::seconds((uint64_t)time_value);
}
return std::chrono::nanoseconds(0);

View File

@ -22,13 +22,13 @@
#include "TConsole.h"
#include <array>
#include <charconv>
#include <chrono>
#include <fmt/core.h>
#include <iostream>
#include <map>
#include <regex>
#include <sstream>
#include <thread>
#include <chrono>
#include "Compat.h"
#include "CustomAssert.h"
@ -383,4 +383,3 @@ void SplitString(const std::string& str, const char delim, std::vector<std::stri
out.push_back(str.substr(start, end - start));
}
}

View File

@ -20,8 +20,8 @@
#include "Client.h"
#include "Common.h"
#include "CustomAssert.h"
#include "TLuaEngine.h"
#include "Settings.h"
#include "TLuaEngine.h"
#include <nlohmann/json.hpp>

View File

@ -57,4 +57,3 @@ size_t prof::UnitExecutionTime::measurement_count() const {
std::unique_lock lock(m_mtx);
return m_total_calls;
}

View File

@ -18,8 +18,6 @@
#include "Settings.h"
Settings::Settings() {
SettingsMap = std::unordered_map<Key, SettingsTypeVariant> {
// All entries which contain std::strings must be explicitly constructed, otherwise they become 'bool'
@ -61,8 +59,6 @@ Settings::Settings(){
{ { "Misc", "ImScaredOfUpdates" }, { Misc_ImScaredOfUpdates, READ_WRITE } },
{ { "Misc", "UpdateReminderTime" }, { Misc_UpdateReminderTime, READ_WRITE } }
};
}
std::string Settings::getAsString(Key key) {

View File

@ -19,8 +19,8 @@
#include "Common.h"
#include "Env.h"
#include "TConfig.h"
#include "Settings.h"
#include "TConfig.h"
#include <cstdlib>
#include <exception>
#include <fstream>

View File

@ -18,9 +18,9 @@
#include "THeartbeatThread.h"
#include "ChronoWrapper.h"
#include "Client.h"
#include "Http.h"
#include "ChronoWrapper.h"
// #include "SocketIO.h"
#include <rapidjson/document.h>
#include <rapidjson/rapidjson.h>

View File

@ -20,6 +20,7 @@
#include "Common.h"
#include "Http.h"
#include "LuaAPI.h"
#include "Settings.h"
#include "SignalHandling.h"
#include "TConfig.h"
#include "THeartbeatThread.h"
@ -29,7 +30,6 @@
#include "TPluginMonitor.h"
#include "TResourceManager.h"
#include "TServer.h"
#include "Settings.h"
#include <cstdint>
#include <iostream>