aboutsummaryrefslogtreecommitdiff
path: root/zencore/include
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-08-20 13:51:39 +0200
committerStefan Boberg <[email protected]>2021-08-20 13:51:39 +0200
commitd88262efac17b956600c85a2ba5e70c66937eb96 (patch)
tree52352a8183bd1e528d7380b82926fe13bfbdabeb /zencore/include
parentRenamed CompactBinaryAttachment to ObjectAttachment to mimic UE (see CL16510518) (diff)
downloadzen-d88262efac17b956600c85a2ba5e70c66937eb96.tar.xz
zen-d88262efac17b956600c85a2ba5e70c66937eb96.zip
CL16570338: CompactBinary: Added validation to LoadCompactBinary and removed asserts from the other load functions
Diffstat (limited to 'zencore/include')
-rw-r--r--zencore/include/zencore/compactbinary.h11
-rw-r--r--zencore/include/zencore/compactbinarypackage.h12
2 files changed, 17 insertions, 6 deletions
diff --git a/zencore/include/zencore/compactbinary.h b/zencore/include/zencore/compactbinary.h
index 2a4d250cb..4c9b48d3a 100644
--- a/zencore/include/zencore/compactbinary.h
+++ b/zencore/include/zencore/compactbinary.h
@@ -1262,6 +1262,17 @@ CbField::AsArray() &&
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Load a compact binary field from an archive.
+ *
+ * The field may be an array or an object, which the caller can convert to by using AsArray or
+ * AsObject as appropriate. The buffer allocator is called to provide the buffer for the field
+ * to load into once its size has been determined.
+ *
+ * @param Ar Archive to read the field from. An error state is set on failure.
+ * @param Allocator Allocator for the buffer that the field is loaded into.
+ * @return A field with a reference to the allocated buffer, or a default field on failure.
+ */
ZENCORE_API CbField LoadCompactBinary(BinaryReader& Ar, BufferAllocator Allocator);
inline CbObject
diff --git a/zencore/include/zencore/compactbinarypackage.h b/zencore/include/zencore/compactbinarypackage.h
index 03098f494..d7a8ea7fc 100644
--- a/zencore/include/zencore/compactbinarypackage.h
+++ b/zencore/include/zencore/compactbinarypackage.h
@@ -83,17 +83,17 @@ public:
*
* The iterator is advanced as attachment fields are consumed from it.
*/
- ZENCORE_API void Load(CbFieldIterator& Fields);
+ ZENCORE_API bool TryLoad(CbFieldIterator& Fields);
/**
* Load the attachment from compact binary as written by Save.
*/
- ZENCORE_API void Load(BinaryReader& Reader, BufferAllocator Allocator = UniqueBuffer::Alloc);
+ ZENCORE_API bool TryLoad(BinaryReader& Reader, BufferAllocator Allocator = UniqueBuffer::Alloc);
/**
* Load the attachment from compact binary as written by Save.
*/
- ZENCORE_API void Load(IoBuffer& Buffer, BufferAllocator Allocator = UniqueBuffer::Alloc);
+ ZENCORE_API bool TryLoad(IoBuffer& Buffer, BufferAllocator Allocator = UniqueBuffer::Alloc);
/** Save the attachment into the writer as a stream of compact binary fields. */
ZENCORE_API void Save(CbWriter& Writer) const;
@@ -277,11 +277,11 @@ public:
*
* The iterator is advanced as object and attachment fields are consumed from it.
*/
- ZENCORE_API void Load(CbFieldIterator& Fields);
+ ZENCORE_API bool TryLoad(CbFieldIterator& Fields);
- ZENCORE_API void Load(IoBuffer& Buffer, BufferAllocator Allocator = UniqueBuffer::Alloc, AttachmentResolver* Mapper = nullptr);
+ ZENCORE_API bool TryLoad(IoBuffer& Buffer, BufferAllocator Allocator = UniqueBuffer::Alloc, AttachmentResolver* Mapper = nullptr);
- ZENCORE_API void Load(BinaryReader& Reader, BufferAllocator Allocator = UniqueBuffer::Alloc, AttachmentResolver* Mapper = nullptr);
+ ZENCORE_API bool TryLoad(BinaryReader& Reader, BufferAllocator Allocator = UniqueBuffer::Alloc, AttachmentResolver* Mapper = nullptr);
/** Save the object and attachments into the writer as a stream of compact binary fields. */
ZENCORE_API void Save(CbWriter& Writer) const;