FileOutputStream.hpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-20
  6. * Changed: 2023-02-22
  7. *
  8. * */
  9. #ifndef LS_STD_FILE_OUTPUT_STREAM_HPP
  10. #define LS_STD_FILE_OUTPUT_STREAM_HPP
  11. #include "File.hpp"
  12. #include <fstream>
  13. #include <ls-std/core/Class.hpp>
  14. #include <ls-std/core/interface/IWriter.hpp>
  15. #include <ls-std/os/dynamic-goal.hpp>
  16. namespace ls::std::io
  17. {
  18. class LS_STD_DYNAMIC_GOAL FileOutputStream : public ls::std::core::Class, public ls::std::core::interface_type::IWriter
  19. {
  20. public:
  21. explicit FileOutputStream(ls::std::io::File &_file);
  22. explicit FileOutputStream(ls::std::io::File &_file, bool _append);
  23. ~FileOutputStream() noexcept override;
  24. void close();
  25. bool write(const ls::std::core::type::byte_field &_data) override; // nodiscard is optional here
  26. private:
  27. bool append{};
  28. ls::std::io::File file;
  29. ::std::ofstream outputStream{};
  30. void _close();
  31. void _init();
  32. };
  33. }
  34. #endif