Converter.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/Component/ComponentApplicationBus.h>
  10. #include <AzCore/IO/Path/Path_fwd.h>
  11. #include <AzCore/JSON/document.h>
  12. #include <AzCore/JSON/stringbuffer.h>
  13. #include <AzCore/Serialization/Json/JsonSerialization.h>
  14. #include <AzCore/std/utils.h>
  15. #include <AzCore/std/containers/vector.h>
  16. #include <AzCore/std/string/string.h>
  17. namespace AZ
  18. {
  19. class CommandLine;
  20. class Entity;
  21. class ModuleEntity;
  22. class SerializeContext;
  23. struct Uuid;
  24. namespace SerializeContextTools
  25. {
  26. class Application;
  27. class Converter
  28. {
  29. public:
  30. static bool ConvertObjectStreamFiles(Application& application);
  31. //! Converts Windows INI Style File
  32. //! Can be used to convert *.ini and *.cfg files
  33. static bool ConvertConfigFile(Application& application);
  34. protected:
  35. using PathDocumentPair = AZStd::pair<AZStd::string, rapidjson::Document>;
  36. using PathDocumentContainer = AZStd::vector<PathDocumentPair>;
  37. static bool VerifyConvertedData(rapidjson::Value& convertedData, const void* original, const Uuid& originalType,
  38. const JsonDeserializerSettings& settings);
  39. static AZStd::string GetClassName(const Uuid& classId, SerializeContext* context);
  40. static bool WriteDocumentToDisk(const AZStd::string& filename, const rapidjson::Document& document, AZStd::string_view documentRoot,
  41. rapidjson::StringBuffer& scratchBuffer);
  42. static void SetupLogging(AZStd::string& scratchBuffer, JsonSerializationResult::JsonIssueCallback& callback,
  43. const AZ::CommandLine& commandLine);
  44. static JsonSerializationResult::ResultCode VerboseLogging(AZStd::string& scratchBuffer, AZStd::string_view message,
  45. JsonSerializationResult::ResultCode result, AZStd::string_view target);
  46. static AZ::JsonSerializationResult::ResultCode SimpleLogging(AZStd::string& scratchBuffer, AZStd::string_view message,
  47. JsonSerializationResult::ResultCode result, AZStd::string_view target);
  48. };
  49. } // namespace SerializeContextTools
  50. } // namespace AZ