// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "PlainPropsTypes.h" #include "Containers/Array.h" #include "Templates/UniquePtr.h" #include namespace PlainProps { struct FBuiltSchemas; struct FBuiltStruct; class FIdIndexerBase; class FNestedScopeIndexer; class FParametricTypeIndexer; struct FWriteIds; struct IDeclarations; class FWriter { public: PLAINPROPS_API FWriter(const FIdIndexerBase& AllIds, const IDeclarations& Declarations, const FBuiltSchemas& InSchemas, ESchemaFormat Format); PLAINPROPS_API ~FWriter(); PLAINPROPS_API TConstArrayView GetUsedNames() const; PLAINPROPS_API FOptionalStructSchemaId GetWriteId(FStructId BuiltId) const; PLAINPROPS_API void WriteSchemas(TArray64& Out) const; PLAINPROPS_API FStructSchemaId WriteMembers(TArray64& Out, FStructId BuiltId, const FBuiltStruct& Struct) const; private: const FBuiltSchemas& Schemas; FDebugIds Debug; TUniquePtr NewIds; }; ////////////////////////////////////////////////////////////////////////// inline void WriteData(TArray64& Out, const void* Data, int64 Size) { Out.Append(static_cast(Data), Size); } template void WriteArray(TArray64& Out, const ArrayType& In) requires (!!TIsContiguousContainer::Value) { WriteData(Out, In.GetData(), sizeof(typename ArrayType::ElementType) * In.Num()); } template void WriteAlignmentPadding(TArray64& Out) { Out.AddZeroed(Align(Out.Num(), alignof(T)) - Out.Num()); } template void WriteAlignedArray(TArray64& Out, TArrayView In) { WriteAlignmentPadding(Out); WriteArray(Out, In); } template inline void WriteInt(TArray64& Out, T Number) requires (std::is_integral_v && !!PLATFORM_LITTLE_ENDIAN) { WriteData(Out, &Number, sizeof(T)); } PLAINPROPS_API uint64 WriteSkippableSlice(TArray64& Out, TConstArrayView64 Slice); } // namespace PlainProps