Compare commits

..

13 Commits

16 changed files with 257 additions and 123 deletions

View File

@@ -6,33 +6,98 @@
# obtain one at http://mozilla.org/MPL/2.0/.
cmake_minimum_required(VERSION 3.10)
cmake_policy(SET CMP0135 NEW)
project(Tourmaline VERSION 1)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address")
endif()
include(GNUInstallDirs)
include(FetchContent)
# Original - https://github.com/novelrt/NovelRT/blob/c877c1e870d62df98935489e9682d93b009fb2fd/ThirdParty/CMakeLists.txt#L6
# Modified version by williamjcm
macro(external_dependency name)
FetchContent_Declare(${name}
${ARGN}
EXCLUDE_FROM_ALL
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/${name}"
TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/${name}/tmp"
STAMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/${name}/stamp"
DOWNLOAD_DIR "${CMAKE_CURRENT_BINARY_DIR}/${name}/dl"
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/${name}/src"
SUBBUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/${name}/build"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/${name}/bin"
INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/${name}/inst"
LOG_DIR "${CMAKE_CURRENT_BINARY_DIR}/${name}/log"
)
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}/cmake/${name}")
endmacro()
# Third Party Libraries
external_dependency(Corrade
URL https://github.com/mosra/corrade/archive/2b7251d8bd8833a12f0d9b8deffca7a290340d3c.zip
URL_HASH SHA256=77ed07d373792ce05a64b87c84e7d4687965d6040df4e17b6e9922ca1cbd88c8
)
foreach(dep
Corrade
)
message(STATUS "Fetching ${dep}...")
add_subdirectory(external/${dep})
endforeach()
# Building
add_library(${PROJECT_NAME} SHARED
"source/Systems/ECS/Components.cpp"
"source/Systems/ECS/World.cpp"
"source/Systems/Logging.cpp"
"source/Systems/Random.cpp"
"source/Types/UUID.cpp")
"source/Systems/ECS/Components.cpp"
"source/Systems/ECS/World.cpp"
"source/Systems/Logging.cpp"
"source/Systems/Random.cpp"
"source/Types/UUID.cpp"
)
# Actual linking
target_link_libraries(${PROJECT_NAME} PUBLIC
Corrade::Main
Corrade::Containers
Corrade::Utility
Corrade::PluginManager
)
# Module stuff
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION})
# Nothing to link right now
target_link_libraries(${PROJECT_NAME})
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/headers>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/>
$<BUILD_INTERFACE:${corrade_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}External>
)
FetchContent_GetProperties(Corrade SOURCE_DIR corrade_SOURCE_DIR)
FetchContent_GetProperties(Corrade BINARY_DIR corrade_BINARY_DIR)
install(
DIRECTORY
"${corrade_SOURCE_DIR}/src/Corrade/"
"${corrade_BINARY_DIR}/src/Corrade/"
DESTINATION "include/${PROJECT_NAME}External/Corrade"
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.hpp"
)
# A way to live forever
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND printf "Dedicated to my beloved Goma, I love you. - Dora" >> $<TARGET_FILE:${PROJECT_NAME}>
)
install(
@@ -40,7 +105,14 @@ install(
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include
INCLUDES DESTINATION include/${PROJECT_NAME}
)
install(
TARGETS CorradeMain CorradeUtility CorradeContainers CorradePluginManager
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include/${PROJECT_NAME}External
)
install(DIRECTORY headers/ DESTINATION include/${PROJECT_NAME})

View File

@@ -17,6 +17,11 @@ Tormaline Engine is a game engine created for C++23. [Source Code](https://git.t
# Usability Status
Tourmaline is by no means currently usable. The project is incredible volatile with constant changes and improvements. Please wait until a release is made.
However if you cannot just help yourself you can compile a tourmaline demo by running
```
g++ program.cpp -std=c++23 -lTourmaline -lCorradeUtility -lCorradePluginManager -I/usr/local/include/TourmalineExternal -o program
```
# 3rd Party Libraries Credits
- [Corrade/Magnum](https://magnum.graphics/) - graphics middleware by Vladimír "Mosra" Vondruš.
- [miniaudio](https://miniaud.io/) - audio playback and capture library by David "Mackron" Reid.

16
external/Corrade/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,16 @@
include(FetchContent)
# Building options
set(CORRADE_BUILD_STATIC OFF)
# Feature options
set(CORRADE_WITH_MAIN ON)
set(CORRADE_WITH_UTILITY ON)
set(CORRADE_WITH_PLUGINMANAGER ON)
set(CORRADE_WITH_INTERCONNECT OFF)
set(CORRADE_WITH_TESTSUITE OFF)
if(NOT CMAKE_CROSSCOMPILING)
set(CORRADE_WITH_RC ON)
endif()
FetchContent_MakeAvailable(Corrade)

View File

@@ -11,6 +11,8 @@
#define GUARD_TOURMALINE_CONCEPTS_H
#include <concepts>
#include <functional>
#include <tuple>
#include <type_traits>
namespace Tourmaline::Concepts {
template <typename T>
@@ -30,5 +32,29 @@ template <typename Base, typename Type1, typename Type2>
requires Either<Base, Type1, Type2>
using OppositeOf = _opposite_of<Base, Type1, Type2>::type;
// heavily inspired by
// https://github.com/aminroosta/sqlite_modern_cpp/blob/master/hdr/sqlite_modern_cpp/utility/function_traits.h
template <typename> struct FunctionTraits;
template <typename Function>
struct FunctionTraits
: public FunctionTraits<
decltype(&std::remove_reference_t<Function>::operator())> {};
template <typename Return, typename Class, typename... Arguments>
struct FunctionTraits<Return (Class::*)(Arguments...) const>
: FunctionTraits<Return (*)(Arguments...)> {};
template <typename Return, typename Class, typename... Arguments>
struct FunctionTraits<Return (Class::*)(Arguments...)>
: FunctionTraits<Return (*)(Arguments...)> {};
template <typename Return, typename... Arguments>
struct FunctionTraits<Return (*)(Arguments...)> {
using returnType = Return;
using arguments = std::tuple<Arguments...>;
template <std::size_t index>
using argument = std::tuple_element_t<index, arguments>;
static constexpr std::size_t argumentCount = sizeof...(Arguments);
};
} // namespace Tourmaline::Concepts
#endif

View File

@@ -13,8 +13,9 @@
#include "ContainerOptions.hpp"
#include "Hashmap.hpp"
#include "Corrade/Containers/Array.h"
#include <algorithm>
#include <array>
#include <cmath>
#include <cstddef>
#include <cstdint>
@@ -33,14 +34,14 @@ template <Concepts::Hashable AKey, Concepts::Hashable BKey, typename Value,
class DualkeyMap {
public:
// Return Types
template <typename OppositeKey, std::size_t keyCount>
template <typename OppositeKey>
requires Concepts::Either<OppositeKey, AKey, BKey>
struct MultiQueryResult {
// Having to use pointers here over references was not fun
// but it was for greater good
const OppositeKey *oppositeKey;
Corrade::Containers::Array<Value *> valueQueryResults;
std::size_t howManyFound = 1;
std::array<Value *, keyCount> valueQueryResults;
};
using QueryResult =
@@ -205,19 +206,19 @@ public:
}
template <typename Key,
typename OppositeKey = Concepts::OppositeOf<Key, AKey, BKey>,
std::size_t keyCount>
typename OppositeKey = Concepts::OppositeOf<Key, AKey, BKey>>
requires Concepts::Either<Key, AKey, BKey>
[[nodiscard("Discarding a very expensive query!")]]
std::vector<MultiQueryResult<OppositeKey, keyCount>>
QueryWithAll(const Key (&keys)[keyCount]) {
std::vector<MultiQueryResult<OppositeKey, keyCount>> queryResult =
std::vector<MultiQueryResult<OppositeKey>>
QueryWithAll(const Corrade::Containers::Array<Key> &keys) {
std::vector<MultiQueryResult<OppositeKey>> queryResult =
queryWithMany<Key>(keys);
std::erase_if(
queryResult,
[](const MultiQueryResult<OppositeKey, keyCount> &queryRecord) {
return queryRecord.howManyFound != keyCount;
});
std::erase_if(queryResult,
[keyCount = keys.size()](
const MultiQueryResult<OppositeKey> &queryRecord) {
return queryRecord.howManyFound != keyCount;
});
return queryResult;
}
@@ -269,14 +270,14 @@ private:
// Interal querying
template <typename Key,
typename OppositeKey = Concepts::OppositeOf<Key, AKey, BKey>,
std::size_t keyCount>
inline std::vector<MultiQueryResult<OppositeKey, keyCount>>
queryWithMany(const Key (&keys)[keyCount]) {
typename OppositeKey = Concepts::OppositeOf<Key, AKey, BKey>>
inline std::vector<MultiQueryResult<OppositeKey>>
queryWithMany(const Corrade::Containers::Array<Key> &keys) {
constexpr bool searchingInFirstKey = std::is_same_v<Key, AKey>;
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",
@@ -284,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);
@@ -292,7 +293,7 @@ private:
// While we don't necessary need the hashes,
// it just helps us tremendously benefit from short circuit checks
std::array<std::size_t, keyCount> keyHashes;
Corrade::Containers::Array<std::size_t> keyHashes{keyCount};
for (uint64_t index = 0; index < keyCount; index++) {
keyHashes[index] = std::hash<Key>{}(keys[index]);
}
@@ -301,7 +302,7 @@ private:
Key *keyToCompare;
OppositeKey *oppositeKey;
Containers::Hashmap<OppositeKey, MultiQueryResult<OppositeKey, keyCount>,
Containers::Hashmap<OppositeKey, MultiQueryResult<OppositeKey>,
{8.0f, 0.01f, 2.5f, 2048, 8}> // Aggressive hashmap :o
queryResults;
@@ -334,8 +335,9 @@ private:
}
queryResults
.Insert(*oppositeKey,
MultiQueryResult<OppositeKey, keyCount>(oppositeKey))
.Insert(
*oppositeKey,
{oppositeKey, Corrade::Containers::Array<Value *>{keyCount}})
.valueQueryResults[index] = &hash->value;
}
}

View File

@@ -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,8 @@ public:
}
Systems::Logging::Log("Trying to access a non-existant key! Throwing...",
"Hashmap", Systems::Logging::LogLevel::Error);
"Hashmap", Systems::Logging::Error);
throw;
}
[[nodiscard("Discarding an expensive operation!")]]
@@ -160,8 +159,8 @@ private:
// Repopulate and cleanup
for (bucket &entry : oldStorage) {
for (const hashStorage &hash : entry) {
Insert(hash.key, hash.value);
for (hashStorage &hash : entry) {
Insert(std::move(hash.key), std::move(hash.value));
}
entry.clear();

View File

@@ -10,64 +10,60 @@
#ifndef GUARD_TOURMALINE_ECS_H
#define GUARD_TOURMALINE_ECS_H
#include <any>
#include <format>
#include <typeindex>
#include "../Containers/DualkeyMap.hpp"
#include "../Containers/Hashmap.hpp"
#include "../Types.hpp"
#include "ECS/BuiltinComponents.hpp"
#include "Logging.hpp"
namespace Tourmaline::Systems::ECS {
using Entity = Tourmaline::Type::UUID;
class World;
using System = Tourmaline::Type::UUID;
class World {
public:
World() {}
// ====== World controls ======
void Step();
// ======== Entities ========
[[nodiscard]]
Entity CreateEntity();
[[nodiscard("Pointless call of EntityExists")]]
bool EntityExists(const Entity &entity) noexcept;
[[nodiscard("It is not guaranteed that an entity can always be destroyed, "
"please make sure by checking the returned bool")]]
bool DestroyEntity(Entity entity);
// ======== Components ========
template <isAComponent component, typename... Args>
component &AddComponent(const Entity &entity,
Args &&...constructionArguments) {
auto newComponent = entityComponentMap.Insert(
entity, typeid(component), component(constructionArguments...));
template <isAComponent Component, typename... ComponentArgs>
Component &AddComponent(const Entity &entity, ComponentArgs &&...args) {
auto newComponent = entityComponentMap.Insert(entity, typeid(Component),
Component(args...));
return std::any_cast<component &>(std::get<2>(newComponent));
return std::any_cast<Component &>(std::get<2>(newComponent));
}
template <isAComponent component>
[[nodiscard("Discarding an expensive operation's result!")]]
component &GetComponent(const Entity &entity) {
auto result = entityComponentMap.Query(entity, typeid(component));
template <isAComponent Component>
[[nodiscard("Pointless call of GetComponent")]]
Component &GetComponent(const Entity &entity) {
auto result = entityComponentMap.Query(entity, typeid(Component));
if (result.empty()) {
Logging::Log(std::format("Entity {} does not have component {}!",
entity.asString(), typeid(component).name()),
"ECS/GetComponent", Logging::LogLevel::Error);
Logging::LogFormatted("Entity {} does not have component {}!",
"ECS/GetComponent", Logging::LogLevel::Error,
entity.asString(), typeid(Component).name());
}
return std::any_cast<component &>(result.begin()->second);
return std::any_cast<Component &>(result.begin()->second);
}
template <isAComponent component>
[[nodiscard("Discarding an expensive operation's result!")]]
template <isAComponent Component>
[[nodiscard("Pointless call of HasComponent")]]
bool HasComponent(const Entity &entity) {
return entityComponentMap.Query(entity, typeid(component)).size();
return entityComponentMap.Query(entity, typeid(Component)).size();
}
template <isAComponent component>
[[nodiscard("It is not guaranteed that a component can always be removed, "
"please make sure by checking the returned bool")]]
bool RemoveComponent(const Entity &entity) {
return entityComponentMap.Remove(entity, typeid(component));
template <isAComponent Component> bool RemoveComponent(const Entity &entity) {
return entityComponentMap.Remove(entity, typeid(Component));
}
// Copying is not allowed since the ECS world is meant to be
@@ -76,8 +72,11 @@ public:
World &operator=(const World &) = delete;
private:
Tourmaline::Containers::DualkeyMap<Entity, std::type_index, std::any>
using systemFunction =
std::function<void(const Entity &, std::span<std::any *>)>;
Containers::DualkeyMap<Entity, std::type_index, std::any>
entityComponentMap{};
Containers::Hashmap<System, systemFunction> registeredSystems{};
// ======== Life-cycle ========
void preSystems();

View File

@@ -24,7 +24,7 @@ concept isAComponent = std::derived_from<T, ECS::Component>;
namespace Tourmaline::Systems::Components {
// Builtin
struct Base : public ECS::Component {
Base() {}
double x = 0, y = 0, z = 0;
};
} // namespace Tourmaline::Systems::Components
#endif

View File

@@ -8,31 +8,36 @@
*/
#ifndef GUARD_TOURMALINE_LOGGING_H
#define GUARD_TOURMALINE_LOGGING_H
#include <array>
#include "Corrade/Containers/String.h"
#include "Corrade/Containers/StringView.h"
#include "Corrade/Utility/Format.h"
#include <fstream>
#include <string_view>
namespace Tourmaline::Systems {
class Logging {
public:
enum class LogLevel {
Critical = 0,
Error = 1,
Warning = 2,
Info = 3,
Debug = 4,
Trace = 5
};
enum LogLevel { Critical, Error, Warning, Info, Debug, Trace };
static void LogToFile(std::string File = "");
static void Log(std::string_view message,
std::string_view position = "Unknown",
static void LogToFile(Corrade::Containers::String File = "");
static void Log(Corrade::Containers::StringView message,
Corrade::Containers::StringView position = "Unknown",
LogLevel severity = LogLevel::Info, bool assertion = true);
template <class... Args>
static void LogFormatted(const char *format, const char *position,
LogLevel severity, const Args &...args) {
static Corrade::Containers::String output{Corrade::ValueInit, 4096};
std::size_t size = Corrade::Utility::formatInto(output, format, args...);
Log(Corrade::Containers::StringView{output.begin(), size}, position,
severity);
}
private:
static std::fstream File;
static std::array<std::pair<const std::string, const std::string>, 6>
LogLevelToString;
static const char *LogLevelToColour[Trace + 1];
static const char *LogLevelToString[Trace + 1];
};
} // namespace Tourmaline::Systems
#endif

View File

@@ -10,7 +10,7 @@
#ifndef GUARD_TOURMALINE_RANDOM_H
#define GUARD_TOURMALINE_RANDOM_H
#include "../Types.hpp"
#include <TourmalineExternal/random/xoshiro.h>
#include "TourmalineExternal/random/xoshiro.h"
#include <type_traits>

View File

@@ -10,7 +10,9 @@
#ifndef GUARD_TOURMALINE_TYPES_H
#define GUARD_TOURMALINE_TYPES_H
#include "Corrade/Containers/String.h"
#include "TourmalineExternal/random/xoshiro.h"
#include <cstdint>
#include <functional>
#include <string>
@@ -19,7 +21,7 @@ namespace Tourmaline::Type {
class UUID {
public:
[[nodiscard]]
std::string asString() const;
Corrade::Containers::String asString() const;
bool operator==(const UUID &rhs) const;
UUID(uint64_t firstHalf, uint64_t secondHalf);

View File

@@ -7,7 +7,7 @@
* obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "../../../headers/Systems/ECS.hpp"
#include "../../../headers/Systems/ECS/BuiltinComponents.hpp"
#include "Systems/ECS.hpp"
#include "Systems/ECS/BuiltinComponents.hpp"
// Empty until future use

View File

@@ -7,9 +7,9 @@
* obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "../../../headers/Systems/ECS.hpp"
#include "../../../headers/Systems/ECS/BuiltinComponents.hpp"
#include "../../../headers/Systems/Random.hpp"
#include "Systems/ECS.hpp"
#include "Systems/ECS/BuiltinComponents.hpp"
#include "Systems/Random.hpp"
using namespace Tourmaline::Systems;
using namespace ECS;

View File

@@ -7,7 +7,12 @@
* obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "../../headers/Systems/Logging.hpp"
#include "Systems/Logging.hpp"
#include "Corrade/Containers/String.h"
#include "Corrade/Containers/StringView.h"
#include "Corrade/Tags.h"
#include "Corrade/Utility/Format.h"
#include <cerrno>
#include <chrono>
@@ -16,63 +21,63 @@
#include <exception>
#include <format>
#include <fstream>
#include <iterator>
#include <print>
#include <stdexcept>
#include <string>
#include <string_view>
#include <utility>
using namespace Tourmaline::Systems;
using namespace Corrade::Containers;
using namespace Corrade::Utility;
// This is what happens when it takes you 50 years to implement
// reflections to a language
std::array<std::pair<const std::string, const std::string>, 6>
Logging::LogLevelToString{std::pair{"Critical", "[0;31m"},
{"Error", "[0;91m"},
{"Warning", "[0;33m"},
{"Info", "[0;37m"},
{"Debug", "[0;92m"},
{"Trace", "[0;36m"}};
const char *Logging::LogLevelToColour[Logging::Trace + 1]{
"[0;31m", "[0;91m", "[0;33m", "[0;37m", "[0;92m", "[0;36m"};
const char *Logging::LogLevelToString[Logging::Trace + 1]{
"Critical", "Error", "Warning", "Info", "Debug", "Trace"};
std::fstream Logging::File;
void Logging::LogToFile(std::string File) {
void Logging::LogToFile(String File) {
if (File == "") {
const auto now = std::chrono::system_clock::now();
File = std::format("Tourmaline-{:%Y-%j}.txt", now);
std::chrono::year_month_day ymd{std::chrono::floor<std::chrono::days>(now)};
File = String{Corrade::ValueInit, 128};
formatInto(File, "Tourmaline-{}-{}-{}.txt", static_cast<int>(ymd.year()),
static_cast<unsigned>(ymd.month()),
static_cast<unsigned>(ymd.day()));
}
Logging::File.open(File, std::fstream::out);
Logging::File.open(File.data(), std::fstream::out);
if (Logging::File.fail()) {
throw std::runtime_error("FAILED! Could not open or create the file: " +
File + "!\n" + strerror(errno));
String error =
format("FAILED! Could not open or create the file: {}! Error: {}", File,
strerror(errno));
throw std::runtime_error(error.data());
}
}
void Logging::Log(std::string_view message, std::string_view position,
void Logging::Log(StringView message, StringView position,
Logging::LogLevel severity, bool assertion) {
if (assertion) [[likely]] {
static std::string
output; // This is done to stop allocations per std::format
const auto &loglevelData =
Logging::LogLevelToString[static_cast<size_t>(severity)];
std::format_to(std::back_inserter(output), "[{}@{}] {}\n",
loglevelData.first, position, message);
if (assertion) {
static String output{Corrade::ValueInit,
4096}; // This is done to stop allocations
std::size_t formattedSize = formatInto(
output, "[{}@{}] {}\n", LogLevelToString[severity], position, message);
std::print("\033{} {}\033[0m", loglevelData.second, output);
std::print(
"\033{} {}\033[0m", LogLevelToColour[severity],
std::string_view{output.begin(), output.begin() + formattedSize});
if (Logging::File.is_open()) {
Logging::File.write(output.c_str(), output.size());
Logging::File.write(output.data(), formattedSize);
Logging::File.flush(); // Terrible but necessary sadly
}
if (severity == Logging::LogLevel::Error) {
throw std::runtime_error(output);
throw std::runtime_error(output.data());
}
if (severity == Logging::LogLevel::Critical) {
std::terminate();
}
output.clear();
}
}

View File

@@ -6,7 +6,8 @@
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "../../headers/Systems/Random.hpp"
#include "Systems/Random.hpp"
#include <bit>
#include <cstdint>

View File

@@ -7,17 +7,19 @@
* obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "../../headers/Types.hpp"
#include "Corrade/Utility/Format.h"
#include "Types.hpp"
#include <charconv>
#include <cstdint>
#include <cstring>
#include <format>
#include <string>
using namespace Tourmaline::Type;
std::string UUID::asString() const {
return std::format("{:016X}{:016X}", firstHalf, secondHalf);
using namespace Corrade::Containers;
using namespace Corrade::Utility;
String UUID::asString() const {
return format("{:.16X}{:.16X}", firstHalf, secondHalf);
}
bool UUID::operator==(const UUID &rhs) const {