CSaveFile.h 849 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * CSaveFile.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "BinarySerializer.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class DLL_LINKAGE CSaveFile : public IBinaryWriter
  14. {
  15. public:
  16. BinarySerializer serializer;
  17. boost::filesystem::path fName;
  18. std::unique_ptr<std::fstream> sfile;
  19. CSaveFile(const boost::filesystem::path &fname); //throws!
  20. ~CSaveFile();
  21. int write(const std::byte * data, unsigned size) override;
  22. void openNextFile(const boost::filesystem::path &fname); //throws!
  23. void clear();
  24. void putMagicBytes(const std::string &text);
  25. template<class T>
  26. CSaveFile & operator<<(const T &t)
  27. {
  28. serializer & t;
  29. return * this;
  30. }
  31. };
  32. VCMI_LIB_NAMESPACE_END