Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Nz::Stream Class Referenceabstract

Core class that represents a stream. More...

Inheritance diagram for Nz::Stream:
Nz::File Nz::MemoryStream Nz::MemoryView Nz::TcpClient

Public Member Functions

 Stream (const Stream &)=default
 
 Stream (Stream &&)=default
 
virtual ~Stream ()
 Destructs the object.
 
virtual bool EndOfStream () const =0
 
void EnableTextMode (bool textMode)
 Enables the text mode. More...
 
void Flush ()
 Flushes the stream. More...
 
virtual UInt64 GetCursorPos () const =0
 
virtual String GetDirectory () const
 Gets the directory of the stream. More...
 
virtual String GetPath () const
 Gets the path of the stream. More...
 
OpenModeFlags GetOpenMode () const
 Gets the open mode of the stream. More...
 
StreamOptionFlags GetStreamOptions () const
 Gets the options of the stream. More...
 
virtual UInt64 GetSize () const =0
 
std::size_t Read (void *buffer, std::size_t size)
 Reads the stream and puts the result in a buffer. More...
 
virtual String ReadLine (unsigned int lineSize=0)
 Reads a line from the stream. More...
 
bool IsReadable () const
 Checks whether the stream is readable. More...
 
bool IsSequential () const
 Checks whether the stream is sequential. More...
 
bool IsTextModeEnabled () const
 Checks whether the stream has text mode enabled. More...
 
bool IsWritable () const
 Checks whether the stream can be written. More...
 
virtual bool SetCursorPos (UInt64 offset)=0
 
bool Write (const ByteArray &byteArray)
 Writes a ByteArray into the stream. More...
 
bool Write (const String &string)
 Writes a String into the stream. More...
 
std::size_t Write (const void *buffer, std::size_t size)
 Writes in the stream the content of a buffer. More...
 
Streamoperator= (const Stream &)=default
 
Streamoperator= (Stream &&)=default
 

Protected Member Functions

 Stream (StreamOptionFlags streamOptions=StreamOption_None, OpenModeFlags openMode=OpenMode_NotOpen)
 Constructs a Stream object with options. More...
 
virtual void FlushStream ()=0
 
virtual std::size_t ReadBlock (void *buffer, std::size_t size)=0
 
virtual std::size_t WriteBlock (const void *buffer, std::size_t size)=0
 

Protected Attributes

OpenModeFlags m_openMode
 
StreamOptionFlags m_streamOptions
 

Detailed Description

Core class that represents a stream.

Member Function Documentation

◆ EnableTextMode()

void Nz::Stream::EnableTextMode ( bool  textMode)
inline

Enables the text mode.

Parameters
textModeEnables the mode or disables

◆ Flush()

void Nz::Stream::Flush ( )
inline

Flushes the stream.

Remarks
Produces a NazaraAssert if file is not writable

◆ GetDirectory()

String Nz::Stream::GetDirectory ( ) const
virtual

Gets the directory of the stream.

Returns
Empty string (meant to be virtual)

Reimplemented in Nz::File.

◆ GetOpenMode()

OpenModeFlags Nz::Stream::GetOpenMode ( ) const
inline

Gets the open mode of the stream.

Returns
Reading/writing mode for the stream

◆ GetPath()

String Nz::Stream::GetPath ( ) const
virtual

Gets the path of the stream.

Returns
Empty string (meant to be virtual)

Reimplemented in Nz::File.

◆ GetStreamOptions()

StreamOptionFlags Nz::Stream::GetStreamOptions ( ) const
inline

Gets the options of the stream.

Returns
Options of the stream

◆ IsReadable()

bool Nz::Stream::IsReadable ( ) const
inline

Checks whether the stream is readable.

Returns
true if it is the case

◆ IsSequential()

bool Nz::Stream::IsSequential ( ) const
inline

Checks whether the stream is sequential.

Returns
true if it is the case

◆ IsTextModeEnabled()

bool Nz::Stream::IsTextModeEnabled ( ) const
inline

Checks whether the stream has text mode enabled.

Returns
true if it is the case

◆ IsWritable()

bool Nz::Stream::IsWritable ( ) const
inline

Checks whether the stream can be written.

Returns
true if it is the case

◆ Read()

std::size_t Nz::Stream::Read ( void *  buffer,
std::size_t  size 
)
inline

Reads the stream and puts the result in a buffer.

Returns
Size of the read
Parameters
bufferBuffer to stock data
sizeSize meant to be read
Remarks
Produces a NazaraAssert if stream is not readable
If preallocated space of buffer is less than the size, the behavior is undefined

◆ ReadLine()

String Nz::Stream::ReadLine ( unsigned int  lineSize = 0)
virtual

Reads a line from the stream.

Reads the stream until a line separator or the end of the stream is found.

If lineSize does not equal zero, it represents the maximum character count to be read from the stream.

Parameters
lineSizeMaximum number of characters to read, or zero for no limit
Returns
Line containing characters
Remarks
With the text stream option, "\r\n" is treated as "\n"
The line separator character is not returned as part of the string

◆ Write() [1/3]

bool Nz::Stream::Write ( const ByteArray byteArray)

Writes a ByteArray into the stream.

Returns
true if successful
Parameters
byteArrayBytes to write

◆ Write() [2/3]

bool Nz::Stream::Write ( const String string)

Writes a String into the stream.

Returns
true if successful
Parameters
stringString to write

◆ Write() [3/3]

std::size_t Nz::Stream::Write ( const void *  buffer,
std::size_t  size 
)
inline

Writes in the stream the content of a buffer.

Returns
Size of the writing
Parameters
bufferBuffer to get data from
sizeSize meant to be written
Remarks
Produces a NazaraAssert if stream is not writable
If preallocated space of buffer is less than the size, the behavior is undefined

The documentation for this class was generated from the following files: