diff options
| author | Stefan Boberg <[email protected]> | 2021-08-20 11:14:10 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-08-20 11:14:10 +0200 |
| commit | 0bf5380d2ce123585d29c1ad624b7eee2f8eca56 (patch) | |
| tree | d4ec94793adc269d0acd165c5a2d522b9a4efb5b | |
| parent | Updated ObjectId comment (diff) | |
| download | zen-0bf5380d2ce123585d29c1ad624b7eee2f8eca56.tar.xz zen-0bf5380d2ce123585d29c1ad624b7eee2f8eca56.zip | |
Renamed CompactBinaryAttachment to ObjectAttachment to mimic UE (see CL16510518)
| -rw-r--r-- | zencore/compactbinary.cpp | 10 | ||||
| -rw-r--r-- | zencore/compactbinarybuilder.cpp | 6 | ||||
| -rw-r--r-- | zencore/compactbinarypackage.cpp | 36 | ||||
| -rw-r--r-- | zencore/compactbinaryvalidation.cpp | 4 | ||||
| -rw-r--r-- | zencore/include/zencore/compactbinary.h | 14 | ||||
| -rw-r--r-- | zencore/include/zencore/compactbinarybuilder.h | 6 | ||||
| -rw-r--r-- | zencore/include/zencore/compactbinaryvalidation.h | 2 |
7 files changed, 39 insertions, 39 deletions
diff --git a/zencore/compactbinary.cpp b/zencore/compactbinary.cpp index b42bcec7e..62c60418c 100644 --- a/zencore/compactbinary.cpp +++ b/zencore/compactbinary.cpp @@ -110,7 +110,7 @@ CbFieldView::IterateAttachments(std::function<void(CbFieldView)> Visitor) const case CbFieldType::Array: case CbFieldType::UniformArray: return CbArrayView::FromFieldView(*this).IterateAttachments(Visitor); - case CbFieldType::CompactBinaryAttachment: + case CbFieldType::ObjectAttachment: case CbFieldType::BinaryAttachment: return Visitor(*this); default: @@ -295,9 +295,9 @@ CbFieldView::AsBool(const bool bDefault) } IoHash -CbFieldView::AsCompactBinaryAttachment(const IoHash& Default) +CbFieldView::AsObjectAttachment(const IoHash& Default) { - if (CbFieldTypeOps::IsCompactBinaryAttachment(Type)) + if (CbFieldTypeOps::IsObjectAttachment(Type)) { Error = CbFieldError::None; return IoHash::MakeFrom(Payload); @@ -493,7 +493,7 @@ CbFieldView::GetPayloadSize() const case CbFieldType::BoolFalse: case CbFieldType::BoolTrue: return 0; - case CbFieldType::CompactBinaryAttachment: + case CbFieldType::ObjectAttachment: case CbFieldType::BinaryAttachment: case CbFieldType::Hash: return 20; @@ -957,7 +957,7 @@ TryMeasureCompactBinary(MemoryView View, CbFieldType& OutType, uint64_t& OutSize case CbFieldType::BoolFalse: case CbFieldType::BoolTrue: break; - case CbFieldType::CompactBinaryAttachment: + case CbFieldType::ObjectAttachment: case CbFieldType::BinaryAttachment: case CbFieldType::Hash: FixedSize = 20; diff --git a/zencore/compactbinarybuilder.cpp b/zencore/compactbinarybuilder.cpp index 74756b51c..a30c8f04a 100644 --- a/zencore/compactbinarybuilder.cpp +++ b/zencore/compactbinarybuilder.cpp @@ -588,11 +588,11 @@ CbWriter::AddBool(const bool bValue) ZEN_NOINLINE void -CbWriter::AddCompactBinaryAttachment(const IoHash& Value) +CbWriter::AddObjectAttachment(const IoHash& Value) { BeginField(); Append(Data, Value.Hash, sizeof Value.Hash); - EndField(CbFieldType::CompactBinaryAttachment); + EndField(CbFieldType::ObjectAttachment); } ZEN_NOINLINE @@ -1359,7 +1359,7 @@ TEST_CASE("usonbuilder.complex") Writer.AddBool("False"sv, false); Writer.AddBool("True"sv, true); - Writer.AddCompactBinaryAttachment("CompactBinaryAttachment"sv, IoHash()); + Writer.AddObjectAttachment("ObjectAttachment"sv, IoHash()); Writer.AddBinaryAttachment("BinaryAttachment"sv, IoHash()); Writer.AddAttachment("Attachment"sv, CbAttachment()); diff --git a/zencore/compactbinarypackage.cpp b/zencore/compactbinarypackage.cpp index 5b659ef39..4a1ea65d2 100644 --- a/zencore/compactbinarypackage.cpp +++ b/zencore/compactbinarypackage.cpp @@ -118,7 +118,7 @@ CbAttachment::Load(CbFieldIterator& Fields) ++Fields; Hash = Fields.AsAttachment(); ZEN_ASSERT(!Fields.HasError()); // TEXT("Attachments must be a non-empty binary value with a content hash.")); - if (Fields.IsCompactBinaryAttachment()) + if (Fields.IsObjectAttachment()) { CompactBinary = CbFieldViewIterator::MakeRange(Buffer); } @@ -152,7 +152,7 @@ CbAttachment::Load(BinaryReader& Reader, BufferAllocator Allocator) }); Hash = HashField.AsAttachment(); ZEN_ASSERT(!HashField.HasError(), "Attachments must be a non-empty binary value with a content hash."); - if (HashField.IsCompactBinaryAttachment()) + if (HashField.IsObjectAttachment()) { CompactBinary = CbFieldViewIterator::MakeRange(Buffer); } @@ -179,7 +179,7 @@ CbAttachment::Save(CbWriter& Writer) const { Writer.AddBinary(AsBinaryView()); } - Writer.AddCompactBinaryAttachment(Hash); + Writer.AddObjectAttachment(Hash); } else if (Buffer && Buffer.GetSize()) { @@ -289,7 +289,7 @@ CbPackage::GatherAttachments(const CbFieldViewIterator& Fields, AttachmentResolv if (SharedBuffer Buffer = Resolver(Hash)) { - if (Field.IsCompactBinaryAttachment()) + if (Field.IsObjectAttachment()) { AddAttachment(CbAttachment(CbFieldIterator::MakeRange(std::move(Buffer)), Hash), &Resolver); } @@ -335,7 +335,7 @@ CbPackage::Load(CbFieldIterator& Fields) ++Fields; if (Object.CreateIterator()) { - ObjectHash = Fields.AsCompactBinaryAttachment(); + ObjectHash = Fields.AsObjectAttachment(); ZEN_ASSERT(!Fields.HasError(), TEXT("Object must be followed by a CompactBinaryReference with the object hash.")); ++Fields; } @@ -379,7 +379,7 @@ CbPackage::Load(BinaryReader& Reader, BufferAllocator Allocator, AttachmentResol CbField HashField = LoadCompactBinary(Reader, StackAllocator); const IoHash& Hash = HashField.AsAttachment(); ZEN_ASSERT(!HashField.HasError(), "Attachments must be a non-empty binary value with a content hash."); - if (HashField.IsCompactBinaryAttachment()) + if (HashField.IsObjectAttachment()) { AddAttachment(CbAttachment(CbFieldIterator::MakeRange(std::move(Buffer)), Hash)); } @@ -405,8 +405,8 @@ CbPackage::Load(BinaryReader& Reader, BufferAllocator Allocator, AttachmentResol if (Object.CreateViewIterator()) { CbField HashField = LoadCompactBinary(Reader, StackAllocator); - ObjectHash = HashField.AsCompactBinaryAttachment(); - ZEN_ASSERT(!HashField.HasError(), "Object must be followed by a CompactBinaryAttachment with the object hash."); + ObjectHash = HashField.AsObjectAttachment(); + ZEN_ASSERT(!HashField.HasError(), "Object must be followed by a ObjectAttachment with the object hash."); } else { @@ -422,7 +422,7 @@ CbPackage::Save(CbWriter& Writer) const if (Object.CreateIterator()) { Writer.AddObject(Object); - Writer.AddCompactBinaryAttachment(ObjectHash); + Writer.AddObjectAttachment(ObjectHash); } for (const CbAttachment& Attachment : Attachments) { @@ -463,7 +463,7 @@ TEST_CASE("usonpackage") CHECK(MakeMemoryView(WriteStream).EqualBytes(Fields.GetRangeBuffer().GetView())); CHECK(ValidateCompactBinaryRange(MakeMemoryView(WriteStream), CbValidateMode::All) == CbValidateError::None); - CHECK(ValidateCompactBinaryAttachment(MakeMemoryView(WriteStream), CbValidateMode::All) == CbValidateError::None); + CHECK(ValidateObjectAttachment(MakeMemoryView(WriteStream), CbValidateMode::All) == CbValidateError::None); CbAttachment FromFields; FromFields.Load(Fields); @@ -791,7 +791,7 @@ TEST_CASE("usonpackage.serialization") CbWriter Writer; Writer.SetName("Level3"); Writer.BeginArray(); - Writer.AddCompactBinaryAttachment(Level3Hash); + Writer.AddObjectAttachment(Level3Hash); Writer.EndArray(); Level2 = Writer.Save().AsArray(); } @@ -801,7 +801,7 @@ TEST_CASE("usonpackage.serialization") { CbWriter Writer; Writer.BeginObject(); - Writer.SetName("Level2").AddCompactBinaryAttachment(Level2Hash); + Writer.SetName("Level2").AddObjectAttachment(Level2Hash); Writer.EndObject(); Level1 = Writer.Save().AsObject(); } @@ -858,13 +858,13 @@ TEST_CASE("usonpackage.serialization") { CbWriter Writer; Writer.AddBinary(Level2.GetBuffer()); - Writer.AddCompactBinaryAttachment(Level2Hash); + Writer.AddObjectAttachment(Level2Hash); Writer.AddBinary(Level4); Writer.AddBinaryAttachment(Level4Hash); Writer.AddObject(Level1); - Writer.AddCompactBinaryAttachment(Level1Hash); + Writer.AddObjectAttachment(Level1Hash); Writer.AddBinary(Level3.GetBuffer()); - Writer.AddCompactBinaryAttachment(Level3Hash); + Writer.AddObjectAttachment(Level3Hash); Writer.AddNull(); CbFieldIterator Fields = Writer.Save(); @@ -909,15 +909,15 @@ TEST_CASE("usonpackage.serialization") CbFieldIterator Saved = Writer.Save(); CHECK(Saved.AsObject().Equals(Level1)); ++Saved; - CHECK(Saved.AsCompactBinaryAttachment() == Level1Hash); + CHECK(Saved.AsObjectAttachment() == Level1Hash); ++Saved; CHECK(Saved.AsBinaryView().EqualBytes(Level2.GetView())); ++Saved; - CHECK(Saved.AsCompactBinaryAttachment() == Level2Hash); + CHECK(Saved.AsObjectAttachment() == Level2Hash); ++Saved; CHECK(Saved.AsBinaryView().EqualBytes(Level3.GetView())); ++Saved; - CHECK(Saved.AsCompactBinaryAttachment() == Level3Hash); + CHECK(Saved.AsObjectAttachment() == Level3Hash); ++Saved; CHECK(Saved.AsBinaryView().EqualBytes(Level4.GetView())); ++Saved; diff --git a/zencore/compactbinaryvalidation.cpp b/zencore/compactbinaryvalidation.cpp index 51ed31e95..0d4283550 100644 --- a/zencore/compactbinaryvalidation.cpp +++ b/zencore/compactbinaryvalidation.cpp @@ -361,7 +361,7 @@ ValidateCbField(MemoryView& View, CbValidateMode Mode, CbValidateError& Error, c case CbFieldType::Float64: ValidateCbFloat64(View, Mode, Error); break; - case CbFieldType::CompactBinaryAttachment: + case CbFieldType::ObjectAttachment: case CbFieldType::BinaryAttachment: case CbFieldType::Hash: ValidateFixedPayload(20); @@ -509,7 +509,7 @@ ValidateCompactBinaryRange(MemoryView View, CbValidateMode Mode) } CbValidateError -ValidateCompactBinaryAttachment(MemoryView View, CbValidateMode Mode) +ValidateObjectAttachment(MemoryView View, CbValidateMode Mode) { CbValidateError Error = CbValidateError::None; if (EnumHasAnyFlags(Mode, CbValidateMode::All)) diff --git a/zencore/include/zencore/compactbinary.h b/zencore/include/zencore/compactbinary.h index 1d5c154bb..2a4d250cb 100644 --- a/zencore/include/zencore/compactbinary.h +++ b/zencore/include/zencore/compactbinary.h @@ -184,11 +184,11 @@ enum class CbFieldType : uint8_t BoolTrue = 0x0d, /** - * CompactBinaryAttachment is a reference to a compact binary attachment stored externally. + * ObjectAttachment is a reference to a compact binary attachment stored externally. * * Payload is a 160-bit hash digest of the referenced compact binary data. */ - CompactBinaryAttachment = 0x0e, + ObjectAttachment = 0x0e, /** * BinaryAttachment is a reference to a binary attachment stored externally. * @@ -297,9 +297,9 @@ public: static constexpr inline bool IsFloat(CbFieldType Type) { return (Type & FloatMask) == FloatBase; } static constexpr inline bool IsBool(CbFieldType Type) { return (Type & BoolMask) == BoolBase; } - static constexpr inline bool IsCompactBinaryAttachment(CbFieldType Type) + static constexpr inline bool IsObjectAttachment(CbFieldType Type) { - return GetType(Type) == CbFieldType::CompactBinaryAttachment; + return GetType(Type) == CbFieldType::ObjectAttachment; } static constexpr inline bool IsBinaryAttachment(CbFieldType Type) { return GetType(Type) == CbFieldType::BinaryAttachment; } static constexpr inline bool IsAttachment(CbFieldType Type) { return (Type & AttachmentMask) == AttachmentBase; } @@ -310,7 +310,7 @@ public: { case CbFieldType::Hash: case CbFieldType::BinaryAttachment: - case CbFieldType::CompactBinaryAttachment: + case CbFieldType::ObjectAttachment: return true; default: return false; @@ -431,7 +431,7 @@ public: ZENCORE_API bool AsBool(bool bDefault = false); /** Access the field as a hash referencing a compact binary attachment. Returns the provided default on error. */ - ZENCORE_API IoHash AsCompactBinaryAttachment(const IoHash& Default = IoHash()); + ZENCORE_API IoHash AsObjectAttachment(const IoHash& Default = IoHash()); /** Access the field as a hash referencing a binary attachment. Returns the provided default on error. */ ZENCORE_API IoHash AsBinaryAttachment(const IoHash& Default = IoHash()); /** Access the field as a hash referencing an attachment. Returns the provided default on error. */ @@ -483,7 +483,7 @@ public: constexpr inline bool IsFloat() const { return CbFieldTypeOps::IsFloat(Type); } constexpr inline bool IsBool() const { return CbFieldTypeOps::IsBool(Type); } - constexpr inline bool IsCompactBinaryAttachment() const { return CbFieldTypeOps::IsCompactBinaryAttachment(Type); } + constexpr inline bool IsObjectAttachment() const { return CbFieldTypeOps::IsObjectAttachment(Type); } constexpr inline bool IsBinaryAttachment() const { return CbFieldTypeOps::IsBinaryAttachment(Type); } constexpr inline bool IsAttachment() const { return CbFieldTypeOps::IsAttachment(Type); } diff --git a/zencore/include/zencore/compactbinarybuilder.h b/zencore/include/zencore/compactbinarybuilder.h index 83d4309f7..f2bf773bf 100644 --- a/zencore/include/zencore/compactbinarybuilder.h +++ b/zencore/include/zencore/compactbinarybuilder.h @@ -279,12 +279,12 @@ public: ZENCORE_API void AddBool(bool bValue); /** Write a field referencing a compact binary attachment by its hash. */ - inline void AddCompactBinaryAttachment(std::string_view Name, const IoHash& Value) + inline void AddObjectAttachment(std::string_view Name, const IoHash& Value) { SetName(Name); - AddCompactBinaryAttachment(Value); + AddObjectAttachment(Value); } - ZENCORE_API void AddCompactBinaryAttachment(const IoHash& Value); + ZENCORE_API void AddObjectAttachment(const IoHash& Value); /** Write a field referencing a binary attachment by its hash. */ inline void AddBinaryAttachment(std::string_view Name, const IoHash& Value) diff --git a/zencore/include/zencore/compactbinaryvalidation.h b/zencore/include/zencore/compactbinaryvalidation.h index 3a3f432be..656eb3d96 100644 --- a/zencore/include/zencore/compactbinaryvalidation.h +++ b/zencore/include/zencore/compactbinaryvalidation.h @@ -169,7 +169,7 @@ ZENCORE_API CbValidateError ValidateCompactBinaryRange(MemoryView View, CbValida * @param Mode A combination of the flags for the types of validation to perform. * @return None on success, otherwise the flags for the types of errors that were detected. */ -ZENCORE_API CbValidateError ValidateCompactBinaryAttachment(MemoryView View, CbValidateMode Mode); +ZENCORE_API CbValidateError ValidateObjectAttachment(MemoryView View, CbValidateMode Mode); /** * Validate the compact binary package pointed to by the view as specified by the mode flags. |