StorableFile.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-19
  6. * Changed: 2024-09-13
  7. *
  8. * */
  9. #ifndef LS_STD_STORABLE_FILE_HPP
  10. #define LS_STD_STORABLE_FILE_HPP
  11. #include "File.hpp"
  12. #include <ls-std/core/interface/IStorable.hpp>
  13. #include <ls-std/os/dynamic-goal.hpp>
  14. #include <memory>
  15. #include <string>
  16. /*
  17. * @doc: class(name: 'StorableFile', package: 'io')
  18. * @doc: io.StorableFile.description('This class can be used to store any serialized information to a file.')
  19. * */
  20. namespace ls::std::io
  21. {
  22. class LS_STD_DYNAMIC_GOAL StorableFile : public ls::std::core::interface_type::IStorable
  23. {
  24. public:
  25. explicit StorableFile(const ::std::string &_path);
  26. ~StorableFile() noexcept override;
  27. [[nodiscard]] ::std::shared_ptr<ls::std::io::File> getFile() const;
  28. [[nodiscard]] ls::std::core::type::byte_field load() override;
  29. void reset(const ::std::string &_path);
  30. void save(const ls::std::core::type::byte_field &_data) override;
  31. private:
  32. ::std::shared_ptr<ls::std::io::File> file{};
  33. void _init(const ::std::string &_path);
  34. };
  35. }
  36. #endif