Dumper.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/JSON/document.h>
  10. #include <AzCore/Math/Uuid.h>
  11. #include <AzCore/Serialization/SerializeContext.h>
  12. #include <AzCore/std/containers/vector.h>
  13. #include <AzCore/std/string/string.h>
  14. #include <AzCore/std/string/string_view.h>
  15. namespace AZ::IO
  16. {
  17. class GenericStream;
  18. }
  19. namespace AZ::SerializeContextTools
  20. {
  21. class Application;
  22. class Dumper
  23. {
  24. public:
  25. static bool DumpFiles(Application& application);
  26. static bool DumpSerializeContext(Application& application);
  27. static bool DumpTypes(Application& application);
  28. static bool CreateType(Application& application);
  29. static bool CreateUuid(Application& application);
  30. private:
  31. static AZStd::vector<Uuid> CreateFilterListByNames(SerializeContext* context, AZStd::string_view name);
  32. static AZStd::string_view ExtractNamespace(const AZStd::string& name);
  33. static rapidjson::Value WriteToJsonValue(const Uuid& uuid, rapidjson::Document& document);
  34. static bool DumpClassContent(const SerializeContext::ClassData* classData, rapidjson::Value& parent, rapidjson::Document& document,
  35. const AZStd::vector<Uuid>& systemComponents, SerializeContext* context, AZStd::string& scratchStringBuffer);
  36. static bool DumpClassContent(AZStd::string& output, void* classPtr, const Uuid& classId, SerializeContext* context);
  37. static void DumpElementInfo(const SerializeContext::ClassElement& element, const SerializeContext::ClassData* classData, SerializeContext* context,
  38. rapidjson::Value& fields, rapidjson::Value& bases, rapidjson::Document& document, AZStd::string& scratchStringBuffer);
  39. static void DumpElementInfo(AZStd::string& output, const SerializeContext::ClassElement* classElement, SerializeContext* context);
  40. static void DumpGenericStructure(AZStd::string& output, GenericClassInfo* genericClassInfo, SerializeContext* context);
  41. static rapidjson::Value DumpGenericStructure(GenericClassInfo* genericClassInfo, SerializeContext* context,
  42. rapidjson::Document& parentDoc, AZStd::string& scratchStringBuffer);
  43. static void DumpPrimitiveTag(AZStd::string& output, const SerializeContext::ClassData* classData,
  44. const SerializeContext::ClassElement* classElement);
  45. static void DumpClassName(rapidjson::Value& parent, SerializeContext* context, const SerializeContext::ClassData* classData,
  46. rapidjson::Document& parentDoc, AZStd::string& scratchStringBuffer);
  47. static void AppendTypeName(AZStd::string& output, const SerializeContext::ClassData* classData, const Uuid& classId);
  48. static bool WriteDocumentToStream(AZ::IO::GenericStream& outputstream, const rapidjson::Document& document,
  49. AZStd::string_view pointerRoot);
  50. };
  51. } // namespace AZ::SerializeContextTools