aboutsummaryrefslogtreecommitdiff
path: root/zencore/include
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-09-01 14:56:22 +0200
committerStefan Boberg <[email protected]>2021-09-01 14:56:22 +0200
commitc6f8a05f22b75d240c14ebfe9225ca1e2fa264c7 (patch)
tree7a661e7752a14a73451d2b1181d76af511d4f3a7 /zencore/include
parentFixed SharedBuffer::IsOwned() semantics to match UE5 (diff)
downloadzen-c6f8a05f22b75d240c14ebfe9225ca1e2fa264c7.tar.xz
zen-c6f8a05f22b75d240c14ebfe9225ca1e2fa264c7.zip
CompactBinary: Restricted compact binary attachments to objects to simplify package management
based on CL16533710 @ p4
Diffstat (limited to 'zencore/include')
-rw-r--r--zencore/include/zencore/compactbinary.h2
-rw-r--r--zencore/include/zencore/compactbinarypackage.h16
2 files changed, 10 insertions, 8 deletions
diff --git a/zencore/include/zencore/compactbinary.h b/zencore/include/zencore/compactbinary.h
index 839218940..537f33d31 100644
--- a/zencore/include/zencore/compactbinary.h
+++ b/zencore/include/zencore/compactbinary.h
@@ -874,6 +874,8 @@ public:
/** @see CbField::CbField */
using CbFieldView::CbFieldView;
+ using CbFieldView::TryGetSerializedView;
+
/** Construct an object with no fields. */
ZENCORE_API CbObjectView();
diff --git a/zencore/include/zencore/compactbinarypackage.h b/zencore/include/zencore/compactbinarypackage.h
index 493eb2ba7..66bace294 100644
--- a/zencore/include/zencore/compactbinarypackage.h
+++ b/zencore/include/zencore/compactbinarypackage.h
@@ -36,10 +36,10 @@ public:
CbAttachment() = default;
/** Construct a compact binary attachment. Value is cloned if not owned. */
- inline explicit CbAttachment(CbFieldIterator Value) : CbAttachment(std::move(Value), nullptr) {}
+ inline explicit CbAttachment(CbObject Value) : CbAttachment(std::move(Value), nullptr) {}
/** Construct a compact binary attachment. Value is cloned if not owned. Hash must match Value. */
- inline explicit CbAttachment(CbFieldIterator Value, const IoHash& Hash) : CbAttachment(std::move(Value), &Hash) {}
+ inline explicit CbAttachment(CbObject Value, const IoHash& Hash) : CbAttachment(std::move(Value), &Hash) {}
/** Construct a binary attachment. Value is cloned if not owned. */
inline explicit CbAttachment(SharedBuffer Value) : CbAttachment(std::move(Value), nullptr) {}
@@ -57,16 +57,16 @@ public:
inline bool IsNull() const { return !Buffer; }
/** Access the attachment as binary. Defaults to a null buffer on error. */
- ZENCORE_API SharedBuffer AsBinaryView() const;
+ inline SharedBuffer AsBinary() const { return Buffer; }
/** Access the attachment as compact binary. Defaults to a field iterator with no value on error. */
- ZENCORE_API CbFieldIterator AsCompactBinary() const;
+ inline CbObject AsObject() const { return Object ? CbObject(CbFieldView(Object).AsObjectView(), Buffer) : CbObject{}; }
/** Returns whether the attachment is binary or compact binary. */
inline bool IsBinary() const { return !Buffer.IsNull(); }
/** Returns whether the attachment is compact binary. */
- inline bool IsCompactBinary() const { return CompactBinary.HasValue(); }
+ inline bool IsObject() const { return Object.IsObject(); }
/** Returns the hash of the attachment value. */
inline const IoHash& GetHash() const { return Hash; }
@@ -102,13 +102,13 @@ public:
ZENCORE_API void Save(BinaryWriter& Writer) const;
private:
- ZENCORE_API CbAttachment(CbFieldIterator Value, const IoHash* Hash);
+ ZENCORE_API CbAttachment(CbObject Value, const IoHash* Hash);
ZENCORE_API CbAttachment(SharedBuffer Value, const IoHash* Hash);
/** An owned buffer containing the binary or compact binary data. */
SharedBuffer Buffer;
/** A field iterator that is valid only for compact binary attachments. */
- CbFieldViewIterator CompactBinary;
+ CbFieldView Object;
/** A hash of the attachment value. */
IoHash Hash;
};
@@ -293,7 +293,7 @@ private:
ZENCORE_API void SetObject(CbObject Object, const IoHash* Hash, AttachmentResolver* Resolver);
ZENCORE_API void AddAttachment(const CbAttachment& Attachment, AttachmentResolver* Resolver);
- void GatherAttachments(const CbFieldViewIterator& Fields, AttachmentResolver Resolver);
+ void GatherAttachments(const CbObject& Object, AttachmentResolver Resolver);
/** Attachments ordered by their hash. */
std::vector<CbAttachment> Attachments;