diff --git a/Code/Framework/AzCore/AzCore/DOM/Backends/JSON/JsonBackend.h b/Code/Framework/AzCore/AzCore/DOM/Backends/JSON/JsonBackend.h index 45825ff92d..1023796f61 100644 --- a/Code/Framework/AzCore/AzCore/DOM/Backends/JSON/JsonBackend.h +++ b/Code/Framework/AzCore/AzCore/DOM/Backends/JSON/JsonBackend.h @@ -10,6 +10,7 @@ #include #include +#include namespace AZ::Dom { @@ -32,8 +33,9 @@ namespace AZ::Dom return Json::VisitSerializedJsonInPlace(buffer, visitor); } - Visitor::Result WriteToStream(AZ::IO::GenericStream& stream, WriteCallback callback) override + Visitor::Result WriteToBuffer(AZStd::string& buffer, WriteCallback callback) { + AZ::IO::ByteContainerStream stream{ &buffer }; AZStd::unique_ptr visitor = Json::CreateJsonStreamWriter(stream, WriteFormat); return callback(*visitor); } diff --git a/Code/Framework/AzCore/AzCore/DOM/DomBackend.h b/Code/Framework/AzCore/AzCore/DOM/DomBackend.h index 6c9c40ef0e..2e4ccf8f3e 100644 --- a/Code/Framework/AzCore/AzCore/DOM/DomBackend.h +++ b/Code/Framework/AzCore/AzCore/DOM/DomBackend.h @@ -38,7 +38,7 @@ namespace AZ::Dom //! A callback that accepts a Visitor, making DOM calls to inform the serializer, and returns an //! aggregate error code to indicate whether or not the operation succeeded. using WriteCallback = AZStd::function; - //! Attempt to write a value to a stream using a write callback. - virtual Visitor::Result WriteToStream(AZ::IO::GenericStream& stream, WriteCallback callback) = 0; + //! Attempt to write a value to the specified string using a write callback. + virtual Visitor::Result WriteToBuffer(AZStd::string& buffer, WriteCallback callback) = 0; }; } // namespace AZ::Dom diff --git a/Code/Framework/AzCore/AzCore/DOM/DomUtils.cpp b/Code/Framework/AzCore/AzCore/DOM/DomUtils.cpp index ca27b177bd..9751b9cecc 100644 --- a/Code/Framework/AzCore/AzCore/DOM/DomUtils.cpp +++ b/Code/Framework/AzCore/AzCore/DOM/DomUtils.cpp @@ -21,10 +21,4 @@ namespace AZ::Dom::Utils { return backend.ReadFromBufferInPlace(string.data(), string.size(), visitor); } - - Visitor::Result WriteToString(Backend& backend, AZStd::string& buffer, Backend::WriteCallback writeCallback) - { - AZ::IO::ByteContainerStream stream{ &buffer }; - return backend.WriteToStream(stream, writeCallback); - } } diff --git a/Code/Framework/AzCore/AzCore/DOM/DomUtils.h b/Code/Framework/AzCore/AzCore/DOM/DomUtils.h index cd64d2e107..84a6eb5687 100644 --- a/Code/Framework/AzCore/AzCore/DOM/DomUtils.h +++ b/Code/Framework/AzCore/AzCore/DOM/DomUtils.h @@ -14,6 +14,4 @@ namespace AZ::Dom::Utils { Visitor::Result ReadFromString(Backend& backend, AZStd::string_view string, AZ::Dom::Lifetime lifetime, Visitor& visitor); Visitor::Result ReadFromStringInPlace(Backend& backend, AZStd::string& string, Visitor& visitor); - - Visitor::Result WriteToString(Backend& backend, AZStd::string& buffer, Backend::WriteCallback writeCallback); } // namespace AZ::Dom::Utils diff --git a/Code/Framework/AzCore/Tests/DOM/DomJsonTests.cpp b/Code/Framework/AzCore/Tests/DOM/DomJsonTests.cpp index b408cd2466..c7af6438cf 100644 --- a/Code/Framework/AzCore/Tests/DOM/DomJsonTests.cpp +++ b/Code/Framework/AzCore/Tests/DOM/DomJsonTests.cpp @@ -71,7 +71,7 @@ namespace AZ::Dom::Tests { AZStd::string serializedDocument; JsonBackend backend; - auto result = Dom::Utils::WriteToString(backend, serializedDocument, visitDocumentFn); + auto result = backend.WriteToBuffer(serializedDocument, visitDocumentFn); EXPECT_TRUE(result.IsSuccess()); EXPECT_EQ(canonicalSerializedDocument, serializedDocument); } @@ -92,8 +92,8 @@ namespace AZ::Dom::Tests { AZStd::string serializedDocument; JsonBackend backend; - auto result = Dom::Utils::WriteToString( - backend, serializedDocument, + auto result = backend.WriteToBuffer( + serializedDocument, [&backend, &canonicalSerializedDocument](AZ::Dom::Visitor& visitor) { return Dom::Utils::ReadFromString(backend, canonicalSerializedDocument, Lifetime::Temporary, visitor);