StorableFile.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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-09
  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. * */
  19. namespace ls::std::io
  20. {
  21. class LS_STD_DYNAMIC_GOAL StorableFile : public ls::std::core::interface_type::IStorable
  22. {
  23. public:
  24. explicit StorableFile(const ::std::string &_path);
  25. ~StorableFile() noexcept override;
  26. [[nodiscard]] ::std::shared_ptr<ls::std::io::File> getFile() const;
  27. [[nodiscard]] ls::std::core::type::byte_field load() override;
  28. void reset(const ::std::string &_path);
  29. void save(const ls::std::core::type::byte_field &_data) override;
  30. private:
  31. ::std::shared_ptr<ls::std::io::File> file{};
  32. void _init(const ::std::string &_path);
  33. };
  34. }
  35. #endif