Merge branch 'main' into mbalfour/spec-6178
This commit is contained in:
@@ -111,7 +111,7 @@ namespace AZ
|
||||
bool loadFileToMemory = Get().ShouldLoadFileToMemory(filename);
|
||||
int assetMode = loadFileToMemory ? AASSET_MODE_BUFFER : AASSET_MODE_UNKNOWN;
|
||||
|
||||
asset = AAssetManager_open(Utils::GetAssetManager(), Utils::StripApkPrefix(filename), assetMode);
|
||||
asset = AAssetManager_open(Utils::GetAssetManager(), Utils::StripApkPrefix(filename).c_str(), assetMode);
|
||||
|
||||
if (asset != nullptr)
|
||||
{
|
||||
@@ -192,7 +192,7 @@ namespace AZ
|
||||
{
|
||||
buf->m_offset = buf->m_totalSize - offset;
|
||||
}
|
||||
|
||||
|
||||
if (buf->m_offset > buf->m_totalSize)
|
||||
{
|
||||
buf->m_offset = buf->m_totalSize;
|
||||
@@ -320,12 +320,19 @@ namespace AZ
|
||||
|
||||
bool APKFileHandler::DirectoryOrFileExists(const char* path)
|
||||
{
|
||||
ANDROID_IO_PROFILE_SECTION_ARGS("APK DirOrFileexists");
|
||||
ANDROID_IO_PROFILE_SECTION_ARGS("APK DirOrFileExists");
|
||||
|
||||
AZ::IO::PathView insideApkPathView(Utils::StripApkPrefix(path));
|
||||
AZ::IO::FixedMaxPath insideApkPath(Utils::StripApkPrefix(path));
|
||||
|
||||
AZ::IO::FixedMaxPathString filename{ insideApkPathView.Filename().Native() };
|
||||
AZ::IO::FixedMaxPathString pathToFile{ insideApkPathView.ParentPath().Native() };
|
||||
// Check for the case where the input path is equal to the APK Assets Prefix of /APK
|
||||
// In that case the directory is the "root" of APK assets in which case the directory exist
|
||||
if (insideApkPath.empty() && Utils::IsApkPath(path))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
AZ::IO::FixedMaxPathString filename{ insideApkPath.Filename().Native() };
|
||||
AZ::IO::FixedMaxPathString pathToFile{ insideApkPath.ParentPath().Native() };
|
||||
bool foundFile = false;
|
||||
|
||||
ParseDirectory(pathToFile.c_str(), [&](const char* name)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <AzCore/Debug/Trace.h>
|
||||
|
||||
#include <AzCore/Memory/OSAllocator.h>
|
||||
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -28,9 +28,9 @@ namespace AZ
|
||||
namespace
|
||||
{
|
||||
////////////////////////////////////////////////////////////////
|
||||
const char* GetApkAssetsPrefix()
|
||||
constexpr const char* GetApkAssetsPrefix()
|
||||
{
|
||||
return "/APK/";
|
||||
return "/APK";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,19 +104,14 @@ namespace AZ
|
||||
////////////////////////////////////////////////////////////////
|
||||
bool IsApkPath(const char* filePath)
|
||||
{
|
||||
return (strncmp(filePath, GetApkAssetsPrefix(), 4) == 0); // +3 for "APK", +1 for '/' starting slash
|
||||
return AZ::IO::PathView(filePath).IsRelativeTo(AZ::IO::PathView(GetApkAssetsPrefix()));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
const char* StripApkPrefix(const char* filePath)
|
||||
AZ::IO::FixedMaxPath StripApkPrefix(const char* filePath)
|
||||
{
|
||||
const int prefixLength = 5; // +3 for "APK", +2 for '/' on either end
|
||||
if (!IsApkPath(filePath))
|
||||
{
|
||||
return filePath;
|
||||
}
|
||||
|
||||
return filePath + prefixLength;
|
||||
constexpr AZ::IO::PathView apkPrefixView = GetApkAssetsPrefix();
|
||||
return AZ::IO::PathView(filePath).LexicallyProximate(apkPrefixView);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
@@ -130,7 +125,7 @@ namespace AZ
|
||||
// first check to see if they are in public storage (application specific)
|
||||
const char* publicAppStorage = GetAppPublicStoragePath();
|
||||
|
||||
OSString path = OSString::format("%s/bootstrap.cfg", publicAppStorage);
|
||||
OSString path = OSString::format("%s/engine.json", publicAppStorage);
|
||||
AZ_TracePrintf("Android::Utils", "Searching for %s\n", path.c_str());
|
||||
|
||||
FILE* f = fopen(path.c_str(), "r");
|
||||
@@ -145,7 +140,7 @@ namespace AZ
|
||||
AAssetManager* mgr = GetAssetManager();
|
||||
if (mgr)
|
||||
{
|
||||
AAsset* asset = AAssetManager_open(mgr, "bootstrap.cfg", AASSET_MODE_UNKNOWN);
|
||||
AAsset* asset = AAssetManager_open(mgr, "engine.json", AASSET_MODE_UNKNOWN);
|
||||
if (asset)
|
||||
{
|
||||
AAsset_close(asset);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/IO/Path/Path_fwd.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
#include <jni.h>
|
||||
@@ -55,7 +56,7 @@ namespace AZ
|
||||
const char* GetObbStoragePath();
|
||||
|
||||
//! Get the dot separated package name for the current application.
|
||||
//! e.g. com.lumberyard.samples for SamplesProject
|
||||
//! e.g. com.o3de.samples for SamplesProject
|
||||
const char* GetPackageName();
|
||||
|
||||
//! Get the app version code (android:versionCode in the manifest).
|
||||
@@ -70,7 +71,7 @@ namespace AZ
|
||||
//! Will first check to verify the argument is an apk asset path and if so
|
||||
//! will strip the prefix from the path.
|
||||
//! \return The pointer position of the relative asset path
|
||||
const char* StripApkPrefix(const char* filePath);
|
||||
AZ::IO::FixedMaxPath StripApkPrefix(const char* filePath);
|
||||
|
||||
//! Searches application storage and the APK for bootstrap.cfg. Will return nullptr
|
||||
//! if bootstrap.cfg is not found.
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
#include <AzCore/Asset/AssetManager.h>
|
||||
#include <AzCore/Asset/AssetJsonSerializer.h>
|
||||
#include <AzCore/Serialization/Json/JsonSerialization.h>
|
||||
#include <AzCore/Serialization/Json/StackedString.h>
|
||||
@@ -107,7 +107,8 @@ namespace AZ
|
||||
result = ContinueLoading(&id, azrtti_typeid<AssetId>(), it->value, context);
|
||||
if (!id.m_guid.IsNull())
|
||||
{
|
||||
*instance = Asset<AssetData>(id, instance->GetType());
|
||||
*instance = AssetManager::Instance().FindOrCreateAsset(id, instance->GetType(), AssetLoadBehavior::NoLoad);
|
||||
|
||||
|
||||
result.Combine(context.Report(result, "Successfully created Asset<T> with id."));
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
/** @file
|
||||
* Header file for the Component base class.
|
||||
* In Lumberyard's component entity system, each component defines a discrete
|
||||
* In Open 3D Engine's component entity system, each component defines a discrete
|
||||
* feature that can be attached to an entity.
|
||||
*/
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace AZ
|
||||
* practice to access other components through EBuses instead of accessing them directly.
|
||||
* For more information, see the
|
||||
* <a href="http://docs.aws.amazon.com/lumberyard/latest/developerguide/component-entity-system-pg-intro.html">Programmer's Guide to Entities and Components</a>
|
||||
* in the Lumberyard Developer Guide.
|
||||
* in the Open 3D Engine Developer Guide.
|
||||
* @return A pointer to the entity. If the component is not attached to any entity,
|
||||
* the return value is a null pointer.
|
||||
*/
|
||||
@@ -426,7 +426,7 @@ namespace AZ
|
||||
|
||||
/**
|
||||
* Describes the properties of the component descriptor event bus.
|
||||
* This bus uses AzTypeInfo::Uuid as the ID for the specific descriptor. Lumberyard allows only one
|
||||
* This bus uses AzTypeInfo::Uuid as the ID for the specific descriptor. Open 3D Engine allows only one
|
||||
* descriptor for each component type. When you call functions on the bus for a specific component
|
||||
* type, you can safely pass only one result variable because aggregating or overwriting results
|
||||
* is impossible.
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <AzCore/Memory/OverrunDetectionAllocator.h>
|
||||
#include <AzCore/Memory/AllocatorManager.h>
|
||||
#include <AzCore/Memory/MallocSchema.h>
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/ObjectStream.h>
|
||||
@@ -174,6 +173,7 @@ namespace AZ
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
//! SettingsRegistry notifier handler which updates relevant registry settings based
|
||||
//! on an update to '/Amazon/AzCore/Bootstrap/project_path' key.
|
||||
struct UpdateProjectSettingsEventHandler
|
||||
@@ -185,66 +185,57 @@ namespace AZ
|
||||
|
||||
void operator()(AZStd::string_view path, AZ::SettingsRegistryInterface::Type)
|
||||
{
|
||||
UpdateProjectSpecializationInRegistry(path);
|
||||
using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString;
|
||||
const auto projectPathKey = FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
|
||||
AZ::IO::FixedMaxPath newProjectPath;
|
||||
if (SettingsRegistryMergeUtils::IsPathAncestorDescendantOrEqual(projectPathKey, path)
|
||||
&& m_registry.Get(newProjectPath.Native(), projectPathKey) && newProjectPath != m_oldProjectPath)
|
||||
{
|
||||
UpdateProjectSettingsFromProjectPath(AZ::IO::PathView(newProjectPath));
|
||||
}
|
||||
|
||||
const auto projectNameKey = FixedValueString(AZ::SettingsRegistryMergeUtils::ProjectSettingsRootKey) + "/project_name";
|
||||
FixedValueString newProjectName;
|
||||
if (SettingsRegistryMergeUtils::IsPathAncestorDescendantOrEqual(projectNameKey, path)
|
||||
&& m_registry.Get(newProjectName, projectNameKey) && newProjectName != m_oldProjectName)
|
||||
{
|
||||
UpdateProjectSpecializationFromProjectName(newProjectName);
|
||||
}
|
||||
}
|
||||
|
||||
//! Add the project name as a specialization underneath the /Amazon/AzCore/Settings/Specializations path
|
||||
//! and remove the current project name specialization if one exists.
|
||||
void UpdateProjectSpecializationInRegistry(AZStd::string_view path)
|
||||
void UpdateProjectSpecializationFromProjectName(AZStd::string_view newProjectName)
|
||||
{
|
||||
auto projectPathKey =
|
||||
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey)
|
||||
+ "/project_path";
|
||||
if (path == projectPathKey)
|
||||
{
|
||||
AZ::SettingsRegistryInterface::FixedValueString newProjectPath;
|
||||
if (m_registry.Get(newProjectPath, path) && !newProjectPath.empty())
|
||||
{
|
||||
// Make the path absolute by appending to app root, in case project path is relative.
|
||||
// If the project path is already absolute it will remain the same.
|
||||
// If we turn it from a relative path to an absolute path, write-back the absolute path to the registry.
|
||||
AZ::IO::FixedMaxPath projectPath = AZ::SettingsRegistryMergeUtils::FindEngineRoot(m_registry) / newProjectPath;
|
||||
if (projectPath.Compare(newProjectPath.c_str()))
|
||||
{
|
||||
m_registry.Set(path, projectPath.Native());
|
||||
}
|
||||
using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString;
|
||||
// Add the project_name as a specialization for loading the build system dependency .setreg files
|
||||
auto newProjectNameSpecialization = FixedValueString::format("%s/%.*s", AZ::SettingsRegistryMergeUtils::SpecializationsRootKey,
|
||||
aznumeric_cast<int>(newProjectName.size()), newProjectName.data());
|
||||
auto oldProjectNameSpecialization = FixedValueString::format("%s/%s", AZ::SettingsRegistryMergeUtils::SpecializationsRootKey,
|
||||
m_oldProjectName.c_str());
|
||||
m_registry.Remove(oldProjectNameSpecialization);
|
||||
m_oldProjectName = newProjectName;
|
||||
m_registry.Set(newProjectNameSpecialization, true);
|
||||
}
|
||||
|
||||
// Merge the project.json file into settings registry under ProjectSettingsRootKey path.
|
||||
AZ::IO::FixedMaxPath projectMetadataFile{ projectPath };
|
||||
projectMetadataFile /= "project.json";
|
||||
m_registry.MergeSettingsFile(projectMetadataFile.Native(),
|
||||
AZ::SettingsRegistryInterface::Format::JsonMergePatch, AZ::SettingsRegistryMergeUtils::ProjectSettingsRootKey);
|
||||
void UpdateProjectSettingsFromProjectPath(AZ::IO::PathView newProjectPath)
|
||||
{
|
||||
// Update old Project path before attempting to merge in new Settings Registry values in order to prevent recursive calls
|
||||
m_oldProjectPath = newProjectPath;
|
||||
|
||||
// Get the 'project_name' value from what was in the 'project.json' file...
|
||||
auto projectNameKey =
|
||||
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::ProjectSettingsRootKey)
|
||||
+ "/project_name";
|
||||
// Merge the project.json file into settings registry under ProjectSettingsRootKey path.
|
||||
AZ::IO::FixedMaxPath projectMetadataFile{ AZ::SettingsRegistryMergeUtils::FindEngineRoot(m_registry) / newProjectPath };
|
||||
projectMetadataFile /= "project.json";
|
||||
m_registry.MergeSettingsFile(projectMetadataFile.Native(),
|
||||
AZ::SettingsRegistryInterface::Format::JsonMergePatch, AZ::SettingsRegistryMergeUtils::ProjectSettingsRootKey);
|
||||
|
||||
AZ::SettingsRegistryInterface::FixedValueString projectSpecialization;
|
||||
if (m_registry.Get(projectSpecialization, projectNameKey))
|
||||
{
|
||||
auto specializationKey = AZ::SettingsRegistryInterface::FixedValueString::format(
|
||||
"%s/%s", AZ::SettingsRegistryMergeUtils::SpecializationsRootKey, projectSpecialization.c_str());
|
||||
if (m_currentSpecialization != specializationKey)
|
||||
{
|
||||
m_registry.Set(specializationKey, true);
|
||||
if (!m_currentSpecialization.empty())
|
||||
{
|
||||
// Remove the previous Project Name from the specialization path if it was set.
|
||||
m_registry.Remove(m_currentSpecialization);
|
||||
}
|
||||
m_currentSpecialization = specializationKey;
|
||||
|
||||
// Update all the runtime file paths based on the new "project_path" value.
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(m_registry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Update all the runtime file paths based on the new "project_path" value.
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(m_registry);
|
||||
}
|
||||
|
||||
private:
|
||||
AZ::SettingsRegistryInterface::FixedValueString m_currentSpecialization;
|
||||
AZ::IO::FixedMaxPath m_oldProjectPath;
|
||||
AZ::SettingsRegistryInterface::FixedValueString m_oldProjectName;
|
||||
AZ::SettingsRegistryInterface& m_registry;
|
||||
};
|
||||
|
||||
@@ -424,7 +415,7 @@ namespace AZ
|
||||
// Add the Command Line arguments into the SettingsRegistry
|
||||
SettingsRegistryMergeUtils::StoreCommandLineToRegistry(*m_settingsRegistry, m_commandLine);
|
||||
|
||||
// Merge Command Line arguments
|
||||
// Merge Command Line arguments
|
||||
constexpr bool executeRegDumpCommands = false;
|
||||
SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(*m_settingsRegistry, m_commandLine, executeRegDumpCommands);
|
||||
|
||||
@@ -1395,10 +1386,7 @@ namespace AZ
|
||||
//=========================================================================
|
||||
void ComponentApplication::CalculateExecutablePath()
|
||||
{
|
||||
Utils::GetExecutableDirectory(m_exeDirectory.data(), m_exeDirectory.capacity());
|
||||
// Update the size value of the executable directory fixed string to correctly be the length of the null-terminated string stored within it
|
||||
m_exeDirectory.resize_no_construct(AZStd::char_traits<char>::length(m_exeDirectory.data()));
|
||||
m_exeDirectory.push_back(AZ_CORRECT_FILESYSTEM_SEPARATOR);
|
||||
m_exeDirectory = Utils::GetExecutableDirectory();
|
||||
}
|
||||
|
||||
void ComponentApplication::CalculateAppRoot()
|
||||
@@ -1406,19 +1394,12 @@ namespace AZ
|
||||
if (AZStd::optional<AZ::StringFunc::Path::FixedString> appRootPath = Utils::GetDefaultAppRootPath(); appRootPath)
|
||||
{
|
||||
m_appRoot = AZStd::move(*appRootPath);
|
||||
if (!m_appRoot.empty() && !m_appRoot.ends_with(AZ_CORRECT_FILESYSTEM_SEPARATOR))
|
||||
{
|
||||
m_appRoot.push_back(AZ_CORRECT_FILESYSTEM_SEPARATOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ComponentApplication::CalculateEngineRoot()
|
||||
{
|
||||
if (m_engineRoot = AZ::SettingsRegistryMergeUtils::FindEngineRoot(*m_settingsRegistry).Native(); !m_engineRoot.empty())
|
||||
{
|
||||
m_engineRoot.push_back(AZ_CORRECT_FILESYSTEM_SEPARATOR);
|
||||
}
|
||||
m_engineRoot = AZ::SettingsRegistryMergeUtils::FindEngineRoot(*m_settingsRegistry).Native();
|
||||
}
|
||||
|
||||
void ComponentApplication::ResolveModulePath([[maybe_unused]] AZ::OSString& modulePath)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <AzCore/Module/DynamicModuleHandle.h>
|
||||
#include <AzCore/Module/ModuleManager.h>
|
||||
#include <AzCore/Outcome/Outcome.h>
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/RTTI/ReflectionManager.h>
|
||||
@@ -392,9 +393,9 @@ namespace AZ
|
||||
void* m_fixedMemoryBlock{ nullptr }; //!< Pointer to the memory block allocator, so we can free it OnDestroy.
|
||||
IAllocatorAllocate* m_osAllocator{ nullptr };
|
||||
EntitySetType m_entities;
|
||||
AZ::IO::FixedMaxPathString m_exeDirectory;
|
||||
AZ::IO::FixedMaxPathString m_engineRoot;
|
||||
AZ::IO::FixedMaxPathString m_appRoot;
|
||||
AZ::IO::FixedMaxPath m_exeDirectory;
|
||||
AZ::IO::FixedMaxPath m_engineRoot;
|
||||
AZ::IO::FixedMaxPath m_appRoot;
|
||||
|
||||
AZ::SettingsRegistryInterface::NotifyEventHandler m_projectChangedHandler;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
/** @file
|
||||
* Header file for the Entity class.
|
||||
* In Lumberyard's component entity system, an entity is an addressable container for
|
||||
* In Open 3D Engine's component entity system, an entity is an addressable container for
|
||||
* a group of components. The entity represents the functionality and properties of an
|
||||
* object within your game.
|
||||
*/
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* Header file for internal EBus classes.
|
||||
* For more information about EBuses, see AZ::EBus and AZ::EBusTraits in this guide and
|
||||
* [Event Bus](http://docs.aws.amazon.com/lumberyard/latest/developerguide/asset-pipeline-ebus.html)
|
||||
* in the *Lumberyard Developer Guide*.
|
||||
* in the *Open 3D Engine Developer Guide*.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
/**
|
||||
* @file
|
||||
* Header file for event bus (EBus), a general-purpose communication system
|
||||
* that Lumberyard uses to dispatch notifications and receive requests.
|
||||
* that Open 3D Engine uses to dispatch notifications and receive requests.
|
||||
* EBuses are configurable and support many different use cases.
|
||||
* For more information about %EBuses, see AZ::EBus in this guide and
|
||||
* [Event Bus](http://docs.aws.amazon.com/lumberyard/latest/developerguide/asset-pipeline-ebus.html)
|
||||
* in the *Lumberyard Developer Guide*.
|
||||
* in the *Open 3D Engine Developer Guide*.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -70,7 +70,7 @@ namespace AZ
|
||||
*
|
||||
* For more information about %EBuses, see EBus in this guide and
|
||||
* [Event Bus](http://docs.aws.amazon.com/lumberyard/latest/developerguide/asset-pipeline-ebus.html)
|
||||
* in the *Lumberyard Developer Guide*.
|
||||
* in the *Open 3D Engine Developer Guide*.
|
||||
*/
|
||||
struct EBusTraits
|
||||
{
|
||||
@@ -256,7 +256,7 @@ namespace AZ
|
||||
|
||||
/**
|
||||
* Event buses (EBuses) are a general-purpose communication system
|
||||
* that Lumberyard uses to dispatch notifications and receive requests.
|
||||
* that Open 3D Engine uses to dispatch notifications and receive requests.
|
||||
*
|
||||
* @tparam Interface A class whose virtual functions define the events
|
||||
* dispatched or received by the %EBus.
|
||||
@@ -268,7 +268,7 @@ namespace AZ
|
||||
* For more information about EBuses, see
|
||||
* [Event Bus](http://docs.aws.amazon.com/lumberyard/latest/developerguide/asset-pipeline-ebus.html)
|
||||
* and [Components and EBuses: Best Practices ](http://docs.aws.amazon.com/lumberyard/latest/developerguide/component-entity-system-pg-components-ebuses-best-practices.html)
|
||||
* in the *Lumberyard Developer Guide*.
|
||||
* in the *Open 3D Engine Developer Guide*.
|
||||
*
|
||||
* ## How Components Use EBuses
|
||||
* Components commonly use EBuses in two ways: to dispatch events or to handle requests.
|
||||
|
||||
@@ -96,8 +96,8 @@ namespace AZ::IO
|
||||
constexpr int Compare(const value_type* pathString) const noexcept;
|
||||
|
||||
// decomposition
|
||||
//! Given a windows path of "C:\lumberyard\foo\bar\name.txt" and a posix path of
|
||||
//! "/lumberyard/foo/bar/name.txt"
|
||||
//! Given a windows path of "C:\O3DE\foo\bar\name.txt" and a posix path of
|
||||
//! "/O3DE/foo/bar/name.txt"
|
||||
//! The following functions return the following
|
||||
|
||||
//! Returns the root name part of the path. if it has one.
|
||||
@@ -114,10 +114,10 @@ namespace AZ::IO
|
||||
constexpr PathView RootPath() const;
|
||||
//! Returns the relative path portion of the path.
|
||||
//! This contains the path parts after the root path
|
||||
//! windows = "lumberyard\foo\bar\name.txt", posix = "lumberyard/foo/bar/name.txt"
|
||||
//! windows = "O3DE\foo\bar\name.txt", posix = "O3DE/foo/bar/name.txt"
|
||||
constexpr PathView RelativePath() const;
|
||||
//! Returns the parent directory of filename contained within the path
|
||||
//! windows = "C:\lumberyard\foo\bar", posix = "/lumberyard/foo/bar"
|
||||
//! windows = "C:\O3DE\foo\bar", posix = "/O3DE/foo/bar"
|
||||
//! NOTE: If the path ends with a trailing separator "test/foo/" it is treated as being a path of
|
||||
//! "test/foo" as if the filename of the path is "foo" and the parent directory is "test"
|
||||
constexpr PathView ParentPath() const;
|
||||
@@ -150,7 +150,7 @@ namespace AZ::IO
|
||||
//! The root portion of the path is made up of root_name() / root_directory()
|
||||
[[nodiscard]] constexpr bool HasRootPath() const;
|
||||
//! checks whether the relative part of path is empty
|
||||
//! (C:\\ lumberyard\dev\)
|
||||
//! (C:\\ O3DE\dev\)
|
||||
//! ^ ^
|
||||
//! root part relative part
|
||||
[[nodiscard]] constexpr bool HasRelativePath() const;
|
||||
@@ -485,10 +485,10 @@ namespace AZ::IO
|
||||
constexpr PathView RootPath() const;
|
||||
//! Returns the relative path portion of the path.
|
||||
//! This contains the path parts after the root path
|
||||
//! windows = "lumberyard\foo\bar\name.txt", posix = "lumberyard/foo/bar/name.txt"
|
||||
//! windows = "O3DE\foo\bar\name.txt", posix = "O3DE/foo/bar/name.txt"
|
||||
constexpr PathView RelativePath() const;
|
||||
//! Returns the parent directory of filename contained within the path
|
||||
//! windows = "C:\lumberyard\foo\bar", posix = "/lumberyard/foo/bar"
|
||||
//! windows = "C:\O3DE\foo\bar", posix = "/O3DE/foo/bar"
|
||||
//! NOTE: If the path ends with a trailing separator "test/foo/" it is treated as being a path of
|
||||
//! "test/foo" as if the filename of the path is "foo" and the parent directory is "test"
|
||||
constexpr PathView ParentPath() const;
|
||||
@@ -521,8 +521,8 @@ namespace AZ::IO
|
||||
//! The root portion of the path is made up of root_name() / root_directory()
|
||||
[[nodiscard]] constexpr bool HasRootPath() const;
|
||||
//! checks whether the relative part of path is empty
|
||||
//! (C:\\ lumberyard\dev\)
|
||||
//! ^ ^
|
||||
//! (C:\\ O3DE\dev\)
|
||||
//! ^ ^
|
||||
//! root part relative part
|
||||
[[nodiscard]] constexpr bool HasRelativePath() const;
|
||||
//! checks whether the path has a parent path that empty
|
||||
@@ -544,8 +544,8 @@ namespace AZ::IO
|
||||
[[nodiscard]] constexpr bool IsRelativeTo(const PathView& base) const;
|
||||
|
||||
// decomposition
|
||||
//! Given a windows path of "C:\lumberyard\foo\bar\name.txt" and a posix path of
|
||||
//! "/lumberyard/foo/bar/name.txt"
|
||||
//! Given a windows path of "C:\O3DE\foo\bar\name.txt" and a posix path of
|
||||
//! "/O3DE/foo/bar/name.txt"
|
||||
//! The following functions return the following
|
||||
|
||||
// query
|
||||
|
||||
@@ -147,15 +147,18 @@ namespace AZ
|
||||
ReadFile(request, args);
|
||||
return;
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::FlushData>)
|
||||
else
|
||||
{
|
||||
FlushCache(args.m_path);
|
||||
if constexpr (AZStd::is_same_v<Command, FileRequest::FlushData>)
|
||||
{
|
||||
FlushCache(args.m_path);
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::FlushAllData>)
|
||||
{
|
||||
FlushEntireCache();
|
||||
}
|
||||
StreamStackEntry::QueueRequest(request);
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::FlushAllData>)
|
||||
{
|
||||
FlushEntireCache();
|
||||
}
|
||||
StreamStackEntry::QueueRequest(request);
|
||||
}, request->GetCommand());
|
||||
}
|
||||
|
||||
|
||||
@@ -146,15 +146,18 @@ namespace AZ
|
||||
DestroyDedicatedCache(request, args);
|
||||
return;
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::FlushData>)
|
||||
else
|
||||
{
|
||||
FlushCache(args.m_path);
|
||||
if constexpr (AZStd::is_same_v<Command, FileRequest::FlushData>)
|
||||
{
|
||||
FlushCache(args.m_path);
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::FlushAllData>)
|
||||
{
|
||||
FlushEntireCache();
|
||||
}
|
||||
StreamStackEntry::QueueRequest(request);
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::FlushAllData>)
|
||||
{
|
||||
FlushEntireCache();
|
||||
}
|
||||
StreamStackEntry::QueueRequest(request);
|
||||
}, request->GetCommand());
|
||||
}
|
||||
|
||||
|
||||
@@ -97,19 +97,22 @@ namespace AZ
|
||||
CancelRequest(request, args.m_target);
|
||||
return;
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::FlushData>)
|
||||
else
|
||||
{
|
||||
FlushCache(args.m_path);
|
||||
if constexpr (AZStd::is_same_v<Command, FileRequest::FlushData>)
|
||||
{
|
||||
FlushCache(args.m_path);
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::FlushAllData>)
|
||||
{
|
||||
FlushEntireCache();
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::ReportData>)
|
||||
{
|
||||
Report(args);
|
||||
}
|
||||
StreamStackEntry::QueueRequest(request);
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::FlushAllData>)
|
||||
{
|
||||
FlushEntireCache();
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::ReportData>)
|
||||
{
|
||||
Report(args);
|
||||
}
|
||||
StreamStackEntry::QueueRequest(request);
|
||||
}, request->GetCommand());
|
||||
}
|
||||
|
||||
|
||||
@@ -374,7 +374,7 @@ namespace AZ
|
||||
|
||||
targetForward.Normalize();
|
||||
|
||||
// Lumberyard is Z-up and is right-handed.
|
||||
// Open 3D Engine is Z-up and is right-handed.
|
||||
Vector3 up = Vector3::CreateAxisZ();
|
||||
|
||||
// We have a degenerate case if target forward is parallel to the up axis,
|
||||
@@ -391,7 +391,7 @@ namespace AZ
|
||||
up.Normalize();
|
||||
|
||||
// Passing in forwardAxis allows you to force a particular local-space axis to look
|
||||
// at the target point. In Lumberyard, the default is forward is along Y+.
|
||||
// at the target point. In Open 3D Engine, the default is forward is along Y+.
|
||||
switch (forwardAxis)
|
||||
{
|
||||
case Axis::XPositive:
|
||||
|
||||
@@ -426,7 +426,7 @@ namespace AZ
|
||||
Matrix4x4 Matrix4x4::CreateProjection(float fovY, float aspectRatio, float nearDist, float farDist)
|
||||
{
|
||||
// This section contains some notes about camera matrices and field of view, because there are some subtle differences
|
||||
// between the convention Lumberyard uses and what you might be used to from other software packages.
|
||||
// between the convention Open 3D Engine uses and what you might be used to from other software packages.
|
||||
// Our camera space has the camera looking down the *positive* z-axis, the x-axis points towards the left of the screen,
|
||||
// and the y-axis points towards the top of the screen.
|
||||
//
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace AZ
|
||||
return Obb::CreateFromPositionRotationAndHalfLengths(
|
||||
transform.TransformPoint(obb.GetPosition()),
|
||||
transform.GetRotation() * obb.GetRotation(),
|
||||
obb.GetHalfLengths()
|
||||
transform.GetScale() * obb.GetHalfLengths()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ namespace AZ
|
||||
|
||||
targetForward.Normalize();
|
||||
|
||||
// Lumberyard is Z-up and is right-handed.
|
||||
// Open 3D Engine is Z-up and is right-handed.
|
||||
Vector3 up = Vector3::CreateAxisZ();
|
||||
|
||||
// We have a degenerate case if target forward is parallel to the up axis,
|
||||
@@ -371,7 +371,7 @@ namespace AZ
|
||||
up.Normalize();
|
||||
|
||||
// Passing in forwardAxis allows you to force a particular local-space axis to look
|
||||
// at the target point. In Lumberyard, the default is forward is along Y+.
|
||||
// at the target point. In Open 3D Engine, the default is forward is along Y+.
|
||||
switch (forwardAxis)
|
||||
{
|
||||
case Axis::XPositive:
|
||||
|
||||
@@ -707,7 +707,7 @@ PoolSchema::GarbageCollect()
|
||||
// occur exclusively in the destruction of the allocator.
|
||||
//
|
||||
// TODO: A better solution needs to be found for integrating back into mainline
|
||||
// Lumberyard.
|
||||
// Open 3D Engine.
|
||||
//m_impl->GarbageCollect();
|
||||
}
|
||||
|
||||
|
||||
@@ -1600,7 +1600,7 @@ static int Global_Typeid(lua_State* l)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef LUA_LUMBERYARD_EXTENSIONS
|
||||
#ifdef LUA_O3DE_EXTENSIONS
|
||||
|
||||
//=========================================================================
|
||||
// LUA Dummy Node Extension
|
||||
@@ -1631,7 +1631,7 @@ LUA_API const Node* lua_getDummyNode()
|
||||
return &(*s_luaDummyNodeVariable);
|
||||
}
|
||||
|
||||
#endif // LUA_LUMBERYARD_EXTENSIONS
|
||||
#endif // LUA_O3DE_EXTENSIONS
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace AZ
|
||||
const static AZ::Crc32 ChangeNotify = AZ_CRC("ChangeNotify", 0xf793bc19);
|
||||
const static AZ::Crc32 ClearNotify = AZ_CRC("ClearNotify", 0x88914c8c);
|
||||
|
||||
//! Specifies a function to accept or reject a value changed in the Lumberyard Editor.
|
||||
//! Specifies a function to accept or reject a value changed in the Open 3D Engine Editor.
|
||||
//! For example, a component could reject AZ::EntityId values that reference its own entity.
|
||||
//!
|
||||
//! Element type to use this with: Any type that you reflect using AZ::EditContext::ClassInfo::DataElement().
|
||||
|
||||
@@ -22,9 +22,9 @@ namespace AZ
|
||||
// JsonBaseContext
|
||||
//
|
||||
|
||||
JsonBaseContext::JsonBaseContext(JsonSerializationMetadata metadata, JsonSerializationResult::JsonIssueCallback reporting,
|
||||
JsonBaseContext::JsonBaseContext(JsonSerializationMetadata& metadata, JsonSerializationResult::JsonIssueCallback reporting,
|
||||
StackedString::Format pathFormat, SerializeContext* serializeContext, JsonRegistrationContext* registrationContext)
|
||||
: m_metadata(AZStd::move(metadata))
|
||||
: m_metadata(metadata)
|
||||
, m_serializeContext(serializeContext)
|
||||
, m_registrationContext(registrationContext)
|
||||
, m_path(pathFormat)
|
||||
@@ -126,20 +126,13 @@ namespace AZ
|
||||
// JsonDeserializerContext
|
||||
//
|
||||
|
||||
JsonDeserializerContext::JsonDeserializerContext(const JsonDeserializerSettings& settings)
|
||||
JsonDeserializerContext::JsonDeserializerContext(JsonDeserializerSettings& settings)
|
||||
: JsonBaseContext(settings.m_metadata, settings.m_reporting,
|
||||
StackedString::Format::JsonPointer, settings.m_serializeContext, settings.m_registrationContext)
|
||||
, m_clearContainers(settings.m_clearContainers)
|
||||
{
|
||||
}
|
||||
|
||||
JsonDeserializerContext::JsonDeserializerContext(JsonDeserializerSettings&& settings)
|
||||
: JsonBaseContext(AZStd::move(settings.m_metadata), AZStd::move(settings.m_reporting),
|
||||
StackedString::Format::JsonPointer, settings.m_serializeContext, settings.m_registrationContext)
|
||||
, m_clearContainers(settings.m_clearContainers)
|
||||
{
|
||||
}
|
||||
|
||||
bool JsonDeserializerContext::ShouldClearContainers() const
|
||||
{
|
||||
return m_clearContainers;
|
||||
@@ -151,7 +144,7 @@ namespace AZ
|
||||
// JsonSerializerContext
|
||||
//
|
||||
|
||||
JsonSerializerContext::JsonSerializerContext(const JsonSerializerSettings& settings, rapidjson::Document::AllocatorType& jsonAllocator)
|
||||
JsonSerializerContext::JsonSerializerContext(JsonSerializerSettings& settings, rapidjson::Document::AllocatorType& jsonAllocator)
|
||||
: JsonBaseContext(settings.m_metadata, settings.m_reporting, StackedString::Format::ContextPath,
|
||||
settings.m_serializeContext, settings.m_registrationContext)
|
||||
, m_jsonAllocator(jsonAllocator)
|
||||
@@ -159,14 +152,6 @@ namespace AZ
|
||||
{
|
||||
}
|
||||
|
||||
JsonSerializerContext::JsonSerializerContext(JsonSerializerSettings&& settings, rapidjson::Document::AllocatorType& jsonAllocator)
|
||||
: JsonBaseContext(AZStd::move(settings.m_metadata), AZStd::move(settings.m_reporting), StackedString::Format::ContextPath,
|
||||
settings.m_serializeContext, settings.m_registrationContext)
|
||||
, m_jsonAllocator(jsonAllocator)
|
||||
, m_keepDefaults(settings.m_keepDefaults)
|
||||
{
|
||||
}
|
||||
|
||||
rapidjson::Document::AllocatorType& JsonSerializerContext::GetJsonAllocator()
|
||||
{
|
||||
return m_jsonAllocator;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace AZ
|
||||
class JsonBaseContext
|
||||
{
|
||||
public:
|
||||
JsonBaseContext(JsonSerializationMetadata metadata, JsonSerializationResult::JsonIssueCallback reporting,
|
||||
JsonBaseContext(JsonSerializationMetadata& metadata, JsonSerializationResult::JsonIssueCallback reporting,
|
||||
StackedString::Format pathFormat, SerializeContext* serializeContext, JsonRegistrationContext* registrationContext);
|
||||
virtual ~JsonBaseContext() = default;
|
||||
|
||||
@@ -71,10 +71,6 @@ namespace AZ
|
||||
const JsonRegistrationContext* GetRegistrationContext() const;
|
||||
|
||||
protected:
|
||||
//! Metadata that's passed in by the settings as additional configuration options or metadata that's collected
|
||||
//! during processing for later use.
|
||||
JsonSerializationMetadata m_metadata;
|
||||
|
||||
//! Callback used to report progress and issues. Users of the serialization can update the return code to change
|
||||
//! the behavior of the serializer.
|
||||
AZStd::stack<JsonSerializationResult::JsonIssueCallback> m_reporters;
|
||||
@@ -82,6 +78,10 @@ namespace AZ
|
||||
//! Path to the element that's currently being operated on.
|
||||
StackedString m_path;
|
||||
|
||||
//! Metadata that's passed in by the settings as additional configuration options or metadata that's collected
|
||||
//! during processing for later use.
|
||||
JsonSerializationMetadata& m_metadata;
|
||||
|
||||
//! The Serialize Context that can be used to retrieve meta data during processing.
|
||||
SerializeContext* m_serializeContext = nullptr;
|
||||
//! The registration context for the json serialization. This can be used to retrieve the handlers for specific types.
|
||||
@@ -92,8 +92,7 @@ namespace AZ
|
||||
: public JsonBaseContext
|
||||
{
|
||||
public:
|
||||
explicit JsonDeserializerContext(const JsonDeserializerSettings& settings);
|
||||
explicit JsonDeserializerContext(JsonDeserializerSettings&& settings);
|
||||
explicit JsonDeserializerContext(JsonDeserializerSettings& settings);
|
||||
~JsonDeserializerContext() override = default;
|
||||
|
||||
JsonDeserializerContext(const JsonDeserializerContext&) = delete;
|
||||
@@ -114,8 +113,7 @@ namespace AZ
|
||||
: public JsonBaseContext
|
||||
{
|
||||
public:
|
||||
explicit JsonSerializerContext(const JsonSerializerSettings& settings, rapidjson::Document::AllocatorType& jsonAllocator);
|
||||
explicit JsonSerializerContext(JsonSerializerSettings&& settings, rapidjson::Document::AllocatorType& jsonAllocator);
|
||||
JsonSerializerContext(JsonSerializerSettings& settings, rapidjson::Document::AllocatorType& jsonAllocator);
|
||||
~JsonSerializerContext() override = default;
|
||||
|
||||
JsonSerializerContext(const JsonSerializerContext&) = delete;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace AZ
|
||||
{
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyPatch(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& patch,
|
||||
const JsonApplyPatchSettings& settings)
|
||||
JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::CreatePatch(rapidjson::Value& patch,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, const JsonCreatePatchSettings& settings)
|
||||
const rapidjson::Value& target, JsonCreatePatchSettings& settings)
|
||||
{
|
||||
StackedString element(StackedString::Format::JsonPointer);
|
||||
return CreatePatchInternal(patch.SetArray(), allocator, source, target, element, settings);
|
||||
@@ -130,7 +130,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyMergePatch(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& patch,
|
||||
const JsonApplyPatchSettings& settings)
|
||||
JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -196,14 +196,14 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::CreateMergePatch(rapidjson::Value& patch,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, const JsonCreatePatchSettings& settings)
|
||||
const rapidjson::Value& target, JsonCreatePatchSettings& settings)
|
||||
{
|
||||
StackedString element(StackedString::Format::JsonPointer);
|
||||
return CreateMergePatchInternal(patch, allocator, source, target, element, settings);
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyPatch_GetFromValue(rapidjson::Value** fromValue, rapidjson::Pointer& fromPointer,
|
||||
rapidjson::Value& target, const rapidjson::Value& entry, StackedString& element, const JsonApplyPatchSettings& settings)
|
||||
rapidjson::Value& target, const rapidjson::Value& entry, StackedString& element, JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyPatch_Add(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& entry, const rapidjson::Pointer& path,
|
||||
StackedString& element, const JsonApplyPatchSettings& settings)
|
||||
StackedString& element, JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyPatch_AddValue(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Pointer& path, rapidjson::Value&& newValue,
|
||||
StackedString& element, const JsonApplyPatchSettings& settings)
|
||||
StackedString& element, JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -347,7 +347,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyPatch_Remove(rapidjson::Value& target, const rapidjson::Pointer& path,
|
||||
StackedString& element, const JsonApplyPatchSettings& settings)
|
||||
StackedString& element, JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -399,7 +399,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyPatch_Replace(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& entry, const rapidjson::Pointer& path,
|
||||
StackedString& element, const JsonApplyPatchSettings& settings)
|
||||
StackedString& element, JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -426,7 +426,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyPatch_Move(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& entry, const rapidjson::Pointer& path,
|
||||
StackedString& element, const JsonApplyPatchSettings& settings)
|
||||
StackedString& element, JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -445,7 +445,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyPatch_Copy(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& entry, const rapidjson::Pointer& path,
|
||||
StackedString& element, const JsonApplyPatchSettings& settings)
|
||||
StackedString& element, JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -463,7 +463,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyPatch_Test(rapidjson::Value& target, const rapidjson::Value& entry,
|
||||
const rapidjson::Pointer& path, StackedString& element, const JsonApplyPatchSettings& settings)
|
||||
const rapidjson::Pointer& path, StackedString& element, JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -495,7 +495,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::CreatePatchInternal(rapidjson::Value& patch,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, StackedString& element, const JsonCreatePatchSettings& settings)
|
||||
const rapidjson::Value& target, StackedString& element, JsonCreatePatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -633,7 +633,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::CreateMergePatchInternal(rapidjson::Value& patch,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, StackedString& element, const JsonCreatePatchSettings& settings)
|
||||
const rapidjson::Value& target, StackedString& element, JsonCreatePatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
|
||||
@@ -30,43 +30,43 @@ namespace AZ
|
||||
//! Implementation of the JSON Patch algorithm: https://tools.ietf.org/html/rfc6902
|
||||
static JsonSerializationResult::ResultCode ApplyPatch(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& patch,
|
||||
const JsonApplyPatchSettings& settings);
|
||||
JsonApplyPatchSettings& settings);
|
||||
|
||||
//! Function to create JSON Patches: https://tools.ietf.org/html/rfc6902
|
||||
static JsonSerializationResult::ResultCode CreatePatch(rapidjson::Value& patch,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, const JsonCreatePatchSettings& settings);
|
||||
const rapidjson::Value& target, JsonCreatePatchSettings& settings);
|
||||
|
||||
//! Implementation of the JSON Merge Patch algorithm: https://tools.ietf.org/html/rfc7386
|
||||
static JsonSerializationResult::ResultCode ApplyMergePatch(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& patch,
|
||||
const JsonApplyPatchSettings& settings);
|
||||
JsonApplyPatchSettings& settings);
|
||||
|
||||
//! Function to create JSON Merge Patches: https://tools.ietf.org/html/rfc7386
|
||||
static JsonSerializationResult::ResultCode CreateMergePatch(rapidjson::Value& patch,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, const JsonCreatePatchSettings& settings);
|
||||
const rapidjson::Value& target, JsonCreatePatchSettings& settings);
|
||||
|
||||
static JsonSerializationResult::ResultCode ApplyPatch_GetFromValue(rapidjson::Value** fromValue, rapidjson::Pointer& fromPointer,
|
||||
rapidjson::Value& target, const rapidjson::Value& entry, StackedString& element, const JsonApplyPatchSettings& settings);
|
||||
rapidjson::Value& target, const rapidjson::Value& entry, StackedString& element, JsonApplyPatchSettings& settings);
|
||||
static JsonSerializationResult::ResultCode ApplyPatch_Add(rapidjson::Value& target, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, const JsonApplyPatchSettings& settings);
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, JsonApplyPatchSettings& settings);
|
||||
static JsonSerializationResult::ResultCode ApplyPatch_AddValue(rapidjson::Value& target, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Pointer& path, rapidjson::Value&& newValue, StackedString& element, const JsonApplyPatchSettings& settings);
|
||||
const rapidjson::Pointer& path, rapidjson::Value&& newValue, StackedString& element, JsonApplyPatchSettings& settings);
|
||||
static JsonSerializationResult::ResultCode ApplyPatch_Remove(rapidjson::Value& target, const rapidjson::Pointer& path,
|
||||
StackedString& element, const JsonApplyPatchSettings& settings);
|
||||
StackedString& element, JsonApplyPatchSettings& settings);
|
||||
static JsonSerializationResult::ResultCode ApplyPatch_Replace(rapidjson::Value& target, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, const JsonApplyPatchSettings& settings);
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, JsonApplyPatchSettings& settings);
|
||||
static JsonSerializationResult::ResultCode ApplyPatch_Move(rapidjson::Value& target, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, const JsonApplyPatchSettings& settings);
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, JsonApplyPatchSettings& settings);
|
||||
static JsonSerializationResult::ResultCode ApplyPatch_Copy(rapidjson::Value& target, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, const JsonApplyPatchSettings& settings);
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, JsonApplyPatchSettings& settings);
|
||||
static JsonSerializationResult::ResultCode ApplyPatch_Test(rapidjson::Value& target,
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, const JsonApplyPatchSettings& settings);
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, JsonApplyPatchSettings& settings);
|
||||
|
||||
static JsonSerializationResult::ResultCode CreatePatchInternal(rapidjson::Value& patch,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, StackedString& element, const JsonCreatePatchSettings& settings);
|
||||
const rapidjson::Value& target, StackedString& element, JsonCreatePatchSettings& settings);
|
||||
static rapidjson::Value CreatePatchInternal_Add(rapidjson::Document::AllocatorType& allocator,
|
||||
StackedString& path, const rapidjson::Value& value);
|
||||
static rapidjson::Value CreatePatchInternal_Remove(rapidjson::Document::AllocatorType& allocator, StackedString& path);
|
||||
@@ -75,6 +75,6 @@ namespace AZ
|
||||
|
||||
static JsonSerializationResult::ResultCode CreateMergePatchInternal(rapidjson::Value& patch,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, StackedString& element, const JsonCreatePatchSettings& settings);
|
||||
const rapidjson::Value& target, StackedString& element, JsonCreatePatchSettings& settings);
|
||||
};
|
||||
} // namespace AZ
|
||||
|
||||
@@ -97,9 +97,18 @@ namespace AZ
|
||||
}
|
||||
} // namespace JsonSerializationInternal
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::ApplyPatch(
|
||||
rapidjson::Value& target, rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& patch, JsonMergeApproach approach,
|
||||
const JsonApplyPatchSettings& settings)
|
||||
{
|
||||
// Explicitly make a copy to call the correct overloaded version and avoid infinite recursion on this function.
|
||||
JsonApplyPatchSettings settingsCopy{ settings };
|
||||
return ApplyPatch(target, allocator, patch, approach, settingsCopy);
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::ApplyPatch(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& patch, JsonMergeApproach approach,
|
||||
JsonApplyPatchSettings settings)
|
||||
JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -126,8 +135,17 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::ApplyPatch(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& patch, JsonMergeApproach approach, const JsonApplyPatchSettings& settings)
|
||||
{
|
||||
// Explicitly make a copy to call the correct overloaded version and avoid infinite recursion on this function.
|
||||
JsonApplyPatchSettings settingsCopy{settings};
|
||||
return ApplyPatch(output, allocator, source, patch, approach, settingsCopy);
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::ApplyPatch(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Value& source, const rapidjson::Value& patch, JsonMergeApproach approach, JsonApplyPatchSettings settings)
|
||||
const rapidjson::Value& source, const rapidjson::Value& patch, JsonMergeApproach approach, JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -166,9 +184,18 @@ namespace AZ
|
||||
return result;
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::CreatePatch(
|
||||
rapidjson::Value& patch, rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, JsonMergeApproach approach, const JsonCreatePatchSettings& settings)
|
||||
{
|
||||
// Explicitly make a copy to call the correct overloaded version and avoid infinite recursion on this function.
|
||||
JsonCreatePatchSettings settingsCopy{settings};
|
||||
return CreatePatch(patch, allocator, source, target, approach, settingsCopy);
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::CreatePatch(rapidjson::Value& patch, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Value& source, const rapidjson::Value& target, JsonMergeApproach approach, JsonCreatePatchSettings settings)
|
||||
JsonSerializationResult::ResultCode JsonSerialization::CreatePatch(
|
||||
rapidjson::Value& patch, rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, JsonMergeApproach approach, JsonCreatePatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -194,7 +221,16 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Load(void* object, const Uuid& objectType, const rapidjson::Value& root, JsonDeserializerSettings settings)
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Load(
|
||||
void* object, const Uuid& objectType, const rapidjson::Value& root, const JsonDeserializerSettings& settings)
|
||||
{
|
||||
// Explicitly make a copy to call the correct overloaded version and avoid infinite recursion on this function.
|
||||
JsonDeserializerSettings settingsCopy{settings};
|
||||
return Load(object, objectType, root, settingsCopy);
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Load(
|
||||
void* object, const Uuid& objectType, const rapidjson::Value& root, JsonDeserializerSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -212,14 +248,23 @@ namespace AZ
|
||||
if (result.GetOutcome() == Outcomes::Success)
|
||||
{
|
||||
StackedString path(StackedString::Format::JsonPointer);
|
||||
JsonDeserializerContext context(AZStd::move(settings));
|
||||
JsonDeserializerContext context(settings);
|
||||
result = JsonDeserializer::Load(object, objectType, root, context);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::LoadTypeId(
|
||||
Uuid& typeId, const rapidjson::Value& input, const Uuid* baseClassTypeId, AZStd::string_view jsonPath,
|
||||
const JsonDeserializerSettings& settings)
|
||||
{
|
||||
// Explicitly make a copy to call the correct overloaded version and avoid infinite recursion on this function.
|
||||
JsonDeserializerSettings settingsCopy{settings};
|
||||
return LoadTypeId(typeId, input, baseClassTypeId, jsonPath, settingsCopy);
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::LoadTypeId(Uuid& typeId, const rapidjson::Value& input,
|
||||
const Uuid* baseClassTypeId, AZStd::string_view jsonPath, JsonDeserializerSettings settings)
|
||||
const Uuid* baseClassTypeId, AZStd::string_view jsonPath, JsonDeserializerSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -236,7 +281,7 @@ namespace AZ
|
||||
ResultCode result = JsonSerializationInternal::GetContexts(settings, settings.m_serializeContext, settings.m_registrationContext);
|
||||
if (result.GetOutcome() == Outcomes::Success)
|
||||
{
|
||||
JsonDeserializerContext context(AZStd::move(settings));
|
||||
JsonDeserializerContext context(settings);
|
||||
context.PushPath(jsonPath);
|
||||
|
||||
result = JsonDeserializer::LoadTypeId(typeId, input, context, baseClassTypeId);
|
||||
@@ -244,8 +289,18 @@ namespace AZ
|
||||
return result;
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Store(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const void* object, const void* defaultObject, const Uuid& objectType, JsonSerializerSettings settings)
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const void* object, const void* defaultObject,
|
||||
const Uuid& objectType, const JsonSerializerSettings& settings)
|
||||
{
|
||||
// Explicitly make a copy to call the correct overloaded version and avoid infinite recursion on this function.
|
||||
JsonSerializerSettings settingsCopy{settings};
|
||||
return Store(output, allocator, object, defaultObject, objectType, settingsCopy);
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const void* object, const void* defaultObject,
|
||||
const Uuid& objectType, JsonSerializerSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -269,15 +324,24 @@ namespace AZ
|
||||
settings.m_keepDefaults = false;
|
||||
}
|
||||
|
||||
JsonSerializerContext context(AZStd::move(settings), allocator);
|
||||
JsonSerializerContext context(settings, allocator);
|
||||
StackedString path(StackedString::Format::ContextPath);
|
||||
result = JsonSerializer::Store(output, object, defaultObject, objectType, context);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::StoreTypeId(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const Uuid& typeId, AZStd::string_view elementPath,
|
||||
const JsonSerializerSettings& settings)
|
||||
{
|
||||
// Explicitly make a copy to call the correct overloaded version and avoid infinite recursion on this function.
|
||||
JsonSerializerSettings settingsCopy{settings};
|
||||
return StoreTypeId(output, allocator, typeId, elementPath, settingsCopy);
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::StoreTypeId(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const Uuid& typeId, AZStd::string_view elementPath, JsonSerializerSettings settings)
|
||||
const Uuid& typeId, AZStd::string_view elementPath, JsonSerializerSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -294,7 +358,7 @@ namespace AZ
|
||||
ResultCode result = JsonSerializationInternal::GetContexts(settings, settings.m_serializeContext, settings.m_registrationContext);
|
||||
if (result.GetOutcome() == Outcomes::Success)
|
||||
{
|
||||
JsonSerializerContext context(AZStd::move(settings), allocator);
|
||||
JsonSerializerContext context(settings, allocator);
|
||||
context.PushPath(elementPath);
|
||||
result = JsonSerializer::StoreTypeName(output, typeId, context);
|
||||
}
|
||||
|
||||
@@ -48,14 +48,25 @@ namespace AZ
|
||||
|
||||
//! Merges two json values together by applying "patch" to "target" using the selected merge algorithm.
|
||||
//! This version of ApplyPatch is destructive to "target". If the patch can't be correctly applied it will
|
||||
//! leave target in a partially patched state. Use the over version of ApplyPatch if target should be copied.
|
||||
//! leave target in a partially patched state. Use the other version of ApplyPatch if target should be copied.
|
||||
//! @param target The value where the patch will be applied to.
|
||||
//! @param allocator The allocator associated with the document that holds the target.
|
||||
//! @param patch The value holding the patch information.
|
||||
//! @param approach The merge algorithm that will be used to apply the patch on top of the target.
|
||||
//! @param settings Optional additional settings to control the way the patch is applied.
|
||||
static JsonSerializationResult::ResultCode ApplyPatch(rapidjson::Value& target, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Value& patch, JsonMergeApproach approach, JsonApplyPatchSettings settings = JsonApplyPatchSettings{});
|
||||
const rapidjson::Value& patch, JsonMergeApproach approach, const JsonApplyPatchSettings& settings = JsonApplyPatchSettings{});
|
||||
//! Merges two json values together by applying "patch" to "target" using the selected merge algorithm.
|
||||
//! This version of ApplyPatch is destructive to "target". If the patch can't be correctly applied it will
|
||||
//! leave target in a partially patched state. Use the other version of ApplyPatch if target should be copied.
|
||||
//! @param target The value where the patch will be applied to.
|
||||
//! @param allocator The allocator associated with the document that holds the target.
|
||||
//! @param patch The value holding the patch information.
|
||||
//! @param approach The merge algorithm that will be used to apply the patch on top of the target.
|
||||
//! @param settings Additional settings to control the way the patch is applied.
|
||||
static JsonSerializationResult::ResultCode ApplyPatch(
|
||||
rapidjson::Value& target, rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& patch,
|
||||
JsonMergeApproach approach, JsonApplyPatchSettings& settings);
|
||||
|
||||
//! Merges two json values together by applying "patch" to a copy of "output" and written to output using the
|
||||
//! selected merge algorithm. This version of ApplyPatch is non-destructive to "source". If the patch couldn't be
|
||||
@@ -68,7 +79,19 @@ namespace AZ
|
||||
//! @param settings Optional additional settings to control the way the patch is applied.
|
||||
static JsonSerializationResult::ResultCode ApplyPatch(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Value& source, const rapidjson::Value& patch, JsonMergeApproach approach,
|
||||
JsonApplyPatchSettings settings = JsonApplyPatchSettings{});
|
||||
const JsonApplyPatchSettings& settings = JsonApplyPatchSettings{});
|
||||
//! Merges two json values together by applying "patch" to a copy of "output" and written to output using the
|
||||
//! selected merge algorithm. This version of ApplyPatch is non-destructive to "source". If the patch couldn't be
|
||||
//! fully applied "output" will be left set to an empty (default) object.
|
||||
//! @param source A copy of source with the patch applied to it or an empty object if the patch couldn't be applied.
|
||||
//! @param allocator The allocator associated with the document that holds the source.
|
||||
//! @param target The value where the patch will be applied to.
|
||||
//! @param patch The value holding the patch information.
|
||||
//! @param approach The merge algorithm that will be used to apply the patch on top of the target.
|
||||
//! @param settings Additional settings to control the way the patch is applied.
|
||||
static JsonSerializationResult::ResultCode ApplyPatch(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& patch, JsonMergeApproach approach, JsonApplyPatchSettings& settings);
|
||||
|
||||
//! Creates a patch using the selected merge algorithm such that when applied to source it results in target.
|
||||
//! @param patch The value containing the differences between source and target.
|
||||
@@ -79,22 +102,46 @@ namespace AZ
|
||||
//! @param settings Optional additional settings to control the way the patch is created.
|
||||
static JsonSerializationResult::ResultCode CreatePatch(rapidjson::Value& patch, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Value& source, const rapidjson::Value& target, JsonMergeApproach approach,
|
||||
JsonCreatePatchSettings settings = JsonCreatePatchSettings{});
|
||||
const JsonCreatePatchSettings& settings = JsonCreatePatchSettings{});
|
||||
//! Creates a patch using the selected merge algorithm such that when applied to source it results in target.
|
||||
//! @param patch The value containing the differences between source and target.
|
||||
//! @param allocator The allocator associated with the document that will hold the patch.
|
||||
//! @param source The value used as a starting point.
|
||||
//! @param target The value that will result if the patch is applied to the source.
|
||||
//! @param approach The algorithm that will be used when the patch is applied to the source.
|
||||
//! @param settings Additional settings to control the way the patch is created.
|
||||
static JsonSerializationResult::ResultCode CreatePatch(
|
||||
rapidjson::Value& patch, rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, JsonMergeApproach approach, JsonCreatePatchSettings& settings);
|
||||
|
||||
//! Loads the data from the provided json value into the supplied object. The object is expected to be created before calling load.
|
||||
//! @param object Object where the data will be loaded into.
|
||||
//! @param root The Value or Document where the deserializer will start reading data from.
|
||||
//! @param settings The settings used during deserialization. Use the value passed in from Load.
|
||||
//! @param settings Optional additional settings to control the way document is deserialized.
|
||||
template<typename T>
|
||||
static JsonSerializationResult::ResultCode Load(T& object, const rapidjson::Value& root,
|
||||
JsonDeserializerSettings settings = JsonDeserializerSettings{});
|
||||
static JsonSerializationResult::ResultCode Load(
|
||||
T& object, const rapidjson::Value& root, const JsonDeserializerSettings& settings = JsonDeserializerSettings{});
|
||||
//! Loads the data from the provided json value into the supplied object. The object is expected to be created before calling load.
|
||||
//! @param object Object where the data will be loaded into.
|
||||
//! @param root The Value or Document where the deserializer will start reading data from.
|
||||
//! @param settings Additional settings to control the way document is deserialized.
|
||||
template<typename T>
|
||||
static JsonSerializationResult::ResultCode Load(T& object, const rapidjson::Value& root, JsonDeserializerSettings& settings);
|
||||
//! Loads the data from the provided json value into the supplied object. The object is expected to be created before calling load.
|
||||
//! @param object Pointer to the object where the data will be loaded into.
|
||||
//! @param objectType Type id of the object passed in.
|
||||
//! @param root The Value or Document from where the deserializer will start reading data.
|
||||
//! @param settings The settings used during deserialization. Use the value passed in from Load.
|
||||
static JsonSerializationResult::ResultCode Load(void* object, const Uuid& objectType, const rapidjson::Value& root,
|
||||
JsonDeserializerSettings settings = JsonDeserializerSettings{});
|
||||
//! @param settings Optional additional settings to control the way document is deserialized.
|
||||
static JsonSerializationResult::ResultCode Load(
|
||||
void* object, const Uuid& objectType, const rapidjson::Value& root,
|
||||
const JsonDeserializerSettings& settings = JsonDeserializerSettings{});
|
||||
//! Loads the data from the provided json value into the supplied object. The object is expected to be created before calling load.
|
||||
//! @param object Pointer to the object where the data will be loaded into.
|
||||
//! @param objectType Type id of the object passed in.
|
||||
//! @param root The Value or Document from where the deserializer will start reading data.
|
||||
//! @param settings Additional settings to control the way document is deserialized.
|
||||
static JsonSerializationResult::ResultCode Load(
|
||||
void* object, const Uuid& objectType, const rapidjson::Value& root, JsonDeserializerSettings& settings);
|
||||
|
||||
//! Loads the type id from the provided input.
|
||||
//! Note: it's not recommended to use this function (frequently) as it requires users of the json file to have knowledge of the internal
|
||||
@@ -105,20 +152,44 @@ namespace AZ
|
||||
//! references multiple types then the baseClassTypeId will be used to disambiguate between the different types by looking
|
||||
//! if exactly one of the types inherits from the base class that baseClassTypeId points to.
|
||||
//! @param jsonPath An optional path to the json node. This will be used for reporting.
|
||||
//! @param settings An optional settings object to change where this function collects information from. This can be same settings
|
||||
//! @param settings Optional settings object to change where this function collects information from. This can be same settings
|
||||
//! as used for the other Load functions.
|
||||
static JsonSerializationResult::ResultCode LoadTypeId(Uuid& typeId, const rapidjson::Value& input,
|
||||
const Uuid* baseClassTypeId = nullptr, AZStd::string_view jsonPath = AZStd::string_view{},
|
||||
JsonDeserializerSettings settings = JsonDeserializerSettings{});
|
||||
const JsonDeserializerSettings& settings = JsonDeserializerSettings{});
|
||||
//! Loads the type id from the provided input.
|
||||
//! Note: it's not recommended to use this function (frequently) as it requires users of the json file to have knowledge of the
|
||||
//! internal type structure and is therefore harder to use.
|
||||
//! @param typeId The uuid where the loaded data will be written to. If loading fails this will be a null uuid.
|
||||
//! @param input The json node to load from. The node is expected to contain a string.
|
||||
//! @param baseClassTypeId. An optional type id for the base class, if known. If a type name is stored in the string which
|
||||
//! references multiple types then the baseClassTypeId will be used to disambiguate between the different types by looking
|
||||
//! if exactly one of the types inherits from the base class that baseClassTypeId points to.
|
||||
//! @param jsonPath An optional path to the json node. This will be used for reporting.
|
||||
//! @param settings Settings object to change where this function collects information from. This can be same settings
|
||||
//! as used for the other Load functions.
|
||||
static JsonSerializationResult::ResultCode LoadTypeId(
|
||||
Uuid& typeId, const rapidjson::Value& input, const Uuid* baseClassTypeId,
|
||||
AZStd::string_view jsonPath, JsonDeserializerSettings& settings);
|
||||
|
||||
//! Stores the data in the provided object as json values starting at the provided value.
|
||||
//! @param output The Value or Document where the converted data will start writing to.
|
||||
//! @param allocator The memory allocator used by RapidJSON to create the json document.
|
||||
//! @param object The object that will be read from for values to convert.
|
||||
//! @param settings The settings used during serialization. Use the value passed in from Store.
|
||||
//! @param settings Optional additional settings to control the way document is serialized.
|
||||
template<typename T>
|
||||
static JsonSerializationResult::ResultCode Store(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const T& object, JsonSerializerSettings settings = JsonSerializerSettings{});
|
||||
static JsonSerializationResult::ResultCode Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const T& object,
|
||||
const JsonSerializerSettings& settings = JsonSerializerSettings{});
|
||||
//! Stores the data in the provided object as json values starting at the provided value.
|
||||
//! @param output The Value or Document where the converted data will start writing to.
|
||||
//! @param allocator The memory allocator used by RapidJSON to create the json document.
|
||||
//! @param object The object that will be read from for values to convert.
|
||||
//! @param settings Additional settings to control the way document is serialized.
|
||||
template<typename T>
|
||||
static JsonSerializationResult::ResultCode Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const T& object,
|
||||
JsonSerializerSettings& settings);
|
||||
|
||||
//! Stores the data in the provided object as json values starting at the provided value.
|
||||
//! @param output The Value or Document where the converted data will start writing to.
|
||||
@@ -127,10 +198,23 @@ namespace AZ
|
||||
//! @param defaultObject Default object used to compare the object to in order to determine if values are
|
||||
//! defaulted or not. If this is argument is provided m_keepDefaults in the settings will automatically
|
||||
//! be set to true.
|
||||
//! @param settings The settings used during serialization. Use the value passed in from Store.
|
||||
//! @param settings Optional additional settings to control the way document is serialized.
|
||||
template<typename T>
|
||||
static JsonSerializationResult::ResultCode Store(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const T& object, const T& defaultObject, JsonSerializerSettings settings = JsonSerializerSettings{});
|
||||
static JsonSerializationResult::ResultCode Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const T& object, const T& defaultObject,
|
||||
const JsonSerializerSettings& settings = JsonSerializerSettings{});
|
||||
//! Stores the data in the provided object as json values starting at the provided value.
|
||||
//! @param output The Value or Document where the converted data will start writing to.
|
||||
//! @param allocator The memory allocator used by RapidJSON to create the json document.
|
||||
//! @param object The object that will be read from for values to convert.
|
||||
//! @param defaultObject Default object used to compare the object to in order to determine if values are
|
||||
//! defaulted or not. If this is argument is provided m_keepDefaults in the settings will automatically
|
||||
//! be set to true.
|
||||
//! @param settings Additional settings to control the way document is serialized.
|
||||
template<typename T>
|
||||
static JsonSerializationResult::ResultCode Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const T& object, const T& defaultObject,
|
||||
JsonSerializerSettings& settings);
|
||||
|
||||
//! Stores the data in the provided object as json values starting at the provided value.
|
||||
//! @param output The Value or Document where the converted data will start writing to.
|
||||
@@ -140,10 +224,22 @@ namespace AZ
|
||||
//! defaulted or not. This argument can be null, in which case a temporary default may be created if required by
|
||||
//! the settings. If this is argument is provided m_keepDefaults in the settings will automatically be set to true.
|
||||
//! @param objectType The type id of the object and default object.
|
||||
//! @param settings The settings used during serialization. Use the value passed in from Store.
|
||||
static JsonSerializationResult::ResultCode Store(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const void* object, const void* defaultObject, const Uuid& objectType,
|
||||
JsonSerializerSettings settings = JsonSerializerSettings{});
|
||||
//! @param settings Optional additional settings to control the way document is serialized.
|
||||
static JsonSerializationResult::ResultCode Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const void* object, const void* defaultObject,
|
||||
const Uuid& objectType, const JsonSerializerSettings& settings = JsonSerializerSettings{});
|
||||
//! Stores the data in the provided object as json values starting at the provided value.
|
||||
//! @param output The Value or Document where the converted data will start writing to.
|
||||
//! @param allocator The memory allocator used by RapidJSON to create the json document.
|
||||
//! @param object Pointer to the object that will be read from for values to convert.
|
||||
//! @param defaultObject Pointer to a default object used to compare the object to in order to determine if values are
|
||||
//! defaulted or not. This argument can be null, in which case a temporary default may be created if required by
|
||||
//! the settings. If this is argument is provided m_keepDefaults in the settings will automatically be set to true.
|
||||
//! @param objectType The type id of the object and default object.
|
||||
//! @param settings Additional settings to control the way document is serialized.
|
||||
static JsonSerializationResult::ResultCode Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const void* object, const void* defaultObject,
|
||||
const Uuid& objectType, JsonSerializerSettings& settings);
|
||||
|
||||
//! Stores a name for the type id in the provided output. The name can be safely used to reference a type such as a class during loading.
|
||||
//! Note: it's not recommended to use this function (frequently) as it requires users of the json file to have knowledge of the internal
|
||||
@@ -152,10 +248,25 @@ namespace AZ
|
||||
//! @param allocator The allocator associated with the document that will or already holds the output.
|
||||
//! @param typeId The type id to store.
|
||||
//! @param elementPath An optional path to the element. This will be used for reporting.
|
||||
//! @param settings An optional settings object to change where this function collects information from. This can be same settings
|
||||
//! @param settings Optional settings to change where this function collects information from. This can be the same settings
|
||||
//! as used for the other Store functions.
|
||||
static JsonSerializationResult::ResultCode StoreTypeId(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const Uuid& typeId, AZStd::string_view elementPath = AZStd::string_view{}, JsonSerializerSettings settings = JsonSerializerSettings{});
|
||||
static JsonSerializationResult::ResultCode StoreTypeId(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const Uuid& typeId,
|
||||
AZStd::string_view elementPath = AZStd::string_view{}, const JsonSerializerSettings& settings = JsonSerializerSettings{});
|
||||
//! Stores a name for the type id in the provided output. The name can be safely used to reference a type such as a class during
|
||||
//! loading. Note: it's not recommended to use this function (frequently) as it requires users of the json file to have knowledge of
|
||||
//! the internal
|
||||
//! type structure and is therefore harder to use.
|
||||
//! @param output The json value the result will be written to. If successful this will contain a string object otherwise a default
|
||||
//! object.
|
||||
//! @param allocator The allocator associated with the document that will or already holds the output.
|
||||
//! @param typeId The type id to store.
|
||||
//! @param elementPath The path to the element. This will be used for reporting.
|
||||
//! @param settings Settings to change where this function collects information from. This can be the same settings
|
||||
//! as used for the other Store functions.
|
||||
static JsonSerializationResult::ResultCode StoreTypeId(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const Uuid& typeId,
|
||||
AZStd::string_view elementPath, JsonSerializerSettings& settings);
|
||||
|
||||
//! Compares two json values of any type and determines if the left is less, equal or greater than the right.
|
||||
//! @param lhs The left hand side value for the compare.
|
||||
@@ -180,22 +291,43 @@ namespace AZ
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Load(T& object, const rapidjson::Value& root, JsonDeserializerSettings settings)
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Load(T& object, const rapidjson::Value& root, const JsonDeserializerSettings& settings)
|
||||
{
|
||||
return Load(&object, azrtti_typeid(object), root, settings);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Store(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const T& object, JsonSerializerSettings settings)
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Load(T& object, const rapidjson::Value& root, JsonDeserializerSettings& settings)
|
||||
{
|
||||
return Load(&object, azrtti_typeid(object), root, settings);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const T& object, const JsonSerializerSettings& settings)
|
||||
{
|
||||
return Store(output, allocator, &object, nullptr, azrtti_typeid(object), settings);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const T& object, JsonSerializerSettings& settings)
|
||||
{
|
||||
return Store(output, allocator, &object, nullptr, azrtti_typeid(object), settings);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Store(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const T& object, const T& defaultObject, JsonSerializerSettings settings)
|
||||
const T& object, const T& defaultObject, const JsonSerializerSettings& settings)
|
||||
{
|
||||
return Store(output, allocator, &object,& defaultObject, azrtti_typeid(object), settings);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const T& object, const T& defaultObject,
|
||||
JsonSerializerSettings& settings)
|
||||
{
|
||||
return Store(output, allocator, &object, &defaultObject, azrtti_typeid(object), settings);
|
||||
}
|
||||
} // namespace AZ
|
||||
|
||||
@@ -22,14 +22,20 @@ namespace AZ
|
||||
class JsonSerializationMetadata final
|
||||
{
|
||||
public:
|
||||
//! Creates a new settings object in the metadata collection.
|
||||
//! Only one object of the same type can be added or created.
|
||||
//! Returns false if an object of this type was already added.
|
||||
template<typename MetadataT, typename... Args>
|
||||
bool Create(Args&&... args);
|
||||
|
||||
//! Adds a new settings object to the metadata collection.
|
||||
//! Only one object of the same type can be added.
|
||||
//! Only one object of the same type can be added or created.
|
||||
//! Returns false if an object of this type was already added.
|
||||
template<typename MetadataT>
|
||||
bool Add(MetadataT&& data);
|
||||
|
||||
//! Adds a new settings object to the metadata collection.
|
||||
//! Only one object of the same type can be added.
|
||||
//! Only one object of the same type can be added or created.
|
||||
//! Returns false if an object of this type was already added.
|
||||
template<typename MetadataT>
|
||||
bool Add(const MetadataT& data);
|
||||
|
||||
@@ -16,19 +16,31 @@
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
template<typename MetadataT>
|
||||
bool JsonSerializationMetadata::Add(MetadataT&& data)
|
||||
template<typename MetadataT, typename... Args>
|
||||
bool JsonSerializationMetadata::Create(Args&&... args)
|
||||
{
|
||||
auto typeId = azrtti_typeid<MetadataT>();
|
||||
auto iter = m_data.find(typeId);
|
||||
if (iter != m_data.end())
|
||||
const Uuid& typeId = azrtti_typeid<MetadataT>();
|
||||
if (m_data.find(typeId) != m_data.end())
|
||||
{
|
||||
AZ_Warning("JsonSerializationMetadata", false, "Metadata object of type %s already added",
|
||||
typeId.template ToString<AZStd::string>().c_str());
|
||||
AZ_Assert(false, "Metadata object of type %s already added", typeId.template ToString<AZStd::string>().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
m_data[typeId] = AZStd::any{ AZStd::forward<MetadataT>(data) };
|
||||
m_data.emplace(typeId, MetadataT{AZStd::forward<Args>(args)...});
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename MetadataT>
|
||||
bool JsonSerializationMetadata::Add(MetadataT&& data)
|
||||
{
|
||||
const Uuid& typeId = azrtti_typeid<MetadataT>();
|
||||
if (m_data.find(typeId) != m_data.end())
|
||||
{
|
||||
AZ_Assert(false, "Metadata object of type %s already added", typeId.template ToString<AZStd::string>().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
m_data.emplace(typeId, AZStd::forward<MetadataT>(data));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -41,7 +53,7 @@ namespace AZ
|
||||
template<typename MetadataT>
|
||||
MetadataT* JsonSerializationMetadata::Find()
|
||||
{
|
||||
const auto& typeId = azrtti_typeid<MetadataT>();
|
||||
const Uuid& typeId = azrtti_typeid<MetadataT>();
|
||||
auto iter = m_data.find(typeId);
|
||||
return iter != m_data.end() ? AZStd::any_cast<MetadataT>(&iter->second) : nullptr;
|
||||
}
|
||||
|
||||
@@ -576,14 +576,32 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
aznumeric_cast<int>(projectPathKey.size()), projectPathKey.data());
|
||||
}
|
||||
|
||||
#if !AZ_TRAIT_USE_ASSET_CACHE_FOLDER
|
||||
// Setup the cache and user paths for Platforms where the Asset Cache Folder isn't used
|
||||
#if !AZ_TRAIT_OS_IS_HOST_OS_PLATFORM
|
||||
// Setup the cache and user paths when to platform specific locations when running on non-host platforms
|
||||
path = engineRoot;
|
||||
registry.Set(FilePathKey_CacheProjectRootFolder, path.LexicallyNormal().Native());
|
||||
registry.Set(FilePathKey_CacheRootFolder, path.LexicallyNormal().Native());
|
||||
registry.Set(FilePathKey_DevWriteStorage, path.LexicallyNormal().Native());
|
||||
registry.Set(FilePathKey_ProjectUserPath, (path / "user").LexicallyNormal().Native());
|
||||
#endif // AZ_TRAIT_USE_ASSET_CACHE_FOLDER
|
||||
if (AZStd::optional<AZ::IO::FixedMaxPathString> nonHostCacheRoot = Utils::GetDefaultAppRootPath();
|
||||
nonHostCacheRoot)
|
||||
{
|
||||
registry.Set(FilePathKey_CacheProjectRootFolder, *nonHostCacheRoot);
|
||||
registry.Set(FilePathKey_CacheRootFolder, *nonHostCacheRoot);
|
||||
}
|
||||
else
|
||||
{
|
||||
registry.Set(FilePathKey_CacheProjectRootFolder, path.LexicallyNormal().Native());
|
||||
registry.Set(FilePathKey_CacheRootFolder, path.LexicallyNormal().Native());
|
||||
}
|
||||
if (AZStd::optional<AZ::IO::FixedMaxPathString> devWriteStorage = Utils::GetDevWriteStoragePath();
|
||||
devWriteStorage)
|
||||
{
|
||||
registry.Set(FilePathKey_DevWriteStorage, *devWriteStorage);
|
||||
registry.Set(FilePathKey_ProjectUserPath, *devWriteStorage);
|
||||
}
|
||||
else
|
||||
{
|
||||
registry.Set(FilePathKey_DevWriteStorage, path.LexicallyNormal().Native());
|
||||
registry.Set(FilePathKey_ProjectUserPath, (path / "user").LexicallyNormal().Native());
|
||||
}
|
||||
#endif // AZ_TRAIT_OS_IS_HOST_OS_PLATFORM
|
||||
}
|
||||
|
||||
void MergeSettingsToRegistry_TargetBuildDependencyRegistry(SettingsRegistryInterface& registry, const AZStd::string_view platform,
|
||||
@@ -986,4 +1004,12 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
|
||||
return visitor.Finalize();
|
||||
}
|
||||
|
||||
bool IsPathAncestorDescendantOrEqual(AZStd::string_view candidatePath, AZStd::string_view inputPath)
|
||||
{
|
||||
AZ::IO::PathView candidateView{ candidatePath, AZ::IO::PosixPathSeparator };
|
||||
AZ::IO::PathView inputView{ inputPath, AZ::IO::PosixPathSeparator };
|
||||
return inputView.empty() || candidateView.IsRelativeTo(inputView) || inputView.IsRelativeTo(candidateView);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -256,4 +256,22 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
aznumeric_cast<int>(keyName.size()), keyName.data());
|
||||
return registry.Get(result, key);
|
||||
}
|
||||
|
||||
//! Check if the supplied input path is an ancestor, a descendant or exactly equal to the candidate path
|
||||
//! The can be used to check if a JSON pointer to a settings registry entry has potentially
|
||||
//! "modified" the object at candidate path or its children in notifications
|
||||
//! @param candidatePath Path which is being checked for the ancestor/descendant relationship
|
||||
//! @param inputPath Path which is checked to determine if it is an ancestor or descendant of the candidate path
|
||||
//! @return true if the input path is an ancestor, descendant or equal to the candidate path
|
||||
//! Example: input path is ancestor path of candidate path
|
||||
//! IsPathAncestorDescendantOrEqual("/Amazon/AzCore/Bootstrap", "/Amazon/AzCore") = true
|
||||
//! Example: input path is equal to candidate path
|
||||
//! IsPathAncestorDescendantOrEqual("/Amazon/AzCore/Bootstrap", "/Amazon/AzCore/Bootstrap") = true
|
||||
//! Example: input path is descendant of candidate path
|
||||
//! IsPathAncestorDescendantOrEqual("/Amazon/AzCore/Bootstrap", "/Amazon/AzCore/Bootstrap/project_path") = true
|
||||
//! //! Example: input path is unrelated to candidate path
|
||||
//! IsPathAncestorDescendantOrEqual("/Amazon/AzCore/Bootstrap", "/Amazon/Project/Settings/project_name") = false
|
||||
//! //! Example: The path "" is the root JSON pointer therefore that is the ancestor of all paths
|
||||
//! IsPathAncestorDescendantOrEqual("/Amazon/AzCore/Bootstrap", "") = true
|
||||
bool IsPathAncestorDescendantOrEqual(AZStd::string_view candidatePath, AZStd::string_view inputPath);
|
||||
}
|
||||
|
||||
@@ -2900,7 +2900,7 @@ namespace AZ
|
||||
{
|
||||
AZ::Data::AssetCatalogRequestBus::BroadcastResult(referencedSliceAssetPath, &AZ::Data::AssetCatalogRequests::GetAssetPathById, slice.GetSliceAsset()->GetId());
|
||||
}
|
||||
AZ_Error("Slices", false, "Slice with asset ID %s and path %s has an invalid slice reference to slice with path %s. The Lumberyard editor may be unstable, it is recommended you re-launch the editor.",
|
||||
AZ_Error("Slices", false, "Slice with asset ID %s and path %s has an invalid slice reference to slice with path %s. The Open 3D Engine editor may be unstable, it is recommended you re-launch the editor.",
|
||||
!m_myAsset ? "invalid asset" : m_myAsset->GetId().ToString<AZStd::string>().c_str(),
|
||||
mySliceAssetPath.empty() ? "invalid path" : mySliceAssetPath.c_str(),
|
||||
referencedSliceAssetPath.empty() ? "invalid path" : referencedSliceAssetPath.c_str());
|
||||
|
||||
@@ -769,8 +769,8 @@ namespace AZ
|
||||
*! This has similar behavior to Python pathlib '/' operator and os.path.join
|
||||
*! Specifically, that it uses the last absolute path as the anchor for the resulting path
|
||||
*! https://docs.python.org/3/library/pathlib.html#pathlib.PurePath
|
||||
*! This means that joining StringFunc::Path::Join("C:\\lumberyard" "F:\\lumberyard") results in "F:\\lumberyard"
|
||||
*! not "C:\\lumberyard\\F:\\lumberyard"
|
||||
*! This means that joining StringFunc::Path::Join("C:\\O3DE" "F:\\O3DE") results in "F:\\O3DE"
|
||||
*! not "C:\\O3DE\\F:\\O3DE"
|
||||
*! EX: StringFunc::Path::Join("C:\\p4\\game","info\\some.file", a) == true; a== "C:\\p4\\game\\info\\some.file"
|
||||
*! EX: StringFunc::Path::Join("C:\\p4\\game\\info", "game\\info\\some.file", a) == true; a== "C:\\p4\\game\\info\\game\\info\\some.file"
|
||||
*! EX: StringFunc::Path::Join("C:\\p4\\game\\info", "\\game\\info\\some.file", a) == true; a== "C:\\game\\info\\some.file"
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/UnitTest/UnitTest.h>
|
||||
#include <AzCore/Settings/SettingsRegistry.h>
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
class MockSettingsRegistry;
|
||||
using NiceSettingsRegistrySimpleMock = ::testing::NiceMock<MockSettingsRegistry>;
|
||||
|
||||
class MockSettingsRegistry
|
||||
: public AZ::SettingsRegistryInterface
|
||||
{
|
||||
public:
|
||||
MOCK_CONST_METHOD1(GetType, Type(AZStd::string_view));
|
||||
MOCK_CONST_METHOD2(Visit, bool(Visitor&, AZStd::string_view));
|
||||
MOCK_CONST_METHOD2(Visit, bool(const VisitorCallback&, AZStd::string_view));
|
||||
MOCK_METHOD1(RegisterNotifier, NotifyEventHandler(const NotifyCallback&));
|
||||
MOCK_METHOD1(RegisterNotifier, NotifyEventHandler(NotifyCallback&&));
|
||||
|
||||
MOCK_CONST_METHOD2(Get, bool(bool&, AZStd::string_view));
|
||||
MOCK_CONST_METHOD2(Get, bool(s64&, AZStd::string_view));
|
||||
MOCK_CONST_METHOD2(Get, bool(u64&, AZStd::string_view));
|
||||
MOCK_CONST_METHOD2(Get, bool(double&, AZStd::string_view));
|
||||
MOCK_CONST_METHOD2(Get, bool(AZStd::string&, AZStd::string_view));
|
||||
MOCK_CONST_METHOD2(Get, bool(FixedValueString&, AZStd::string_view));
|
||||
MOCK_CONST_METHOD3(GetObject, bool(void*, Uuid, AZStd::string_view));
|
||||
|
||||
MOCK_METHOD2(Set, bool(AZStd::string_view, bool));
|
||||
MOCK_METHOD2(Set, bool(AZStd::string_view, s64));
|
||||
MOCK_METHOD2(Set, bool(AZStd::string_view, u64));
|
||||
MOCK_METHOD2(Set, bool(AZStd::string_view, double));
|
||||
MOCK_METHOD2(Set, bool(AZStd::string_view, AZStd::string_view));
|
||||
MOCK_METHOD2(Set, bool(AZStd::string_view, const char*));
|
||||
MOCK_METHOD3(SetObject, bool(AZStd::string_view, const void*, Uuid));
|
||||
|
||||
MOCK_METHOD1(Remove, bool(AZStd::string_view));
|
||||
|
||||
MOCK_METHOD3(MergeCommandLineArgument, bool(AZStd::string_view, AZStd::string_view, const CommandLineArgumentSettings&));
|
||||
MOCK_METHOD2(MergeSettings, bool(AZStd::string_view, Format));
|
||||
MOCK_METHOD4(MergeSettingsFile, bool(AZStd::string_view, Format, AZStd::string_view, AZStd::vector<char>*));
|
||||
MOCK_METHOD5(
|
||||
MergeSettingsFolder,
|
||||
bool(AZStd::string_view, const Specializations&, AZStd::string_view, AZStd::string_view, AZStd::vector<char>*));
|
||||
};
|
||||
} // namespace AZ
|
||||
|
||||
@@ -278,7 +278,7 @@ namespace UnitTest
|
||||
#define AZ_TEST_STATIC_ASSERT(_Exp) static_assert(_Exp, "Test Static Assert")
|
||||
#ifdef AZ_ENABLE_TRACING
|
||||
/*
|
||||
* The AZ_TEST_START_ASSERTTEST and AZ_TEST_STOP_ASSERTTEST macros have been deprecated and will be removed in a future Lumberyard release.
|
||||
* The AZ_TEST_START_ASSERTTEST and AZ_TEST_STOP_ASSERTTEST macros have been deprecated and will be removed in a future Open 3D Engine release.
|
||||
* The AZ_TEST_START_TRACE_SUPPRESSION and AZ_TEST_STOP_TRACE_SUPPRESSION is the recommend macros
|
||||
* The reason for the deprecation is that the AZ_TEST_(START|STOP)_ASSERTTEST implies that they should be used to for writing assert unit test
|
||||
* where the asserts themselves are expected to cause the test process to terminate.
|
||||
|
||||
@@ -15,4 +15,5 @@ set(FILES
|
||||
UnitTest/UnitTest.h
|
||||
UnitTest/TestTypes.h
|
||||
UnitTest/Mocks/MockFileIOBase.h
|
||||
UnitTest/Mocks/MockSettingsRegistry.h
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user