XMLBinaryHeaders.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #ifndef CRYINCLUDE_CRYCOMMON_XMLBINARYHEADERS_H
  9. #define CRYINCLUDE_CRYCOMMON_XMLBINARYHEADERS_H
  10. #pragma once
  11. namespace XMLBinary
  12. {
  13. class IDataWriter
  14. {
  15. public:
  16. virtual ~IDataWriter() {}
  17. virtual void Write(const void* pData, size_t size) = 0;
  18. };
  19. class IFilter
  20. {
  21. public:
  22. enum EType
  23. {
  24. eType_ElementName,
  25. eType_AttributeName
  26. };
  27. virtual ~IFilter() {}
  28. virtual bool IsAccepted(EType type, const char* pName) const = 0;
  29. };
  30. //////////////////////////////////////////////////////////////////////////
  31. typedef uint32 NodeIndex; // note: only uint32 or uint16 are supported
  32. template<int size>
  33. struct Pad
  34. {
  35. char pad[size];
  36. };
  37. template<>
  38. struct Pad<0> { };
  39. struct Node
  40. {
  41. uint32 nTagStringOffset; // offset in CBinaryXmlData::pStringData
  42. uint32 nContentStringOffset; // offset in CBinaryXmlData::pStringData
  43. uint16 nAttributeCount;
  44. uint16 nChildCount;
  45. NodeIndex nParentIndex;
  46. NodeIndex nFirstAttributeIndex;
  47. NodeIndex nFirstChildIndex;
  48. Pad<sizeof(uint32) - sizeof(NodeIndex)> reserved_for_alignment;
  49. };
  50. struct Attribute
  51. {
  52. uint32 nKeyStringOffset; // offset in CBinaryXmlData::pStringData
  53. uint32 nValueStringOffset; // offset in CBinaryXmlData::pStringData
  54. };
  55. struct BinaryFileHeader
  56. {
  57. char szSignature[8];
  58. uint32 nXMLSize;
  59. uint32 nNodeTablePosition;
  60. uint32 nNodeCount;
  61. uint32 nAttributeTablePosition;
  62. uint32 nAttributeCount;
  63. uint32 nChildTablePosition;
  64. uint32 nChildCount;
  65. uint32 nStringDataPosition;
  66. uint32 nStringDataSize;
  67. };
  68. }
  69. #endif // CRYINCLUDE_CRYCOMMON_XMLBINARYHEADERS_H