XmlArchive.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 : Stores XML in MFC archive.
  9. #ifndef CRYINCLUDE_EDITOR_UTIL_XMLARCHIVE_H
  10. #define CRYINCLUDE_EDITOR_UTIL_XMLARCHIVE_H
  11. #pragma once
  12. #include "NamedData.h"
  13. #include "EditorUtils.h"
  14. class CPakFile;
  15. /*!
  16. * CXmlArcive used to stores XML in MFC archive.
  17. */
  18. class CXmlArchive
  19. {
  20. public:
  21. XmlNodeRef root;
  22. CNamedData* pNamedData;
  23. bool bLoading;
  24. bool bOwnNamedData;
  25. CXmlArchive()
  26. {
  27. bLoading = false;
  28. bOwnNamedData = true;
  29. pNamedData = new CNamedData;
  30. };
  31. explicit CXmlArchive(const QString& xmlRoot)
  32. {
  33. bLoading = false;
  34. bOwnNamedData = true;
  35. pNamedData = new CNamedData;
  36. root = XmlHelpers::CreateXmlNode(xmlRoot.toUtf8().data());
  37. };
  38. ~CXmlArchive()
  39. {
  40. if (bOwnNamedData)
  41. {
  42. delete pNamedData;
  43. }
  44. };
  45. CXmlArchive(const CXmlArchive& ar) { *this = ar; }
  46. CXmlArchive& operator=(const CXmlArchive& ar)
  47. {
  48. root = ar.root;
  49. pNamedData = ar.pNamedData;
  50. bLoading = ar.bLoading;
  51. bOwnNamedData = false;
  52. return *this;
  53. }
  54. //! Save XML Archive to pak file.
  55. //! @return true if saved.
  56. bool SaveToPak(const QString& levelPath, CPakFile& pakFile);
  57. bool LoadFromPak(const QString& levelPath, CPakFile& pakFile);
  58. };
  59. #endif // CRYINCLUDE_EDITOR_UTIL_XMLARCHIVE_H