NamedData.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. // Description : Collection of Named data blocks
  9. #ifndef CRYINCLUDE_EDITOR_UTIL_NAMEDDATA_H
  10. #define CRYINCLUDE_EDITOR_UTIL_NAMEDDATA_H
  11. #pragma once
  12. #include "MemoryBlock.h"
  13. #include "QtUtil.h"
  14. class CPakFile;
  15. class CNamedData
  16. {
  17. public:
  18. CNamedData();
  19. virtual ~CNamedData();
  20. void AddDataBlock(const QString& blockName, void* pData, int nSize, bool bCompress = true);
  21. void AddDataBlock(const QString& blockName, CMemoryBlock& block);
  22. //! Returns uncompressed block data.
  23. bool GetDataBlock(const QString& blockName, void*& pData, int& nSize);
  24. //! Returns raw data block in original form (Compressed or Uncompressed).
  25. CMemoryBlock* GetDataBlock(const QString& blockName, bool& bCompressed);
  26. void Clear();
  27. public:
  28. virtual bool Serialize(CArchive& ar);
  29. //! Save named data to pak file.
  30. void Save(CPakFile& pakFile);
  31. //! Load named data from pak file.
  32. bool Load(const QString& levelPath, CPakFile& pakFile);
  33. void SaveToFiles(const QString& rootPath);
  34. void LoadFromFiles(const QString& rootPath);
  35. private:
  36. struct DataBlock
  37. {
  38. DataBlock();
  39. QString blockName;
  40. CMemoryBlock data;
  41. CMemoryBlock compressedData;
  42. //! This block is compressed.
  43. bool bCompressed;
  44. bool bFastCompression;
  45. };
  46. typedef std::map<QString, DataBlock*, stl::less_stricmp<QString> > TBlocks;
  47. TBlocks m_blocks;
  48. };
  49. #endif // CRYINCLUDE_EDITOR_UTIL_NAMEDDATA_H