StorableFile.hpp 1.2 KB

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