diff options
| author | Dan Engelbrecht <[email protected]> | 2022-11-18 11:35:13 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-11-18 02:35:13 -0800 |
| commit | 55225621f018904abf7e212320bb784dc64f8ac3 (patch) | |
| tree | 3fb962e9e0553448f9d42612bb078ff072308e1c /zencore/include | |
| parent | move BasicFile to zenutil to remove zenstore dependency from zen command (#190) (diff) | |
| download | zen-55225621f018904abf7e212320bb784dc64f8ac3.tar.xz zen-55225621f018904abf7e212320bb784dc64f8ac3.zip | |
Add `import-project` and `export-project` (#183)
* Add `import-project` and `export-project` command line parsing
Diffstat (limited to 'zencore/include')
| -rw-r--r-- | zencore/include/zencore/compactbinarypackage.h | 30 | ||||
| -rw-r--r-- | zencore/include/zencore/compositebuffer.h | 9 | ||||
| -rw-r--r-- | zencore/include/zencore/compress.h | 9 | ||||
| -rw-r--r-- | zencore/include/zencore/stream.h | 2 |
4 files changed, 22 insertions, 28 deletions
diff --git a/zencore/include/zencore/compactbinarypackage.h b/zencore/include/zencore/compactbinarypackage.h index c3e587f40..16f723edc 100644 --- a/zencore/include/zencore/compactbinarypackage.h +++ b/zencore/include/zencore/compactbinarypackage.h @@ -64,8 +64,8 @@ public: ZENCORE_API explicit CbAttachment(CompositeBuffer&& InValue, const IoHash& Hash); /** Construct a compressed binary attachment. Value is cloned if not owned. */ - ZENCORE_API explicit CbAttachment(const CompressedBuffer& InValue); - ZENCORE_API explicit CbAttachment(CompressedBuffer&& InValue); + ZENCORE_API explicit CbAttachment(const CompressedBuffer& InValue, const IoHash& Hash); + ZENCORE_API explicit CbAttachment(CompressedBuffer&& InValue, const IoHash& Hash); /** Reset this to a null attachment. */ inline void Reset() { *this = CbAttachment(); } @@ -133,28 +133,8 @@ public: private: ZENCORE_API CbAttachment(const CbObject& Value, const IoHash* Hash); - struct CbObjectValue - { - CbObject Object; - IoHash Hash; - - CbObjectValue(const CbObject& InObject, const IoHash& InHash) : Object(InObject), Hash(InHash) {} - CbObjectValue(CbObject&& InObject, const IoHash& InHash) : Object(std::move(InObject)), Hash(InHash) {} - }; - - struct BinaryValue - { - CompositeBuffer Buffer; - IoHash Hash; - - BinaryValue(const CompositeBuffer& InBuffer) : Buffer(InBuffer.MakeOwned()), Hash(IoHash::HashBuffer(InBuffer)) {} - BinaryValue(const CompositeBuffer& InBuffer, const IoHash& InHash) : Buffer(InBuffer.MakeOwned()), Hash(InHash) {} - BinaryValue(CompositeBuffer&& InBuffer) : Buffer(std::move(InBuffer)), Hash(IoHash::HashBuffer(Buffer)) {} - BinaryValue(CompositeBuffer&& InBuffer, const IoHash& InHash) : Buffer(std::move(InBuffer)), Hash(InHash) {} - BinaryValue(SharedBuffer&& InBuffer, const IoHash& InHash) : Buffer(std::move(InBuffer)), Hash(InHash) {} - }; - - std::variant<std::nullptr_t, CbObjectValue, BinaryValue, CompressedBuffer> Value; + IoHash Hash; + std::variant<std::nullptr_t, CbObject, CompositeBuffer, CompressedBuffer> Value; }; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -300,6 +280,8 @@ public: /** Add the attachment to this package, along with any references that can be resolved. */ inline void AddAttachment(const CbAttachment& Attachment, AttachmentResolver Resolver) { AddAttachment(Attachment, &Resolver); } + void AddAttachments(std::span<const CbAttachment> Attachments); + /** * Remove an attachment by hash. * diff --git a/zencore/include/zencore/compositebuffer.h b/zencore/include/zencore/compositebuffer.h index 4a3b60428..4e4b4d002 100644 --- a/zencore/include/zencore/compositebuffer.h +++ b/zencore/include/zencore/compositebuffer.h @@ -99,6 +99,15 @@ public: uint64_t Size, std::function<void(MemoryView View, const SharedBuffer& ViewOuter)> Visitor) const; + struct Iterator + { + size_t SegmentIndex = 0; + uint64_t OffsetInSegment = 0; + }; + ZENCORE_API Iterator GetIterator(uint64_t Offset) const; + ZENCORE_API MemoryView ViewOrCopyRange(Iterator& It, uint64_t Size, UniqueBuffer& CopyBuffer) const; + ZENCORE_API void CopyTo(MutableMemoryView Target, Iterator& It) const; + /** A null composite buffer. */ static const CompositeBuffer Null; diff --git a/zencore/include/zencore/compress.h b/zencore/include/zencore/compress.h index d37ecfa79..92dc1fb76 100644 --- a/zencore/include/zencore/compress.h +++ b/zencore/include/zencore/compress.h @@ -75,6 +75,8 @@ public: [[nodiscard]] ZENCORE_API static CompressedBuffer FromCompressed(CompositeBuffer&& CompressedData); [[nodiscard]] ZENCORE_API static CompressedBuffer FromCompressed(const SharedBuffer& CompressedData); [[nodiscard]] ZENCORE_API static CompressedBuffer FromCompressed(SharedBuffer&& CompressedData); + [[nodiscard]] ZENCORE_API static CompressedBuffer FromCompressedNoValidate(IoBuffer&& CompressedData); + [[nodiscard]] ZENCORE_API static CompressedBuffer FromCompressedNoValidate(CompositeBuffer&& CompressedData); /** Reset this to null. */ inline void Reset() { CompressedData.Reset(); } @@ -89,8 +91,8 @@ public: [[nodiscard]] inline bool IsOwned() const { return CompressedData.IsOwned(); } /** Returns a copy of the compressed buffer that owns its underlying memory. */ - [[nodiscard]] inline CompressedBuffer MakeOwned() const& { return FromCompressed(CompressedData.MakeOwned()); } - [[nodiscard]] inline CompressedBuffer MakeOwned() && { return FromCompressed(std::move(CompressedData).MakeOwned()); } + [[nodiscard]] inline CompressedBuffer MakeOwned() const& { return FromCompressedNoValidate(CompressedData.MakeOwned()); } + [[nodiscard]] inline CompressedBuffer MakeOwned() && { return FromCompressedNoValidate(std::move(CompressedData).MakeOwned()); } /** Returns a composite buffer containing the compressed data. May be null. May not be owned. */ [[nodiscard]] inline const CompositeBuffer& GetCompressed() const& { return CompressedData; } @@ -117,7 +119,8 @@ public: * @return True if parameters were written, otherwise false. */ [[nodiscard]] ZENCORE_API bool TryGetCompressParameters(OodleCompressor& OutCompressor, - OodleCompressionLevel& OutCompressionLevel) const; + OodleCompressionLevel& OutCompressionLevel, + uint64_t& OutBlockSize) const; /** * Decompress into a memory view that is less or equal GetRawSize() bytes. diff --git a/zencore/include/zencore/stream.h b/zencore/include/zencore/stream.h index ec303e1f8..9e4996249 100644 --- a/zencore/include/zencore/stream.h +++ b/zencore/include/zencore/stream.h @@ -28,6 +28,7 @@ public: } inline void Write(MemoryView Memory) { Write(Memory.GetData(), Memory.GetSize()); } + void Write(std::initializer_list<const MemoryView> Buffers); inline uint64_t CurrentOffset() const { return m_Offset; } @@ -41,7 +42,6 @@ public: inline MutableMemoryView GetMutableView() { return MutableMemoryView(m_Buffer.data(), m_Offset); } private: - RwLock m_Lock; std::vector<uint8_t> m_Buffer; uint64_t m_Offset = 0; |