diff options
| author | Dan Engelbrecht <[email protected]> | 2025-10-03 14:52:01 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-10-03 14:52:01 +0200 |
| commit | a2a19b533bbcdab37b7704a8b89a22069db39ec8 (patch) | |
| tree | 7e4cc4a9c9ede02db1dbef16883698cd0474e11b /src/zenutil/include | |
| parent | move zen vfs implementation to zenstore (#549) (diff) | |
| download | zen-a2a19b533bbcdab37b7704a8b89a22069db39ec8.tar.xz zen-a2a19b533bbcdab37b7704a8b89a22069db39ec8.zip | |
zenutil cleanup (#550)
* move referencemetadata to zenstore
* rename zenutil/windows/service to windowsservice
Diffstat (limited to 'src/zenutil/include')
| -rw-r--r-- | src/zenutil/include/zenutil/referencemetadata.h | 109 | ||||
| -rw-r--r-- | src/zenutil/include/zenutil/windows/windowsservice.h (renamed from src/zenutil/include/zenutil/windows/service.h) | 0 |
2 files changed, 0 insertions, 109 deletions
diff --git a/src/zenutil/include/zenutil/referencemetadata.h b/src/zenutil/include/zenutil/referencemetadata.h deleted file mode 100644 index 5160bfb8b..000000000 --- a/src/zenutil/include/zenutil/referencemetadata.h +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright Epic Games, Inc. All Rights Reserved. - -#pragma once - -#include <zencore/compositebuffer.h> - -ZEN_THIRD_PARTY_INCLUDES_START -#include <gsl/gsl-lite.hpp> -ZEN_THIRD_PARTY_INCLUDES_END - -namespace zen { - -#pragma pack(push) -#pragma pack(1) - -struct ReferenceMetaDataHeader -{ - static constexpr uint32_t Version1 = 1; - static constexpr uint32_t CurrentVersion = Version1; - - ReferenceMetaDataHeader(uint32_t InMagic, uint32_t InEntryCount, uint64_t InAttachmentCount) - : Magic(InMagic) - , EntryCount(InEntryCount) - , AttachmentCount(InAttachmentCount) - , Checksum(ComputeChecksum()) - { - } - - uint32_t Magic = 0xffffffffu; - uint32_t Version = CurrentVersion; - - uint32_t EntryCount = 0; - uint64_t AttachmentCount = 0; - uint64_t Padding = 0; - - uint32_t Checksum = 0; - - bool IsValid(uint32_t ExpectedMagic) const; - - template<typename KeyType, typename AttachmentType> - static uint64_t ExpectedSize(uint32_t EntryCount, uint64_t AttachmentCount) - { - return sizeof(ReferenceMetaDataHeader) + sizeof(KeyType) * EntryCount + sizeof(uint32_t) * EntryCount + - sizeof(AttachmentType) * AttachmentCount; - } - - ReferenceMetaDataHeader() = delete; - -private: - uint32_t ComputeChecksum() const; -}; - -static_assert(sizeof(ReferenceMetaDataHeader) == 32); - -#pragma pack(pop) - -template<typename KeyType, typename AttachmentType> -CompositeBuffer -BuildReferenceMetaData(uint32_t HeaderMagic, - std::span<const KeyType> Keys, - std::span<const uint32_t> AttachmentCounts, - std::span<const AttachmentType> Attachments) -{ - uint32_t KeyCount = gsl::narrow<uint32_t>(Keys.size()); - - ReferenceMetaDataHeader Header(HeaderMagic, KeyCount, Attachments.size()); - return CompositeBuffer(std::vector<SharedBuffer>{ - SharedBuffer(IoBuffer(IoBuffer::Clone, &Header, sizeof(ReferenceMetaDataHeader))), - SharedBuffer(IoBuffer(IoBuffer::Wrap, Keys.data(), sizeof(KeyType) * Keys.size())), - SharedBuffer(IoBuffer(IoBuffer::Wrap, AttachmentCounts.data(), sizeof(uint32_t) * AttachmentCounts.size())), - SharedBuffer(IoBuffer(IoBuffer::Wrap, Attachments.data(), sizeof(AttachmentType) * Attachments.size()))}); -} - -template<typename KeyType, typename AttachmentType> -bool -GetAttachmentsFromMetaData(const IoBuffer& MetaData, - const uint32_t ExpectedHeaderMagic, - std::function<void(std::span<const KeyType> Keys, - std::span<const uint32_t> AttachmentCounts, - std::span<const AttachmentType> Attachments)>&& Parser) -{ - MemoryView PayloadView = MetaData.GetView(); - if (PayloadView.GetSize() >= sizeof(ReferenceMetaDataHeader)) - { - const ReferenceMetaDataHeader* Header = (const ReferenceMetaDataHeader*)PayloadView.GetData(); - if (Header->IsValid(ExpectedHeaderMagic)) - { - if (MetaData.GetSize() == - ReferenceMetaDataHeader::ExpectedSize<KeyType, AttachmentType>(Header->EntryCount, Header->AttachmentCount)) - { - PayloadView.MidInline(sizeof(ReferenceMetaDataHeader)); - std::span<const KeyType> PayloadKeys = {(const KeyType*)PayloadView.GetData(), Header->EntryCount}; - PayloadView.MidInline(sizeof(KeyType) * Header->EntryCount); - std::span<const uint32_t> PayloadAttachmentCounts = {(const uint32_t*)PayloadView.GetData(), Header->EntryCount}; - PayloadView.MidInline(sizeof(uint32_t) * Header->EntryCount); - std::span<const AttachmentType> PayloadAttachments = {(const AttachmentType*)PayloadView.GetData(), - Header->AttachmentCount}; - PayloadView.MidInline(sizeof(AttachmentType) * Header->AttachmentCount); - ZEN_ASSERT(PayloadView.GetSize() == 0); - - Parser(PayloadKeys, PayloadAttachmentCounts, PayloadAttachments); - - return true; - } - } - } - return false; -} -} // namespace zen diff --git a/src/zenutil/include/zenutil/windows/service.h b/src/zenutil/include/zenutil/windows/windowsservice.h index ca0270a36..ca0270a36 100644 --- a/src/zenutil/include/zenutil/windows/service.h +++ b/src/zenutil/include/zenutil/windows/windowsservice.h |