From b8c21ebbde6a3c195228ef2baca3458feb107406 Mon Sep 17 00:00:00 2001 From: cat Date: Mon, 16 Mar 2026 09:30:29 +0200 Subject: [PATCH] Removed LogLevel being enum class --- headers/Containers/DualkeyMap.hpp | 22 +++++++++++----------- headers/Containers/Hashmap.hpp | 10 ++++------ headers/Systems/Logging.hpp | 4 ++-- source/Systems/Logging.cpp | 4 ++-- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/headers/Containers/DualkeyMap.hpp b/headers/Containers/DualkeyMap.hpp index 92582dc..36fcf0e 100644 --- a/headers/Containers/DualkeyMap.hpp +++ b/headers/Containers/DualkeyMap.hpp @@ -16,7 +16,6 @@ #include "Corrade/Containers/Array.h" #include -#include #include #include #include @@ -207,16 +206,17 @@ public: } template , - std::size_t keyCount> + typename OppositeKey = Concepts::OppositeOf> requires Concepts::Either [[nodiscard("Discarding a very expensive query!")]] std::vector> - QueryWithAll(const Key (&keys)[keyCount]) { + QueryWithAll(const Corrade::Containers::Array &keys) { std::vector> queryResult = queryWithMany(keys); + std::erase_if(queryResult, - [](const MultiQueryResult &queryRecord) { + [keyCount = keys.size()]( + const MultiQueryResult &queryRecord) { return queryRecord.howManyFound != keyCount; }); return queryResult; @@ -270,14 +270,14 @@ private: // Interal querying template , - std::size_t keyCount> + typename OppositeKey = Concepts::OppositeOf> inline std::vector> - queryWithMany(const Key (&keys)[keyCount]) { + queryWithMany(const Corrade::Containers::Array &keys) { constexpr bool searchingInFirstKey = std::is_same_v; + std::size_t keyCount = keys.size(); // I really can't wait for C++26 contracts - if constexpr (keyCount == 0) { + if (keyCount == 0) { Systems::Logging::Log("Failed to Query! QueryWithAll require at least 2 " "key to be given, zero was given! Terminating", "Dualkey Map", @@ -285,7 +285,7 @@ private: } // Hoping this never ever gets triggered :sigh: - if constexpr (keyCount == 1) { + if (keyCount == 1) { Systems::Logging::Log("QueryWithAll should not be used for single key " "entry! Please use Query for this instead.", "Dualkey Map", Systems::Logging::LogLevel::Error); @@ -293,7 +293,7 @@ private: // While we don't necessary need the hashes, // it just helps us tremendously benefit from short circuit checks - std::array keyHashes; + Corrade::Containers::Array keyHashes{keyCount}; for (uint64_t index = 0; index < keyCount; index++) { keyHashes[index] = std::hash{}(keys[index]); } diff --git a/headers/Containers/Hashmap.hpp b/headers/Containers/Hashmap.hpp index e47e1f0..3a4ea96 100644 --- a/headers/Containers/Hashmap.hpp +++ b/headers/Containers/Hashmap.hpp @@ -34,8 +34,7 @@ public: if (!storage[keyHashPosition].empty()) { // Throws Systems::Logging::Log("Trying to insert the same key twice! Throwing...", - "Hashmap", Systems::Logging::LogLevel::Error, - Has(key)); + "Hashmap", Systems::Logging::Error, Has(key)); } else { storage[keyHashPosition].reserve(Options.reservedBucketSpace); } @@ -51,7 +50,7 @@ public: // Throws Systems::Logging::Log("Trying to remove a non-existant key! Throwing...", - "Hashmap", Systems::Logging::LogLevel::Error, + "Hashmap", Systems::Logging::Error, storage[keyHashPosition].empty()); std::erase_if(storage[keyHashPosition], [keyHash, &key](const hashStorage &hash) { @@ -90,8 +89,7 @@ public: Systems::Logging::Log( "Trying to access a non-existant bucket for a key! Throwing...", - "Hashmap", Systems::Logging::LogLevel::Error, - storage[keyHashPosition].empty()); + "Hashmap", Systems::Logging::Error, storage[keyHashPosition].empty()); for (hashStorage &hash : storage[keyHashPosition]) { if (hash.hash == keyHash && hash.key == key) { @@ -100,7 +98,7 @@ public: } Systems::Logging::Log("Trying to access a non-existant key! Throwing...", - "Hashmap", Systems::Logging::LogLevel::Error); + "Hashmap", Systems::Logging::Error); throw; } diff --git a/headers/Systems/Logging.hpp b/headers/Systems/Logging.hpp index 24ad37c..23d114e 100644 --- a/headers/Systems/Logging.hpp +++ b/headers/Systems/Logging.hpp @@ -36,8 +36,8 @@ public: private: static std::fstream File; - static const char *LogLevelToColour[LogLevel::Trace + 1]; - static const char *LogLevelToString[LogLevel::Trace + 1]; + static const char *LogLevelToColour[Trace + 1]; + static const char *LogLevelToString[Trace + 1]; }; } // namespace Tourmaline::Systems #endif diff --git a/source/Systems/Logging.cpp b/source/Systems/Logging.cpp index 4215c20..c7f7296 100644 --- a/source/Systems/Logging.cpp +++ b/source/Systems/Logging.cpp @@ -31,9 +31,9 @@ using namespace Corrade::Utility; // This is what happens when it takes you 50 years to implement // reflections to a language -const char *Logging::LogLevelToColour[Logging::LogLevel::Trace + 1]{ +const char *Logging::LogLevelToColour[Logging::Trace + 1]{ "[0;31m", "[0;91m", "[0;33m", "[0;37m", "[0;92m", "[0;36m"}; -const char *Logging::LogLevelToString[Logging::LogLevel::Trace + 1]{ +const char *Logging::LogLevelToString[Logging::Trace + 1]{ "Critical", "Error", "Warning", "Info", "Debug", "Trace"}; std::fstream Logging::File;