More work on data formatters

This commit is contained in:
2026-04-20 20:52:17 -04:00
parent 4c1eebab96
commit 0d607ba277
3 changed files with 281 additions and 687 deletions

View File

@@ -0,0 +1,57 @@
#pragma once
#include "CoreMinimal.h"
#include "WingServer.h"
#include "WingBasics.h"
#include "Containers/BitArray.h"
#include "Containers/SparseArray.h"
#include "Test_TMaps.generated.h"
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
UCLASS()
class UWing_Test_TMaps : public UWingHandler
{
GENERATED_BODY()
public:
virtual void Register() override
{
UWingServer::AddHandler(this,
TEXT("Constructs a small TMap, TBitArray, and TSparseArray so that "
"a developer can set a breakpoint and inspect them with the "
"lldb data formatters."));
}
virtual void Handle() override
{
TMap<int32, FString> Map;
Map.Add(1, TEXT("one"));
Map.Add(2, TEXT("two"));
Map.Add(3, TEXT("three"));
Map.Add(42, TEXT("forty-two"));
TBitArray<> Bits;
Bits.Add(true);
Bits.Add(false);
Bits.Add(true);
Bits.Add(true);
Bits.Add(false);
// Add a few entries, then remove a middle one so the live set is
// non-contiguous. Exercises the sparse-array formatter against a hole.
TSparseArray<FString> Sparse;
Sparse.Add(TEXT("alpha"));
int32 BetaIdx = Sparse.Add(TEXT("beta"));
Sparse.Add(TEXT("gamma"));
Sparse.Add(TEXT("delta"));
Sparse.RemoveAt(BetaIdx);
// Set a breakpoint on the following line to inspect Map, Bits, and Sparse.
WingOut::Stdout.Printf(TEXT("Test_TMaps: Map has %d entries, Bits has %d bits, Sparse has %d entries.\n"),
Map.Num(), Bits.Num(), Sparse.Num());
}
};