diff --git a/Code/Framework/AzCore/AzCore/DOM/Backends/JSON/JsonSerializationUtils.cpp b/Code/Framework/AzCore/AzCore/DOM/Backends/JSON/JsonSerializationUtils.cpp index 104082ce54..8d8c8463ff 100644 --- a/Code/Framework/AzCore/AzCore/DOM/Backends/JSON/JsonSerializationUtils.cpp +++ b/Code/Framework/AzCore/AzCore/DOM/Backends/JSON/JsonSerializationUtils.cpp @@ -70,11 +70,11 @@ namespace AZ::Dom::Json { if (lifetime == Lifetime::Temporary) { - CurrentValue().SetString(value.data(), static_cast(value.length()), m_allocator); + CurrentValue().SetString(value.data(), aznumeric_cast(value.length()), m_allocator); } else { - CurrentValue().SetString(value.data(), static_cast(value.length())); + CurrentValue().SetString(value.data(), aznumeric_cast(value.length())); } return FinishWrite(); } @@ -102,7 +102,7 @@ namespace AZ::Dom::Json if (m_entryStack.front().m_entryCount != attributeCount) { - return FormatVisitorFailure( + return VisitorFailure( VisitorErrorCode::InternalError, "EndObject: Expected %lu attributes but received %lu attributes instead", attributeCount, m_entryStack.front().m_entryCount); } @@ -122,11 +122,11 @@ namespace AZ::Dom::Json AZ_Assert(m_entryStack.front().m_isObject, "Attempted to push a key to an array"); if (lifetime == Lifetime::Persistent) { - m_entryStack.front().m_key.SetString(key.data(), static_cast(key.size())); + m_entryStack.front().m_key.SetString(key.data(), aznumeric_cast(key.size())); } else { - m_entryStack.front().m_key.SetString(key.data(), static_cast(key.size()), m_allocator); + m_entryStack.front().m_key.SetString(key.data(), aznumeric_cast(key.size()), m_allocator); } return VisitorSuccess(); } @@ -154,7 +154,7 @@ namespace AZ::Dom::Json if (m_entryStack.front().m_entryCount != elementCount) { - return FormatVisitorFailure( + return VisitorFailure( VisitorErrorCode::InternalError, "EndArray: Expected %lu elements but received %lu elements instead", elementCount, m_entryStack.front().m_entryCount); } @@ -250,7 +250,7 @@ namespace AZ::Dom::Json Result String(AZStd::string_view value, Lifetime lifetime) override { const bool shouldCopy = lifetime == Lifetime::Temporary; - return CheckWrite(m_writer.String(value.data(), static_cast(value.size()), shouldCopy)); + return CheckWrite(m_writer.String(value.data(), aznumeric_cast(value.size()), shouldCopy)); } Result StartObject() override @@ -260,7 +260,7 @@ namespace AZ::Dom::Json Result EndObject(AZ::u64 attributeCount) override { - return CheckWrite(m_writer.EndObject(static_cast(attributeCount))); + return CheckWrite(m_writer.EndObject(aznumeric_cast(attributeCount))); } Result Key(AZ::Name key) override @@ -271,7 +271,7 @@ namespace AZ::Dom::Json Result RawKey(AZStd::string_view key, Lifetime lifetime) override { const bool shouldCopy = lifetime == Lifetime::Temporary; - return CheckWrite(m_writer.Key(key.data(), static_cast(key.size()), shouldCopy)); + return CheckWrite(m_writer.Key(key.data(), aznumeric_cast(key.size()), shouldCopy)); } Result StartArray() override @@ -281,7 +281,7 @@ namespace AZ::Dom::Json Result EndArray(AZ::u64 elementCount) override { - return CheckWrite(m_writer.EndArray(static_cast(elementCount))); + return CheckWrite(m_writer.EndArray(aznumeric_cast(elementCount))); } private: @@ -323,12 +323,12 @@ namespace AZ::Dom::Json bool RapidJsonReadHandler::Int(int i) { - return CheckResult(m_visitor->Int64(static_cast(i))); + return CheckResult(m_visitor->Int64(aznumeric_cast(i))); } bool RapidJsonReadHandler::Uint(unsigned i) { - return CheckResult(m_visitor->Uint64(static_cast(i))); + return CheckResult(m_visitor->Uint64(aznumeric_cast(i))); } bool RapidJsonReadHandler::Int64(int64_t i) @@ -472,7 +472,7 @@ namespace AZ::Dom::Json while (!entryStack.empty()) { - const auto currentEntry = entryStack.top(); + const Entry currentEntry = entryStack.top(); entryStack.pop(); Visitor::Result result = AZ::Success(); @@ -507,7 +507,7 @@ namespace AZ::Dom::Json for (auto it = currentValue.MemberEnd(); it != currentValue.MemberBegin(); --it) { auto entry = (it - 1); - const AZStd::string_view key(entry->name.GetString(), static_cast(entry->name.GetStringLength())); + const AZStd::string_view key(entry->name.GetString(), aznumeric_cast(entry->name.GetStringLength())); entryStack.push(&entry->value); entryStack.push(key); } @@ -524,7 +524,7 @@ namespace AZ::Dom::Json break; case rapidjson::kStringType: result = visitor.String( - AZStd::string_view(currentValue.GetString(), static_cast(currentValue.GetStringLength())), + AZStd::string_view(currentValue.GetString(), aznumeric_cast(currentValue.GetStringLength())), lifetime); break; case rapidjson::kNumberType: diff --git a/Code/Framework/AzCore/AzCore/DOM/DomVisitor.cpp b/Code/Framework/AzCore/AzCore/DOM/DomVisitor.cpp index ad314da385..d5190cbbac 100644 --- a/Code/Framework/AzCore/AzCore/DOM/DomVisitor.cpp +++ b/Code/Framework/AzCore/AzCore/DOM/DomVisitor.cpp @@ -60,11 +60,6 @@ namespace AZ::Dom return AZ::Failure(VisitorError(code)); } - Visitor::Result Visitor::VisitorFailure(VisitorErrorCode code, AZStd::string additionalInfo) - { - return AZ::Failure(VisitorError(code, AZStd::move(additionalInfo))); - } - Visitor::Result Visitor::VisitorFailure(VisitorError error) { return AZ::Failure(error); diff --git a/Code/Framework/AzCore/AzCore/DOM/DomVisitor.h b/Code/Framework/AzCore/AzCore/DOM/DomVisitor.h index f36ad8d827..c0da56036e 100644 --- a/Code/Framework/AzCore/AzCore/DOM/DomVisitor.h +++ b/Code/Framework/AzCore/AzCore/DOM/DomVisitor.h @@ -227,17 +227,15 @@ namespace AZ::Dom //! Helper method, constructs a failure \ref Result with the specified code. static Result VisitorFailure(VisitorErrorCode code); - //! Helper method, constructs a failure \ref Result with the specified code and supplemental info. - static Result VisitorFailure(VisitorErrorCode code, AZStd::string additionalInfo); //! Helper method, constructs a failure \ref Result with the specified error. static Result VisitorFailure(VisitorError error); //! Helper method, constructs a failure \ref Result with the specified code and supplemental info specified by a format string //! and its arguments. template - static Result FormatVisitorFailure(VisitorErrorCode code, TArgs... formatArgs) + static Result VisitorFailure(VisitorErrorCode code, TArgs... formatArgs) { - return VisitorFailure(code, AZStd::string::format(formatArgs...)); + return AZ::Failure(VisitorError(code, AZStd::string::format(formatArgs...))); } //! Helper method, constructs a success \ref Result.