// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" // TraceServices #include "Common/StringStore.h" #include "Model/Tables.h" #include "TraceServices/Model/TableImport.h" class FTokenizedMessage; namespace TraceServices { struct FColumnValueContainer; class FImportTableRow { public: FColumnValueContainer GetValue(uint64 ColumnIndex) const { return Values[static_cast(ColumnIndex)]; } template void SetValue(uint64 ColumnIndex, T Value) { Values[static_cast(ColumnIndex)] = Value; } void SetNumValues(uint64 NumColumns) { Values.AddUninitialized(static_cast(NumColumns)); } private: TArray Values; }; constexpr int GImportTableAllocatorSlabSize = 32 << 20; template class TImportTable : public TTable { public: TImportTable() : TTable() , StringStore(TTable::Allocator) { } virtual ~TImportTable() {} FStringStore& GetStringStore() { return StringStore; } private: FStringStore StringStore; }; class FTableImportTask { public: FTableImportTask(const FString& InFilePath, FName InTableId, FTableImportService::TableImportCallback InCallback); ~FTableImportTask(); void operator()(); bool ParseHeader(const FString& HeaderLine); bool CreateLayout(const FString& Line); bool ParseData(TArray& Lines); private: ETableImportResult ImportTable(); void SplitLineIntoValues(const FString& InLine, TArray& OutValues); bool LoadFileToStringArray(const FString& InFilePath, TArray& Lines); void AddError(const FText& Msg); FTableImportService::TableImportCallback Callback; TSharedPtr> Table; TArray> Messages; TArray ColumnNames; FString FilePath; FName TableId; FString Separator; }; } // namespace TraceServices