Gamedev Framework (gf)  0.11.0
A C++14 framework for 2D games
Public Types | Public Member Functions | List of all members
gf::FileOutputStream Class Reference

File based output stream. More...

#include <gf/Streams.h>

Inheritance diagram for gf::FileOutputStream:
Inheritance graph
[legend]

Public Types

enum  Mode {
  Mode::Write,
  Mode::Append
}
 Open mode for the file. More...
 

Public Member Functions

 FileOutputStream (const Path &path, Mode mode=Mode::Write)
 Constructor. More...
 
 ~FileOutputStream ()
 Destructor. More...
 
virtual std::size_t write (ArrayRef< uint8_t > buffer) override
 Write data to the stream. More...
 
virtual std::size_t getWrittenBytesCount () const override
 Get the number of bytes already written. More...
 
- Public Member Functions inherited from gf::OutputStream
 OutputStream ()=default
 Default constructor. More...
 
 OutputStream (const InputStream &)=delete
 Deleted copy constructor. More...
 
OutputStreamoperator= (const InputStream &)=delete
 Deleted copy assignment. More...
 
virtual ~OutputStream ()
 Destructor. More...
 
std::size_t write (uint8_t byte)
 Write a single byte to the stream. More...
 

Detailed Description

File based output stream.

Member Enumeration Documentation

◆ Mode

Open mode for the file.

Enumerator
Write 

Open the file in write only mode.

Append 

Open the file in append only mode.

Constructor & Destructor Documentation

◆ FileOutputStream()

gf::FileOutputStream::FileOutputStream ( const Path path,
Mode  mode = Mode::Write 
)

Constructor.

The constructor opens the file. If the file is not opened, an exception is thrown.

Parameters
pathThe path to the file
modeThe open mode of the file

◆ ~FileOutputStream()

gf::FileOutputStream::~FileOutputStream ( )

Destructor.

The destructor closes the file.

Member Function Documentation

◆ getWrittenBytesCount()

virtual std::size_t gf::FileOutputStream::getWrittenBytesCount ( ) const
overridevirtual

Get the number of bytes already written.

This function returns the number of bytes actually written i.e. it does not take into account possible bytes that have not been flushed yet.

Returns
The number of written bytes

Implements gf::OutputStream.

◆ write()

virtual std::size_t gf::FileOutputStream::write ( ArrayRef< uint8_t >  buffer)
overridevirtual

Write data to the stream.

Parameters
bufferThe buffer to copy to the stream
Returns
The number of bytes actually written

Implements gf::OutputStream.