StevEngine
StevEngine is a customizable C++ game engine.
Loading...
Searching...
No Matches
StevEngine::Utilities::Stream Class Reference

Stream for serialization of data. More...

#include <utilities/Stream.hpp>

Public Member Functions

 Stream (StreamType type)
 Create new stream of type.
 
template<typename T>
Read ()
 Read data of specified type from stream.
 
template<typename T>
void Write (const T &data)
 Write data of specified type to stream.
 
template<typename T>
Streamoperator<< (const T &data)
 Write data of specified type to stream.
 
template<typename T>
Streamoperator>> (T &out)
 Read data of specified type from stream.
 
void WriteToFile (const char *path) const
 Write full stream content to a file.
 
void ReadFromFile (const Resources::Resource &file)
 Read content from a file to stream.
 
void ReadFromFile (std::ifstream &file)
 Read content from an input file stream to stream.
 
std::stringstream & GetStream ()
 Get underlying std::stringstream object.
 
const std::stringstream & GetStream () const
 Get underlying std::stringstream object.
 
 Stream (const Stream &stream)
 make a copy of a stream
 
template<>
void Write (const Stream &data)
 
template<>
char Read ()
 
template<>
void Write (const char &data)
 
template<>
bool Read ()
 
template<>
void Write (const bool &data)
 
template<>
uint8_t Read ()
 
template<>
void Write (const uint8_t &data)
 
template<>
uint16_t Read ()
 
template<>
void Write (const uint16_t &data)
 
template<>
uint32_t Read ()
 
template<>
void Write (const uint32_t &data)
 
template<>
int Read ()
 
template<>
void Write (const int &data)
 
template<>
long Read ()
 
template<>
void Write (const long &data)
 
template<>
uint64_t Read ()
 
template<>
void Write (const uint64_t &data)
 
template<>
float Read ()
 
template<>
void Write (const float &data)
 
template<>
double Read ()
 
template<>
void Write (const double &data)
 

Public Attributes

const StreamType type
 Type of serialization used by stream.
 

Protected Attributes

std::stringstream stream
 

Detailed Description

Stream for serialization of data.

Handles writing and reading basic data types, utility types, components, GameObjects etc. to a text or binary stream.

Constructor & Destructor Documentation

◆ Stream() [1/2]

StevEngine::Utilities::Stream::Stream ( StreamType type)
inline

Create new stream of type.

Parameters
typeType of stream to create

◆ Stream() [2/2]

StevEngine::Utilities::Stream::Stream ( const Stream & stream)
inline

make a copy of a stream

Parameters
streamStream to copy

Member Function Documentation

◆ GetStream() [1/2]

std::stringstream & StevEngine::Utilities::Stream::GetStream ( )
inline

Get underlying std::stringstream object.

Returns
Underlying std::stringstream

◆ GetStream() [2/2]

const std::stringstream & StevEngine::Utilities::Stream::GetStream ( ) const
inline

Get underlying std::stringstream object.

Returns
Underlying std::stringstream

◆ operator<<()

template<typename T>
Stream & StevEngine::Utilities::Stream::operator<< ( const T & data)
inline

Write data of specified type to stream.

Template Parameters
TType of data to write
Parameters
dataValue to write

◆ operator>>()

template<typename T>
Stream & StevEngine::Utilities::Stream::operator>> ( T & out)
inline

Read data of specified type from stream.

Template Parameters
TType of data to read
Returns
Read value of type T

◆ Read()

template<typename T>
T StevEngine::Utilities::Stream::Read ( )

Read data of specified type from stream.

Template Parameters
TType of data to read
Returns
Read value of type T

◆ ReadFromFile() [1/2]

void StevEngine::Utilities::Stream::ReadFromFile ( const Resources::Resource & file)

Read content from a file to stream.

Parameters
fileFile to read from

◆ ReadFromFile() [2/2]

void StevEngine::Utilities::Stream::ReadFromFile ( std::ifstream & file)

Read content from an input file stream to stream.

Parameters
fileInput file stream to read from

◆ Write()

template<typename T>
void StevEngine::Utilities::Stream::Write ( const T & data)

Write data of specified type to stream.

Template Parameters
TType of data to write
Parameters
dataValue to write

◆ WriteToFile()

void StevEngine::Utilities::Stream::WriteToFile ( const char * path) const

Write full stream content to a file.

Parameters
pathPath of the file to write to

Writes the full stream content to a file with the specified path.


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