Reduce back and forth between std and eastl
Bigfoot / Sonarqube (push) Skipped
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 47s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 28s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 52s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 34s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 1m16s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 42s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 26s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 45s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 28s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 1m12s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 59s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m17s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 59s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 1m0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m24s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 1m6s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 35s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 25s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 53s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 42s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 46s
sonarqube ERROR
Bigfoot / Sonarqube (pull_request) Failing after 4m45s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 52s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 59s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 49s
Bigfoot / Clang Format Checks (push) Successful in 9s
Bigfoot / Sonarqube (push) Skipped
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 47s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 28s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 52s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 34s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 1m16s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 42s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 26s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 45s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 28s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 1m12s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 59s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m17s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 59s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 1m0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m24s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 1m6s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 35s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 25s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 53s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 42s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 46s
sonarqube ERROR
Bigfoot / Sonarqube (pull_request) Failing after 4m45s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 52s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 59s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 49s
Bigfoot / Clang Format Checks (push) Successful in 9s
This commit is contained in:
@@ -95,12 +95,12 @@ class BigFileFixture: public benchmark::Fixture
|
|||||||
for (std::uint32_t i = 0; i < ASSET_COUNT; ++i)
|
for (std::uint32_t i = 0; i < ASSET_COUNT; ++i)
|
||||||
{
|
{
|
||||||
BenchmarkAsset asset;
|
BenchmarkAsset asset;
|
||||||
asset.SetName(asset.GetHeader().uuid.ToString().c_str());
|
asset.SetName(asset.GetHeader().uuid.ToString());
|
||||||
asset.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
asset.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
||||||
for (std::uint32_t j = 0; j < REFS_PER_ASSET; ++j)
|
for (std::uint32_t j = 0; j < REFS_PER_ASSET; ++j)
|
||||||
{
|
{
|
||||||
BenchmarkAssetReferred assetReferred;
|
BenchmarkAssetReferred assetReferred;
|
||||||
assetReferred.SetName(assetReferred.GetHeader().uuid.ToString().c_str());
|
assetReferred.SetName(assetReferred.GetHeader().uuid.ToString());
|
||||||
|
|
||||||
asset.GetAsset().refs.emplace_back(assetReferred.GetHeader().uuid);
|
asset.GetAsset().refs.emplace_back(assetReferred.GetHeader().uuid);
|
||||||
}
|
}
|
||||||
@@ -237,7 +237,7 @@ BENCHMARK_DEFINE_F(BigFileFixture, SaveAssetFlatbuffer)(benchmark::State& state)
|
|||||||
{
|
{
|
||||||
state.PauseTiming();
|
state.PauseTiming();
|
||||||
BenchmarkAsset asset;
|
BenchmarkAsset asset;
|
||||||
asset.SetName(asset.GetHeader().uuid.ToString().c_str());
|
asset.SetName(asset.GetHeader().uuid.ToString());
|
||||||
asset.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
asset.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
||||||
for (std::uint32_t j = 0; j < REFS_PER_ASSET; ++j)
|
for (std::uint32_t j = 0; j < REFS_PER_ASSET; ++j)
|
||||||
{
|
{
|
||||||
@@ -278,7 +278,7 @@ BENCHMARK_DEFINE_F(BigFileFixture, SaveAssetFlatbuffers)(benchmark::State& state
|
|||||||
for (std::size_t i = 0; i < batchSize; ++i)
|
for (std::size_t i = 0; i < batchSize; ++i)
|
||||||
{
|
{
|
||||||
BenchmarkAsset asset;
|
BenchmarkAsset asset;
|
||||||
asset.SetName(asset.GetHeader().uuid.ToString().c_str());
|
asset.SetName(asset.GetHeader().uuid.ToString());
|
||||||
asset.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
asset.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
||||||
for (std::uint32_t j = 0; j < REFS_PER_ASSET; ++j)
|
for (std::uint32_t j = 0; j < REFS_PER_ASSET; ++j)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -97,12 +97,12 @@ class SasquatchFixture: public benchmark::Fixture
|
|||||||
for (std::uint32_t i = 0; i < ASSET_COUNT; ++i)
|
for (std::uint32_t i = 0; i < ASSET_COUNT; ++i)
|
||||||
{
|
{
|
||||||
BenchmarkAsset asset;
|
BenchmarkAsset asset;
|
||||||
asset.SetName(asset.GetHeader().uuid.ToString().c_str());
|
asset.SetName(asset.GetHeader().uuid.ToString());
|
||||||
asset.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
asset.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
||||||
for (std::uint32_t j = 0; j < REFS_PER_ASSET; ++j)
|
for (std::uint32_t j = 0; j < REFS_PER_ASSET; ++j)
|
||||||
{
|
{
|
||||||
BenchmarkAssetReferred assetReferred;
|
BenchmarkAssetReferred assetReferred;
|
||||||
assetReferred.SetName(assetReferred.GetHeader().uuid.ToString().c_str());
|
assetReferred.SetName(assetReferred.GetHeader().uuid.ToString());
|
||||||
|
|
||||||
asset.GetAsset().refs.emplace_back(assetReferred.GetHeader().uuid);
|
asset.GetAsset().refs.emplace_back(assetReferred.GetHeader().uuid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,14 +176,14 @@ class SerializationManagerFixture: public benchmark::Fixture
|
|||||||
for (std::uint32_t i = 0; i < ROOT_ASSET_COUNT; ++i)
|
for (std::uint32_t i = 0; i < ROOT_ASSET_COUNT; ++i)
|
||||||
{
|
{
|
||||||
BenchmarkAsset root;
|
BenchmarkAsset root;
|
||||||
root.SetName(root.GetHeader().uuid.ToString().c_str());
|
root.SetName(root.GetHeader().uuid.ToString());
|
||||||
root.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
root.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
||||||
|
|
||||||
std::size_t totalBytes = 0;
|
std::size_t totalBytes = 0;
|
||||||
for (std::uint32_t j = 0; j < REFS_PER_ROOT; ++j)
|
for (std::uint32_t j = 0; j < REFS_PER_ROOT; ++j)
|
||||||
{
|
{
|
||||||
BenchmarkAssetReferred leaf;
|
BenchmarkAssetReferred leaf;
|
||||||
leaf.SetName(leaf.GetHeader().uuid.ToString().c_str());
|
leaf.SetName(leaf.GetHeader().uuid.ToString());
|
||||||
|
|
||||||
root.GetAsset().refs.emplace_back(leaf.GetHeader().uuid);
|
root.GetAsset().refs.emplace_back(leaf.GetHeader().uuid);
|
||||||
|
|
||||||
@@ -318,7 +318,7 @@ BENCHMARK_DEFINE_F(SerializationManagerFixture, SaveAsset)(benchmark::State& sta
|
|||||||
{
|
{
|
||||||
state.PauseTiming();
|
state.PauseTiming();
|
||||||
auto* asset = CreateAsset<BenchmarkAsset>();
|
auto* asset = CreateAsset<BenchmarkAsset>();
|
||||||
asset->SetName(asset->GetHeader().uuid.ToString().c_str());
|
asset->SetName(asset->GetHeader().uuid.ToString());
|
||||||
asset->GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
asset->GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
||||||
for (std::uint32_t j = 0; j < REFS_PER_ROOT; ++j)
|
for (std::uint32_t j = 0; j < REFS_PER_ROOT; ++j)
|
||||||
{
|
{
|
||||||
@@ -360,7 +360,7 @@ BENCHMARK_DEFINE_F(SerializationManagerFixture, SaveAssets)(benchmark::State& st
|
|||||||
for (std::size_t i = 0; i < batchSize; ++i)
|
for (std::size_t i = 0; i < batchSize; ++i)
|
||||||
{
|
{
|
||||||
auto* asset = CreateAsset<BenchmarkAsset>();
|
auto* asset = CreateAsset<BenchmarkAsset>();
|
||||||
asset->SetName(asset->GetHeader().uuid.ToString().c_str());
|
asset->SetName(asset->GetHeader().uuid.ToString());
|
||||||
asset->GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
asset->GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
||||||
for (std::uint32_t j = 0; j < REFS_PER_ROOT; ++j)
|
for (std::uint32_t j = 0; j < REFS_PER_ROOT; ++j)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class SasquatchBakerFixture: public benchmark::Fixture
|
|||||||
for (std::uint32_t i = 0; i < ASSET_COUNT; ++i)
|
for (std::uint32_t i = 0; i < ASSET_COUNT; ++i)
|
||||||
{
|
{
|
||||||
BenchmarkAsset asset;
|
BenchmarkAsset asset;
|
||||||
asset.SetName(asset.GetHeader().uuid.ToString().c_str());
|
asset.SetName(asset.GetHeader().uuid.ToString());
|
||||||
asset.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
asset.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
||||||
|
|
||||||
const eastl::vector<std::byte> flatbuffer = asset.Pack();
|
const eastl::vector<std::byte> flatbuffer = asset.Pack();
|
||||||
|
|||||||
@@ -8,8 +8,9 @@
|
|||||||
|
|
||||||
#include <Engine/EngineAssertHandler.hpp>
|
#include <Engine/EngineAssertHandler.hpp>
|
||||||
|
|
||||||
|
#include <Utils/Format.hpp>
|
||||||
|
|
||||||
#include <EASTL/algorithm.h>
|
#include <EASTL/algorithm.h>
|
||||||
#include <fmt/format.h>
|
|
||||||
|
|
||||||
namespace Bigfoot
|
namespace Bigfoot
|
||||||
{
|
{
|
||||||
@@ -149,9 +150,9 @@ eastl::vector<eastl::vector<std::byte>> BigFile::GetAssetFlatbuffers(const eastl
|
|||||||
placeholders += "?";
|
placeholders += "?";
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string sql = fmt::format("SELECT UUID, Asset FROM Asset WHERE UUID IN ({});", placeholders);
|
const eastl::string sql = Format("SELECT UUID, Asset FROM Asset WHERE UUID IN ({});", placeholders);
|
||||||
|
|
||||||
BigFile::Request assetRequest {*this, sql.c_str()};
|
BigFile::Request assetRequest {*this, sql};
|
||||||
for (std::size_t i = 0; i < chunkSize; ++i)
|
for (std::size_t i = 0; i < chunkSize; ++i)
|
||||||
{
|
{
|
||||||
assetRequest.Bind(static_cast<std::uint32_t>(i + 1), distinctUUIDs[chunkStart + i].ToBytes());
|
assetRequest.Bind(static_cast<std::uint32_t>(i + 1), distinctUUIDs[chunkStart + i].ToBytes());
|
||||||
@@ -159,9 +160,9 @@ eastl::vector<eastl::vector<std::byte>> BigFile::GetAssetFlatbuffers(const eastl
|
|||||||
|
|
||||||
while (assetRequest.Step())
|
while (assetRequest.Step())
|
||||||
{
|
{
|
||||||
const eastl::span<const std::byte, UUID::UUID_BYTE_SIZE> rawUUID =
|
const std::span<const std::byte, UUID::UUID_BYTE_SIZE> rawUUID {
|
||||||
static_cast<eastl::span<const std::byte>>(assetRequest.Get(0));
|
static_cast<std::span<const std::byte>>(assetRequest.Get(0))};
|
||||||
const UUID uuid {std::span<const std::byte, UUID::UUID_BYTE_SIZE> {rawUUID.begin(), rawUUID.end()}};
|
const UUID uuid {rawUUID};
|
||||||
|
|
||||||
const auto it = uuidToIndices.find(uuid);
|
const auto it = uuidToIndices.find(uuid);
|
||||||
ASSERT(EngineAssertHandler,
|
ASSERT(EngineAssertHandler,
|
||||||
@@ -191,9 +192,9 @@ eastl::vector<UUID> BigFile::GetAssetHardReferences(const UUID& p_uuid) const
|
|||||||
eastl::vector<UUID> hardReferences;
|
eastl::vector<UUID> hardReferences;
|
||||||
while (hardReferencesRequest.Step())
|
while (hardReferencesRequest.Step())
|
||||||
{
|
{
|
||||||
const eastl::span<const std::byte, UUID::UUID_BYTE_SIZE> rawUUID = static_cast<eastl::span<const std::byte>>(
|
const std::span<const std::byte, UUID::UUID_BYTE_SIZE> rawUUID {
|
||||||
hardReferencesRequest.Get(0));
|
static_cast<std::span<const std::byte>>(hardReferencesRequest.Get(0))};
|
||||||
hardReferences.emplace_back(std::span<const std::byte, UUID::UUID_BYTE_SIZE>(rawUUID.begin(), rawUUID.end()));
|
hardReferences.emplace_back(rawUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hardReferences;
|
return hardReferences;
|
||||||
@@ -244,10 +245,10 @@ eastl::vector<eastl::vector<UUID>> BigFile::GetAssetsHardReferences(eastl::span<
|
|||||||
placeholders += "?";
|
placeholders += "?";
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string sql = fmt::format("SELECT UUID, HardReference FROM AssetHardReference WHERE UUID IN ({});",
|
const eastl::string sql = Format("SELECT UUID, HardReference FROM AssetHardReference WHERE UUID IN ({});",
|
||||||
placeholders);
|
placeholders);
|
||||||
|
|
||||||
BigFile::Request hardReferencesRequest {*this, sql.c_str()};
|
BigFile::Request hardReferencesRequest {*this, sql};
|
||||||
for (std::size_t i = 0; i < chunkSize; ++i)
|
for (std::size_t i = 0; i < chunkSize; ++i)
|
||||||
{
|
{
|
||||||
hardReferencesRequest.Bind(static_cast<std::uint32_t>(i + 1), distinctUUIDs[chunkStart + i].ToBytes());
|
hardReferencesRequest.Bind(static_cast<std::uint32_t>(i + 1), distinctUUIDs[chunkStart + i].ToBytes());
|
||||||
@@ -255,10 +256,9 @@ eastl::vector<eastl::vector<UUID>> BigFile::GetAssetsHardReferences(eastl::span<
|
|||||||
|
|
||||||
while (hardReferencesRequest.Step())
|
while (hardReferencesRequest.Step())
|
||||||
{
|
{
|
||||||
const eastl::span<const std::byte, UUID::UUID_BYTE_SIZE> rawOwnerUUID =
|
const std::span<const std::byte, UUID::UUID_BYTE_SIZE> rawOwnerUUID {
|
||||||
static_cast<eastl::span<const std::byte>>(hardReferencesRequest.Get(0));
|
static_cast<std::span<const std::byte>>(hardReferencesRequest.Get(0))};
|
||||||
const UUID ownerUUID {
|
const UUID ownerUUID {rawOwnerUUID};
|
||||||
std::span<const std::byte, UUID::UUID_BYTE_SIZE> {rawOwnerUUID.begin(), rawOwnerUUID.end()}};
|
|
||||||
|
|
||||||
const auto it = uuidToIndices.find(ownerUUID);
|
const auto it = uuidToIndices.find(ownerUUID);
|
||||||
ASSERT(EngineAssertHandler,
|
ASSERT(EngineAssertHandler,
|
||||||
@@ -266,14 +266,12 @@ eastl::vector<eastl::vector<UUID>> BigFile::GetAssetsHardReferences(eastl::span<
|
|||||||
"Returned UUID {} not found in requested UUIDs",
|
"Returned UUID {} not found in requested UUIDs",
|
||||||
ownerUUID);
|
ownerUUID);
|
||||||
|
|
||||||
const eastl::span<const std::byte, UUID::UUID_BYTE_SIZE> rawHardReference =
|
const std::span<const std::byte, UUID::UUID_BYTE_SIZE> rawHardReference {
|
||||||
static_cast<eastl::span<const std::byte>>(hardReferencesRequest.Get(1));
|
static_cast<std::span<const std::byte>>(hardReferencesRequest.Get(1))};
|
||||||
|
|
||||||
for (const std::size_t index: it->second)
|
for (const std::size_t index: it->second)
|
||||||
{
|
{
|
||||||
hardReferences[index].emplace_back(
|
hardReferences[index].emplace_back(rawHardReference);
|
||||||
std::span<const std::byte, UUID::UUID_BYTE_SIZE> {rawHardReference.begin(),
|
|
||||||
rawHardReference.end()});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -342,11 +340,11 @@ eastl::vector<eastl::optional<BigFile::AssetTime>> BigFile::GetAssetsTime(const
|
|||||||
placeholders += "?";
|
placeholders += "?";
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string sql = fmt::format(
|
const eastl::string sql = Format(
|
||||||
"SELECT UUID, CreateTime, ModificationTime FROM AssetMetadata WHERE UUID IN ({});",
|
"SELECT UUID, CreateTime, ModificationTime FROM AssetMetadata WHERE UUID IN ({});",
|
||||||
placeholders);
|
placeholders);
|
||||||
|
|
||||||
BigFile::Request timeRequest {*this, sql.c_str()};
|
BigFile::Request timeRequest {*this, sql};
|
||||||
for (std::size_t i = 0; i < chunkSize; ++i)
|
for (std::size_t i = 0; i < chunkSize; ++i)
|
||||||
{
|
{
|
||||||
timeRequest.Bind(static_cast<std::uint32_t>(i + 1), distinctUUIDs[chunkStart + i].ToBytes());
|
timeRequest.Bind(static_cast<std::uint32_t>(i + 1), distinctUUIDs[chunkStart + i].ToBytes());
|
||||||
@@ -354,9 +352,9 @@ eastl::vector<eastl::optional<BigFile::AssetTime>> BigFile::GetAssetsTime(const
|
|||||||
|
|
||||||
while (timeRequest.Step())
|
while (timeRequest.Step())
|
||||||
{
|
{
|
||||||
const eastl::span<const std::byte, UUID::UUID_BYTE_SIZE> rawUUID =
|
const std::span<const std::byte, UUID::UUID_BYTE_SIZE> rawUUID {
|
||||||
static_cast<eastl::span<const std::byte>>(timeRequest.Get(0));
|
static_cast<std::span<const std::byte>>(timeRequest.Get(0))};
|
||||||
const UUID uuid {std::span<const std::byte, UUID::UUID_BYTE_SIZE> {rawUUID.begin(), rawUUID.end()}};
|
const UUID uuid {rawUUID};
|
||||||
|
|
||||||
const auto it = uuidToIndices.find(uuid);
|
const auto it = uuidToIndices.find(uuid);
|
||||||
ASSERT(EngineAssertHandler,
|
ASSERT(EngineAssertHandler,
|
||||||
@@ -422,12 +420,11 @@ void BigFile::SaveAssetFlatbuffer(const UUID& p_uuid,
|
|||||||
hardReferencePlaceholders += "(?, ?)";
|
hardReferencePlaceholders += "(?, ?)";
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string hardReferenceSQL = fmt::format(
|
const eastl::string hardReferenceSQL = Format("INSERT INTO AssetHardReference (UUID, HardReference) VALUES {} "
|
||||||
"INSERT INTO AssetHardReference (UUID, HardReference) VALUES {} "
|
"ON CONFLICT(UUID, HardReference) DO NOTHING;",
|
||||||
"ON CONFLICT(UUID, HardReference) DO NOTHING;",
|
hardReferencePlaceholders);
|
||||||
hardReferencePlaceholders);
|
|
||||||
|
|
||||||
BigFile::Request hardReferenceRequest {*this, hardReferenceSQL.c_str()};
|
BigFile::Request hardReferenceRequest {*this, hardReferenceSQL};
|
||||||
std::uint32_t bindIndex = 1;
|
std::uint32_t bindIndex = 1;
|
||||||
for (std::size_t i = 0; i < chunkSize; ++i)
|
for (std::size_t i = 0; i < chunkSize; ++i)
|
||||||
{
|
{
|
||||||
@@ -477,11 +474,11 @@ void BigFile::SaveAssetFlatbuffers(const eastl::span<const UUID> p_uuids,
|
|||||||
metadataPlaceholders += "(?)";
|
metadataPlaceholders += "(?)";
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string metadataSQL = fmt::format(
|
const eastl::string metadataSQL = Format(
|
||||||
"INSERT INTO AssetMetadata (UUID) VALUES {} ON CONFLICT(UUID) DO NOTHING;",
|
"INSERT INTO AssetMetadata (UUID) VALUES {} ON CONFLICT(UUID) DO NOTHING;",
|
||||||
metadataPlaceholders);
|
metadataPlaceholders);
|
||||||
|
|
||||||
BigFile::Request metadataRequest {*this, metadataSQL.c_str()};
|
BigFile::Request metadataRequest {*this, metadataSQL};
|
||||||
std::uint32_t metadataBindIndex = 1;
|
std::uint32_t metadataBindIndex = 1;
|
||||||
for (std::size_t i = 0; i < chunkSize; ++i)
|
for (std::size_t i = 0; i < chunkSize; ++i)
|
||||||
{
|
{
|
||||||
@@ -500,11 +497,11 @@ void BigFile::SaveAssetFlatbuffers(const eastl::span<const UUID> p_uuids,
|
|||||||
assetPlaceholders += "(?, ?)";
|
assetPlaceholders += "(?, ?)";
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string assetSQL = fmt::format(
|
const eastl::string assetSQL = Format(
|
||||||
"INSERT INTO Asset (UUID, Asset) VALUES {} ON CONFLICT(UUID) DO UPDATE SET Asset = excluded.Asset;",
|
"INSERT INTO Asset (UUID, Asset) VALUES {} ON CONFLICT(UUID) DO UPDATE SET Asset = excluded.Asset;",
|
||||||
assetPlaceholders);
|
assetPlaceholders);
|
||||||
|
|
||||||
BigFile::Request assetRequest {*this, assetSQL.c_str()};
|
BigFile::Request assetRequest {*this, assetSQL};
|
||||||
std::uint32_t assetBindIndex = 1;
|
std::uint32_t assetBindIndex = 1;
|
||||||
for (std::size_t i = 0; i < chunkSize; ++i)
|
for (std::size_t i = 0; i < chunkSize; ++i)
|
||||||
{
|
{
|
||||||
@@ -525,10 +522,10 @@ void BigFile::SaveAssetFlatbuffers(const eastl::span<const UUID> p_uuids,
|
|||||||
deleteInPlaceholders += "?";
|
deleteInPlaceholders += "?";
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string deleteHardReferencesSQL = fmt::format("DELETE FROM AssetHardReference WHERE UUID IN ({});",
|
const eastl::string deleteHardReferencesSQL = Format("DELETE FROM AssetHardReference WHERE UUID IN ({});",
|
||||||
deleteInPlaceholders);
|
deleteInPlaceholders);
|
||||||
|
|
||||||
BigFile::Request deleteHardReferencesRequest {*this, deleteHardReferencesSQL.c_str()};
|
BigFile::Request deleteHardReferencesRequest {*this, deleteHardReferencesSQL};
|
||||||
for (std::size_t i = 0; i < chunkSize; ++i)
|
for (std::size_t i = 0; i < chunkSize; ++i)
|
||||||
{
|
{
|
||||||
deleteHardReferencesRequest.Bind(static_cast<std::uint32_t>(i + 1), p_uuids[chunkStart + i].ToBytes());
|
deleteHardReferencesRequest.Bind(static_cast<std::uint32_t>(i + 1), p_uuids[chunkStart + i].ToBytes());
|
||||||
@@ -566,12 +563,12 @@ void BigFile::SaveAssetFlatbuffers(const eastl::span<const UUID> p_uuids,
|
|||||||
hardReferencePlaceholders += "(?, ?)";
|
hardReferencePlaceholders += "(?, ?)";
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string hardReferenceSQL = fmt::format(
|
const eastl::string hardReferenceSQL = Format(
|
||||||
"INSERT INTO AssetHardReference (UUID, HardReference) VALUES {} "
|
"INSERT INTO AssetHardReference (UUID, HardReference) VALUES {} "
|
||||||
"ON CONFLICT(UUID, HardReference) DO NOTHING;",
|
"ON CONFLICT(UUID, HardReference) DO NOTHING;",
|
||||||
hardReferencePlaceholders);
|
hardReferencePlaceholders);
|
||||||
|
|
||||||
BigFile::Request hardReferenceRequest {*this, hardReferenceSQL.c_str()};
|
BigFile::Request hardReferenceRequest {*this, hardReferenceSQL};
|
||||||
std::uint32_t bindIndex = 1;
|
std::uint32_t bindIndex = 1;
|
||||||
for (std::size_t i = 0; i < hardRefChunkSize; ++i)
|
for (std::size_t i = 0; i < hardRefChunkSize; ++i)
|
||||||
{
|
{
|
||||||
@@ -819,6 +816,14 @@ BigFile::Request::Column::operator eastl::span<const std::byte>() const
|
|||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
BigFile::Request::Column::operator std::span<const std::byte>() const
|
||||||
|
{
|
||||||
|
return std::span<const std::byte> {static_cast<const std::byte*>(sqlite3_column_blob(m_statement, m_index)),
|
||||||
|
static_cast<std::size_t>(sqlite3_column_bytes(m_statement, m_index))};
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
BigFile::Request::Column BigFile::Request::Get(const std::uint32_t p_index) const
|
BigFile::Request::Column BigFile::Request::Get(const std::uint32_t p_index) const
|
||||||
{
|
{
|
||||||
ASSERT(EngineAssertHandler,
|
ASSERT(EngineAssertHandler,
|
||||||
|
|||||||
@@ -15,8 +15,11 @@
|
|||||||
|
|
||||||
#include <EASTL/optional.h>
|
#include <EASTL/optional.h>
|
||||||
#include <EASTL/span.h>
|
#include <EASTL/span.h>
|
||||||
|
#include <EASTL/string_view.h>
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
|
|
||||||
|
#include <span>
|
||||||
|
|
||||||
namespace Bigfoot
|
namespace Bigfoot
|
||||||
{
|
{
|
||||||
#ifdef BIGFOOT_TOOLMODE
|
#ifdef BIGFOOT_TOOLMODE
|
||||||
@@ -325,6 +328,13 @@ class BigFile: public DataAccessor
|
|||||||
*/
|
*/
|
||||||
operator eastl::span<const std::byte>() const;
|
operator eastl::span<const std::byte>() const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get value as a blob
|
||||||
|
*
|
||||||
|
* \return The value
|
||||||
|
*/
|
||||||
|
operator std::span<const std::byte>() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*
|
/*
|
||||||
* The statement
|
* The statement
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#ifndef BIGFOOT_SYSTEM_UUID_UUID_HPP
|
#ifndef BIGFOOT_SYSTEM_UUID_UUID_HPP
|
||||||
#define BIGFOOT_SYSTEM_UUID_UUID_HPP
|
#define BIGFOOT_SYSTEM_UUID_UUID_HPP
|
||||||
|
#include <EASTL/string.h>
|
||||||
#include <ankerl/unordered_dense.h>
|
#include <ankerl/unordered_dense.h>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
#include <uuid.h>
|
#include <uuid.h>
|
||||||
@@ -52,7 +53,7 @@ class UUID
|
|||||||
* \return A string representing the UUID
|
* \return A string representing the UUID
|
||||||
*/
|
*/
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
std::string ToString() const;
|
eastl::string ToString() const;
|
||||||
|
|
||||||
operator bool() const;
|
operator bool() const;
|
||||||
|
|
||||||
@@ -127,7 +128,7 @@ struct fmt::formatter<Bigfoot::UUID>
|
|||||||
|
|
||||||
auto format(const Bigfoot::UUID& p_uuid, format_context& ctx) const
|
auto format(const Bigfoot::UUID& p_uuid, format_context& ctx) const
|
||||||
{
|
{
|
||||||
return fmt::format_to(ctx.out(), "{}", p_uuid.ToString());
|
return fmt::format_to(ctx.out(), "{}", p_uuid.ToString().c_str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -146,7 +147,7 @@ struct fmtquill::formatter<Bigfoot::UUID>
|
|||||||
|
|
||||||
auto format(const Bigfoot::UUID& p_uuid, format_context& ctx) const
|
auto format(const Bigfoot::UUID& p_uuid, format_context& ctx) const
|
||||||
{
|
{
|
||||||
return fmtquill::format_to(ctx.out(), "{}", p_uuid.ToString());
|
return fmtquill::format_to(ctx.out(), "{}", p_uuid.ToString().c_str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -50,9 +50,10 @@ std::span<const std::byte, UUID::UUID_BYTE_SIZE> UUID::ToBytes() const
|
|||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
|
|
||||||
std::string UUID::ToString() const
|
eastl::string UUID::ToString() const
|
||||||
{
|
{
|
||||||
return uuids::to_string(m_uuid);
|
const std::string uuid = uuids::to_string(m_uuid);
|
||||||
|
return eastl::string {uuid.data(), uuid.size()};
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ void Bake(const BigFile& p_bigFile, const File& p_outputFile)
|
|||||||
BigFile::Request request {p_bigFile, "SELECT UUID FROM Asset;"};
|
BigFile::Request request {p_bigFile, "SELECT UUID FROM Asset;"};
|
||||||
while (request.Step())
|
while (request.Step())
|
||||||
{
|
{
|
||||||
const eastl::span<const std::byte> rawUUID = request.Get(0);
|
const std::span<const std::byte> rawUUID = request.Get(0);
|
||||||
|
|
||||||
ASSERT(SasquatchBakerAssertHandler,
|
ASSERT(SasquatchBakerAssertHandler,
|
||||||
rawUUID.size() == UUID::UUID_BYTE_SIZE,
|
rawUUID.size() == UUID::UUID_BYTE_SIZE,
|
||||||
|
|||||||
@@ -11,9 +11,10 @@
|
|||||||
|
|
||||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||||
|
|
||||||
|
#include <Utils/Format.hpp>
|
||||||
|
|
||||||
#include <EASTL/fixed_function.h>
|
#include <EASTL/fixed_function.h>
|
||||||
#include <EASTL/string.h>
|
#include <EASTL/string.h>
|
||||||
#include <fmt/format.h>
|
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <source_location>
|
#include <source_location>
|
||||||
@@ -84,24 +85,21 @@ BIGFOOT_ALWAYS_INLINE void CriticalAssertCheck(const bool p_condition,
|
|||||||
::Bigfoot::AssertCheck<HANDLER>((p_assert), \
|
::Bigfoot::AssertCheck<HANDLER>((p_assert), \
|
||||||
[&] \
|
[&] \
|
||||||
{ \
|
{ \
|
||||||
return eastl::string { \
|
return ::Bigfoot::Format(p_message __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
fmt::format(p_message __VA_OPT__(, ) __VA_ARGS__).c_str()}; \
|
|
||||||
})
|
})
|
||||||
|
|
||||||
#define SOFT_ASSERT(HANDLER, p_assert, p_message, ...) \
|
#define SOFT_ASSERT(HANDLER, p_assert, p_message, ...) \
|
||||||
::Bigfoot::AssertCheck<HANDLER>((p_assert), \
|
::Bigfoot::AssertCheck<HANDLER>((p_assert), \
|
||||||
[&] \
|
[&] \
|
||||||
{ \
|
{ \
|
||||||
return eastl::string { \
|
return ::Bigfoot::Format(p_message __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
fmt::format(p_message __VA_OPT__(, ) __VA_ARGS__).c_str()}; \
|
|
||||||
})
|
})
|
||||||
|
|
||||||
#define CRITICAL_ASSERT(HANDLER, p_assert, p_message, ...) \
|
#define CRITICAL_ASSERT(HANDLER, p_assert, p_message, ...) \
|
||||||
::Bigfoot::CriticalAssertCheck<HANDLER>((p_assert), \
|
::Bigfoot::CriticalAssertCheck<HANDLER>((p_assert), \
|
||||||
[&] \
|
[&] \
|
||||||
{ \
|
{ \
|
||||||
return eastl::string { \
|
return ::Bigfoot::Format(p_message __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
fmt::format(p_message __VA_OPT__(, ) __VA_ARGS__).c_str()}; \
|
|
||||||
})
|
})
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file Format.hpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date September 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#ifndef BIGFOOT_UTILS_FORMAT_HPP
|
||||||
|
#define BIGFOOT_UTILS_FORMAT_HPP
|
||||||
|
#include <EASTL/string.h>
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Format a string, like fmt::format, but returning an eastl::string instead of a std::string.
|
||||||
|
*
|
||||||
|
* \param p_format The format string
|
||||||
|
* \param p_args The arguments for the format string
|
||||||
|
* \return The formatted eastl::string
|
||||||
|
*/
|
||||||
|
template<typename... ARGS>
|
||||||
|
eastl::string Format(fmt::format_string<ARGS...> p_format, ARGS&&... p_args)
|
||||||
|
{
|
||||||
|
fmt::memory_buffer buffer;
|
||||||
|
fmt::format_to(std::back_inserter(buffer), p_format, std::forward<ARGS>(p_args)...);
|
||||||
|
return eastl::string {buffer.data(), buffer.size()};
|
||||||
|
}
|
||||||
|
} // namespace Bigfoot
|
||||||
|
#endif
|
||||||
@@ -7,12 +7,13 @@
|
|||||||
#ifndef BIGFOOT_UTILS_VERSION_HPP
|
#ifndef BIGFOOT_UTILS_VERSION_HPP
|
||||||
#define BIGFOOT_UTILS_VERSION_HPP
|
#define BIGFOOT_UTILS_VERSION_HPP
|
||||||
#include <Utils/Caster.hpp>
|
#include <Utils/Caster.hpp>
|
||||||
|
#include <Utils/Format.hpp>
|
||||||
#include <Utils/TargetMacros.h>
|
#include <Utils/TargetMacros.h>
|
||||||
|
|
||||||
|
#include <EASTL/string.h>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace Bigfoot
|
namespace Bigfoot
|
||||||
{
|
{
|
||||||
@@ -99,7 +100,7 @@ class Version
|
|||||||
* \return The string
|
* \return The string
|
||||||
*/
|
*/
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
std::string ToString() const;
|
eastl::string ToString() const;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr auto operator<=>(const Version& p_version) const = default;
|
constexpr auto operator<=>(const Version& p_version) const = default;
|
||||||
@@ -126,7 +127,7 @@ struct fmt::formatter<Bigfoot::Version>
|
|||||||
template<typename FormatContext>
|
template<typename FormatContext>
|
||||||
auto format(const Bigfoot::Version& p_version, FormatContext& p_context) const
|
auto format(const Bigfoot::Version& p_version, FormatContext& p_context) const
|
||||||
{
|
{
|
||||||
return fmt::format_to(p_context.out(), "{}", p_version.ToString());
|
return fmt::format_to(p_context.out(), "{}", p_version.ToString().c_str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
namespace Bigfoot
|
namespace Bigfoot
|
||||||
{
|
{
|
||||||
std::string Version::ToString() const
|
eastl::string Version::ToString() const
|
||||||
{
|
{
|
||||||
return fmt::format("{}.{}.{}", GetMajor(), GetMinor(), GetPatch());
|
return Format("{}.{}.{}", GetMajor(), GetMinor(), GetPatch());
|
||||||
}
|
}
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include <System/UUID/UUID_generated.hpp>
|
#include <System/UUID/UUID_generated.hpp>
|
||||||
|
|
||||||
|
#include <Utils/Format.hpp>
|
||||||
|
|
||||||
#include <ankerl/unordered_dense.h>
|
#include <ankerl/unordered_dense.h>
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
@@ -203,7 +205,7 @@ TEST_F(UUIDFixture, UnPack_ShouldGiveBackTheOriginalUUID)
|
|||||||
|
|
||||||
TEST_F(UUIDFixture, FormatsUUID)
|
TEST_F(UUIDFixture, FormatsUUID)
|
||||||
{
|
{
|
||||||
EXPECT_EQ(fmt::format("{}", m_b), m_b.ToString());
|
EXPECT_STREQ(Format("{}", m_b).c_str(), m_b.ToString().c_str());
|
||||||
EXPECT_EQ(fmt::format("{}", UUID::NULL_UUID), "00000000-0000-0000-0000-000000000000");
|
EXPECT_STREQ(Format("{}", UUID::NULL_UUID).c_str(), "00000000-0000-0000-0000-000000000000");
|
||||||
}
|
}
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
|
|||||||
@@ -6,34 +6,34 @@
|
|||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#include <Utils/Assert/AssertHandler.hpp>
|
#include <Utils/Assert/AssertHandler.hpp>
|
||||||
|
|
||||||
|
#include <Utils/Format.hpp>
|
||||||
#include <Utils/Singleton.hpp>
|
#include <Utils/Singleton.hpp>
|
||||||
|
|
||||||
#include <UtilsTests/UtilsTestsLogger_generated.hpp>
|
#include <UtilsTests/UtilsTestsLogger_generated.hpp>
|
||||||
|
|
||||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||||
|
|
||||||
#include <EASTL/string.h>
|
|
||||||
#include <fmt/format.h>
|
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <source_location>
|
#include <source_location>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Bigfoot
|
namespace Bigfoot
|
||||||
{
|
{
|
||||||
class AssertHandlerFixture: public ::testing::Test
|
class AssertHandlerFixture: public ::testing::Test
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
eastl::string ReadFileSinkContent()
|
std::string ReadFileSinkContent()
|
||||||
{
|
{
|
||||||
Singleton<Log>::GetInstance().Flush();
|
Singleton<Log>::GetInstance().Flush();
|
||||||
|
|
||||||
std::ifstream file {std::string {Log::FILE_SINK_PATH.data()}};
|
std::ifstream file {std::string {Log::FILE_SINK_PATH.data()}};
|
||||||
std::stringstream buffer;
|
std::stringstream buffer;
|
||||||
buffer << file.rdbuf();
|
buffer << file.rdbuf();
|
||||||
return eastl::string {buffer.str().c_str()};
|
return buffer.str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -42,10 +42,9 @@ class AssertHandlerFixture: public ::testing::Test
|
|||||||
TEST_F(AssertHandlerFixture, Handle_ShouldLogAFatalMessageContainingTheGivenMessage)
|
TEST_F(AssertHandlerFixture, Handle_ShouldLogAFatalMessageContainingTheGivenMessage)
|
||||||
{
|
{
|
||||||
constexpr std::source_location location = std::source_location::current();
|
constexpr std::source_location location = std::source_location::current();
|
||||||
AssertHandler<UTILSTESTS_LOGGER>::Handle(location,
|
AssertHandler<UTILSTESTS_LOGGER>::Handle(location, Format("Something went wrong: {}", 42));
|
||||||
eastl::string {fmt::format("Something went wrong: {}", 42).c_str()});
|
|
||||||
|
|
||||||
EXPECT_THAT(std::string {ReadFileSinkContent().c_str()}, ::testing::HasSubstr("Something went wrong: 42"));
|
EXPECT_THAT(ReadFileSinkContent(), ::testing::HasSubstr("Something went wrong: 42"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
@@ -55,7 +54,7 @@ TEST_F(AssertHandlerFixture, Handle_ShouldLogAFatalMessageContainingTheSourceLoc
|
|||||||
constexpr std::source_location location = std::source_location::current();
|
constexpr std::source_location location = std::source_location::current();
|
||||||
AssertHandler<UTILSTESTS_LOGGER>::Handle(location, "Doesn't matter");
|
AssertHandler<UTILSTESTS_LOGGER>::Handle(location, "Doesn't matter");
|
||||||
|
|
||||||
const std::string content {ReadFileSinkContent().c_str()};
|
const std::string content = ReadFileSinkContent();
|
||||||
EXPECT_THAT(content, ::testing::HasSubstr(location.file_name()));
|
EXPECT_THAT(content, ::testing::HasSubstr(location.file_name()));
|
||||||
EXPECT_THAT(content, ::testing::HasSubstr(location.function_name()));
|
EXPECT_THAT(content, ::testing::HasSubstr(location.function_name()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file Format.cpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date September 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#include <Utils/Format.hpp>
|
||||||
|
|
||||||
|
#include <EASTL/string.h>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
TEST(Format, ShouldReturnAnEastlString)
|
||||||
|
{
|
||||||
|
const eastl::string result = Format("Hello");
|
||||||
|
EXPECT_STREQ(result.c_str(), "Hello");
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST(Format, ShouldFormatASingleArgument)
|
||||||
|
{
|
||||||
|
EXPECT_STREQ(Format("Value: {}", 42).c_str(), "Value: 42");
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST(Format, ShouldFormatMultipleArguments)
|
||||||
|
{
|
||||||
|
EXPECT_STREQ(Format("{} + {} = {}", 1, 2, 3).c_str(), "1 + 2 = 3");
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST(Format, ShouldReturnAnEmptyStringForAnEmptyFormat)
|
||||||
|
{
|
||||||
|
EXPECT_STREQ(Format("").c_str(), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST(Format, ShouldFormatAStringLongerThanTheSmallStringOptimizationBuffer)
|
||||||
|
{
|
||||||
|
const eastl::string expected(256, 'a');
|
||||||
|
EXPECT_STREQ(Format("{}", expected.c_str()).c_str(), expected.c_str());
|
||||||
|
}
|
||||||
|
} // namespace Bigfoot
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Bigfoot
|
namespace Bigfoot
|
||||||
{
|
{
|
||||||
@@ -88,14 +89,14 @@ TEST_F(EASTLFormattersFixture, FormatsNestedVectors)
|
|||||||
class EASTLFormattersLogFixture: public ::testing::Test
|
class EASTLFormattersLogFixture: public ::testing::Test
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
eastl::string ReadFileSinkContent()
|
std::string ReadFileSinkContent()
|
||||||
{
|
{
|
||||||
Singleton<Log>::GetInstance().Flush();
|
Singleton<Log>::GetInstance().Flush();
|
||||||
|
|
||||||
std::ifstream file {std::string {Log::FILE_SINK_PATH.data()}};
|
std::ifstream file {std::string {Log::FILE_SINK_PATH.data()}};
|
||||||
std::stringstream buffer;
|
std::stringstream buffer;
|
||||||
buffer << file.rdbuf();
|
buffer << file.rdbuf();
|
||||||
return eastl::string {buffer.str().c_str()};
|
return buffer.str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -105,7 +106,7 @@ TEST_F(EASTLFormattersLogFixture, LogsEastlStringArgument)
|
|||||||
{
|
{
|
||||||
const eastl::string value = "Hello EASTL string";
|
const eastl::string value = "Hello EASTL string";
|
||||||
BIGFOOT_LOG_INFO(UTILSTESTS_LOGGER, "{}", value);
|
BIGFOOT_LOG_INFO(UTILSTESTS_LOGGER, "{}", value);
|
||||||
EXPECT_THAT(std::string {ReadFileSinkContent().c_str()}, ::testing::HasSubstr("Hello EASTL string"));
|
EXPECT_THAT(ReadFileSinkContent(), ::testing::HasSubstr("Hello EASTL string"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
@@ -114,7 +115,7 @@ TEST_F(EASTLFormattersLogFixture, LogsEmptyVectorArgument)
|
|||||||
{
|
{
|
||||||
const eastl::vector<int> value;
|
const eastl::vector<int> value;
|
||||||
BIGFOOT_LOG_INFO(UTILSTESTS_LOGGER, "{}", value);
|
BIGFOOT_LOG_INFO(UTILSTESTS_LOGGER, "{}", value);
|
||||||
EXPECT_THAT(std::string {ReadFileSinkContent().c_str()}, ::testing::HasSubstr("[]"));
|
EXPECT_THAT(ReadFileSinkContent(), ::testing::HasSubstr("[]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
@@ -123,7 +124,7 @@ TEST_F(EASTLFormattersLogFixture, LogsVectorArgumentWithCommaSeparators)
|
|||||||
{
|
{
|
||||||
const eastl::vector<eastl::string> value {"a", "b", "c"};
|
const eastl::vector<eastl::string> value {"a", "b", "c"};
|
||||||
BIGFOOT_LOG_INFO(UTILSTESTS_LOGGER, "{}", value);
|
BIGFOOT_LOG_INFO(UTILSTESTS_LOGGER, "{}", value);
|
||||||
EXPECT_THAT(std::string {ReadFileSinkContent().c_str()}, ::testing::HasSubstr("[a, b, c]"));
|
EXPECT_THAT(ReadFileSinkContent(), ::testing::HasSubstr("[a, b, c]"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
|
|||||||
@@ -12,26 +12,26 @@
|
|||||||
|
|
||||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||||
|
|
||||||
#include <EASTL/string.h>
|
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Bigfoot
|
namespace Bigfoot
|
||||||
{
|
{
|
||||||
class LogMacrosFixture: public ::testing::Test
|
class LogMacrosFixture: public ::testing::Test
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
eastl::string ReadFileSinkContent()
|
std::string ReadFileSinkContent()
|
||||||
{
|
{
|
||||||
Singleton<Log>::GetInstance().Flush();
|
Singleton<Log>::GetInstance().Flush();
|
||||||
|
|
||||||
std::ifstream file {std::string {Log::FILE_SINK_PATH.data()}};
|
std::ifstream file {std::string {Log::FILE_SINK_PATH.data()}};
|
||||||
std::stringstream buffer;
|
std::stringstream buffer;
|
||||||
buffer << file.rdbuf();
|
buffer << file.rdbuf();
|
||||||
return eastl::string {buffer.str().c_str()};
|
return buffer.str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ class LogMacrosFixture: public ::testing::Test
|
|||||||
TEST_F(LogMacrosFixture, LogDebug)
|
TEST_F(LogMacrosFixture, LogDebug)
|
||||||
{
|
{
|
||||||
BIGFOOT_LOG_DEBUG(UTILSTESTS_LOGGER, "Hello Debug");
|
BIGFOOT_LOG_DEBUG(UTILSTESTS_LOGGER, "Hello Debug");
|
||||||
EXPECT_THAT(std::string {ReadFileSinkContent().c_str()}, ::testing::HasSubstr("Hello Debug"));
|
EXPECT_THAT(ReadFileSinkContent(), ::testing::HasSubstr("Hello Debug"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
@@ -48,7 +48,7 @@ TEST_F(LogMacrosFixture, LogDebug)
|
|||||||
TEST_F(LogMacrosFixture, LogTrace)
|
TEST_F(LogMacrosFixture, LogTrace)
|
||||||
{
|
{
|
||||||
BIGFOOT_LOG_TRACE(UTILSTESTS_LOGGER, "Hello Trace");
|
BIGFOOT_LOG_TRACE(UTILSTESTS_LOGGER, "Hello Trace");
|
||||||
EXPECT_THAT(std::string {ReadFileSinkContent().c_str()}, ::testing::HasSubstr("Hello Trace"));
|
EXPECT_THAT(ReadFileSinkContent(), ::testing::HasSubstr("Hello Trace"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
@@ -56,7 +56,7 @@ TEST_F(LogMacrosFixture, LogTrace)
|
|||||||
TEST_F(LogMacrosFixture, LogInfo)
|
TEST_F(LogMacrosFixture, LogInfo)
|
||||||
{
|
{
|
||||||
BIGFOOT_LOG_INFO(UTILSTESTS_LOGGER, "Hello Info");
|
BIGFOOT_LOG_INFO(UTILSTESTS_LOGGER, "Hello Info");
|
||||||
EXPECT_THAT(std::string {ReadFileSinkContent().c_str()}, ::testing::HasSubstr("Hello Info"));
|
EXPECT_THAT(ReadFileSinkContent(), ::testing::HasSubstr("Hello Info"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
@@ -64,7 +64,7 @@ TEST_F(LogMacrosFixture, LogInfo)
|
|||||||
TEST_F(LogMacrosFixture, LogWarn)
|
TEST_F(LogMacrosFixture, LogWarn)
|
||||||
{
|
{
|
||||||
BIGFOOT_LOG_WARN(UTILSTESTS_LOGGER, "Hello Warn");
|
BIGFOOT_LOG_WARN(UTILSTESTS_LOGGER, "Hello Warn");
|
||||||
EXPECT_THAT(std::string {ReadFileSinkContent().c_str()}, ::testing::HasSubstr("Hello Warn"));
|
EXPECT_THAT(ReadFileSinkContent(), ::testing::HasSubstr("Hello Warn"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
@@ -72,7 +72,7 @@ TEST_F(LogMacrosFixture, LogWarn)
|
|||||||
TEST_F(LogMacrosFixture, LogError)
|
TEST_F(LogMacrosFixture, LogError)
|
||||||
{
|
{
|
||||||
BIGFOOT_LOG_ERROR(UTILSTESTS_LOGGER, "Hello Error");
|
BIGFOOT_LOG_ERROR(UTILSTESTS_LOGGER, "Hello Error");
|
||||||
EXPECT_THAT(std::string {ReadFileSinkContent().c_str()}, ::testing::HasSubstr("Hello Error"));
|
EXPECT_THAT(ReadFileSinkContent(), ::testing::HasSubstr("Hello Error"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
@@ -80,7 +80,7 @@ TEST_F(LogMacrosFixture, LogError)
|
|||||||
TEST_F(LogMacrosFixture, LogFatal)
|
TEST_F(LogMacrosFixture, LogFatal)
|
||||||
{
|
{
|
||||||
BIGFOOT_LOG_FATAL(UTILSTESTS_LOGGER, "Hello Fatal");
|
BIGFOOT_LOG_FATAL(UTILSTESTS_LOGGER, "Hello Fatal");
|
||||||
EXPECT_THAT(std::string {ReadFileSinkContent().c_str()}, ::testing::HasSubstr("Hello Fatal"));
|
EXPECT_THAT(ReadFileSinkContent(), ::testing::HasSubstr("Hello Fatal"));
|
||||||
}
|
}
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#include <Utils/Version.hpp>
|
#include <Utils/Version.hpp>
|
||||||
|
|
||||||
|
#include <Utils/Format.hpp>
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
namespace Bigfoot
|
namespace Bigfoot
|
||||||
@@ -75,7 +77,7 @@ TEST_F(VersionFixture, Comparisons)
|
|||||||
|
|
||||||
TEST_F(VersionFixture, FormatsVersion)
|
TEST_F(VersionFixture, FormatsVersion)
|
||||||
{
|
{
|
||||||
EXPECT_EQ(fmt::format("{}", m_detailed), "1.2.3");
|
EXPECT_STREQ(Format("{}", m_detailed).c_str(), "1.2.3");
|
||||||
EXPECT_EQ(fmt::format("{}", m_combined), "1.2.3");
|
EXPECT_STREQ(Format("{}", m_combined).c_str(), "1.2.3");
|
||||||
}
|
}
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
|
|||||||
Reference in New Issue
Block a user