Gorgon Game Engine
Gorgon::IO Namespace Reference

Classes

class  MemoryInputBuffer
 This class is an input only memory stream buffer. More...
 
class  MemoryInputStream
 

Functions

template<class T_ >
void ReadArray (std::istream &stream, T_ *data, unsigned long size)
 Reads an array from the stream. More...
 
bool ReadBool (std::istream &stream)
 Reads a boolean value. In resource 1.0, booleans are stored as 32bit integers. More...
 
double ReadDouble (std::istream &stream)
 Reads a 64 bit IEEE double precision floating point number from the stream. More...
 
template<class E_ >
E_ ReadEnum32 (std::istream &stream)
 Reads an enumeration that is saved as 32bit integer. More...
 
float ReadFloat (std::istream &stream)
 Reads a 32 bit IEEE floating point number from the stream. More...
 
SGuid ReadGuid (std::istream &stream)
 Reads a GUID from the given stream. More...
 
int ReadInt16 (std::istream &stream)
 Reads a 16-bit integer from the stream. More...
 
long ReadInt32 (std::istream &stream)
 Reads a 32-bit integer from the stream. More...
 
char ReadInt8 (std::istream &stream)
 Reads an 8-bit integer from the stream. More...
 
Geometry::Point ReadPoint (std::istream &stream)
 
Geometry::Pointf ReadPointf (std::istream &stream)
 
Graphics::RGBA ReadRGBA (std::istream &stream)
 Reads a RGBA color, R will be read first. More...
 
Graphics::RGBAf ReadRGBAf (std::istream &stream)
 Reads a RGBAf color, R will be read first. More...
 
Geometry::Size ReadSize (std::istream &stream)
 
std::string ReadString (std::istream &stream)
 Reads a string from a given stream. More...
 
std::string ReadString (std::istream &stream, unsigned long size)
 Reads a string with the given size. More...
 
unsigned ReadUInt16 (std::istream &stream)
 Reads a 16-bit unsigned integer from the stream. More...
 
unsigned long ReadUInt32 (std::istream &stream)
 Reads a 32-bit unsigned integer from the stream. More...
 
Byte ReadUInt8 (std::istream &stream)
 Reads an 8-bit unsigned integer from the stream. More...
 
template<class T_ >
void WriteArray (std::ostream &stream, const T_ *data, unsigned long size)
 Writes an array to the stream. More...
 
void WriteBool (std::ostream &stream, bool value)
 Writes a boolean value. In resource 1.0, booleans are stored as 32bit integers. More...
 
void WriteDouble (std::ostream &stream, double value)
 Writes a 64 bit IEEE double precision floating point number from the stream. More...
 
template<class E_ >
void WriteEnum32 (std::ostream &stream, E_ v)
 Writes an enumeration as a 32-bit integer. More...
 
void WriteFloat (std::ostream &stream, float value)
 Writes a 32 bit IEEE floating point number from the stream. More...
 
void WriteGuid (std::ostream &stream, const SGuid &value)
 Writes a GUID from the given stream. More...
 
void WriteInt16 (std::ostream &stream, int value)
 Writes a 16-bit integer from the stream. More...
 
void WriteInt32 (std::ostream &stream, long value)
 Writes a 32-bit integer to the stream. More...
 
void WriteInt8 (std::ostream &stream, char value)
 Writes an 8-bit integer from the stream. More...
 
void WritePoint (std::ostream &stream, Geometry::Point p)
 Saves the point as two consecutive 32bit integers. More...
 
template<class F_ = Float>
std::enable_if< std::is_same< F_, float >::value, void >::type WritePointf (std::ostream &stream, Geometry::Pointf p)
 Saves the point as two consecutive floats. This function will not work if float type is double. More...
 
void WriteRGBA (std::ostream &stream, Graphics::RGBA value)
 Writes a RGBA color, R will be saved first. More...
 
void WriteRGBAf (std::ostream &stream, Graphics::RGBAf value)
 Writes a RGBAf color, R will be saved first. More...
 
void WriteSize (std::ostream &stream, Geometry::Size s)
 Saves the size as two consecutive 32bit integers. More...
 
void WriteString (std::ostream &stream, const std::string &value)
 Writes a string without its size. More...
 
void WriteStringWithSize (std::ostream &stream, const std::string &value)
 Writes a string from a given stream. More...
 
void WriteUInt16 (std::ostream &stream, unsigned value)
 Writes a 16-bit unsigned integer from the stream. More...
 
void WriteUInt32 (std::ostream &stream, unsigned long value)
 Writes a 32-bit unsigned integer from the stream. More...
 
void WriteUInt8 (std::ostream &stream, Byte value)
 Writes an 8-bit unsigned integer from the stream. More...
 
template<class T_ >
void WriteVector (std::ostream &stream, const std::vector< T_ > &data)
 Writes a vector to the stream. More...
 

Function Documentation

◆ ReadArray()

void Gorgon::IO::ReadArray ( std::istream &  stream,
T_ *  data,
unsigned long  size 
)

Reads an array from the stream.

Array type should be a fixed size construct (ie. a byte, int32_t), otherwise a mismatch between binary formats will cause trouble.

Parameters
datais the data to be read from the stream
sizeis the number of elements to be read

◆ ReadBool()

bool Gorgon::IO::ReadBool ( std::istream &  stream)

Reads a boolean value. In resource 1.0, booleans are stored as 32bit integers.

References ReadInt32().

◆ ReadDouble()

double Gorgon::IO::ReadDouble ( std::istream &  stream)

Reads a 64 bit IEEE double precision floating point number from the stream.

This function only works on systems that have native 64 bit doubles.

◆ ReadEnum32()

E_ Gorgon::IO::ReadEnum32 ( std::istream &  stream)

Reads an enumeration that is saved as 32bit integer.

◆ ReadFloat()

float Gorgon::IO::ReadFloat ( std::istream &  stream)

Reads a 32 bit IEEE floating point number from the stream.

This function only works on systems that that have native 32 bit floats.

◆ ReadGuid()

SGuid Gorgon::IO::ReadGuid ( std::istream &  stream)

Reads a GUID from the given stream.

References Gorgon::Resource::GID::SGuid.

◆ ReadInt16()

int Gorgon::IO::ReadInt16 ( std::istream &  stream)

Reads a 16-bit integer from the stream.

An int is at least 16 bits, could be more however, only 2 bytes will be read from the stream

◆ ReadInt32()

long Gorgon::IO::ReadInt32 ( std::istream &  stream)

Reads a 32-bit integer from the stream.

A long is at least 32 bits, could be more however, only 4 bytes will be read from the stream

◆ ReadInt8()

char Gorgon::IO::ReadInt8 ( std::istream &  stream)

Reads an 8-bit integer from the stream.

A char is at least 8 bits, could be more however, only 1 byte will be read from the stream

◆ ReadPoint()

Geometry::Point Gorgon::IO::ReadPoint ( std::istream &  stream)

References ReadInt32().

◆ ReadPointf()

Geometry::Pointf Gorgon::IO::ReadPointf ( std::istream &  stream)

References ReadFloat().

◆ ReadRGBA()

Graphics::RGBA Gorgon::IO::ReadRGBA ( std::istream &  stream)

Reads a RGBA color, R will be read first.

References RGBA::A, RGBA::B, RGBA::G, RGBA::R, and ReadUInt8().

◆ ReadRGBAf()

Graphics::RGBAf Gorgon::IO::ReadRGBAf ( std::istream &  stream)

Reads a RGBAf color, R will be read first.

References RGBAf::A, RGBAf::B, RGBAf::G, RGBAf::R, and ReadFloat().

◆ ReadSize()

Geometry::Size Gorgon::IO::ReadSize ( std::istream &  stream)

References ReadInt32().

◆ ReadString() [1/2]

std::string Gorgon::IO::ReadString ( std::istream &  stream)

Reads a string from a given stream.

Assumes the size of the string is appended before the string as 32-bit unsigned value.

References ReadUInt32().

◆ ReadString() [2/2]

std::string Gorgon::IO::ReadString ( std::istream &  stream,
unsigned long  size 
)

Reads a string with the given size.

◆ ReadUInt16()

unsigned Gorgon::IO::ReadUInt16 ( std::istream &  stream)

Reads a 16-bit unsigned integer from the stream.

An unsigned int is at least 16 bits, could be more however, only 2 bytes will be read from the stream

◆ ReadUInt32()

unsigned long Gorgon::IO::ReadUInt32 ( std::istream &  stream)

Reads a 32-bit unsigned integer from the stream.

An unsigned long is at least 32 bits, could be more however, only 4 bytes will be read from the stream

◆ ReadUInt8()

Byte Gorgon::IO::ReadUInt8 ( std::istream &  stream)

Reads an 8-bit unsigned integer from the stream.

A char is at least 8 bits, could be more however, only 1 byte will be read from the stream

◆ WriteArray()

void Gorgon::IO::WriteArray ( std::ostream &  stream,
const T_ *  data,
unsigned long  size 
)

Writes an array to the stream.

Array type should be a fixed size construct (ie. a byte, int32_t), otherwise a mismatch between binary formats will cause trouble.

Parameters
datais the data to be written to the stream
sizeis the number of elements to be write

◆ WriteBool()

void Gorgon::IO::WriteBool ( std::ostream &  stream,
bool  value 
)

Writes a boolean value. In resource 1.0, booleans are stored as 32bit integers.

References WriteInt32().

◆ WriteDouble()

void Gorgon::IO::WriteDouble ( std::ostream &  stream,
double  value 
)

Writes a 64 bit IEEE double precision floating point number from the stream.

This function only works on systems that have native 64 bit doubles.

◆ WriteEnum32()

void Gorgon::IO::WriteEnum32 ( std::ostream &  stream,
E_  v 
)

Writes an enumeration as a 32-bit integer.

◆ WriteFloat()

void Gorgon::IO::WriteFloat ( std::ostream &  stream,
float  value 
)

Writes a 32 bit IEEE floating point number from the stream.

This function only works on systems that that have native 32 bit floats.

◆ WriteGuid()

void Gorgon::IO::WriteGuid ( std::ostream &  stream,
const SGuid value 
)

Writes a GUID from the given stream.

References SGuid::Bytes, and WriteArray().

◆ WriteInt16()

void Gorgon::IO::WriteInt16 ( std::ostream &  stream,
int  value 
)

Writes a 16-bit integer from the stream.

An int is at least 16 bits, could be more however, only 2 bytes will be written to the stream

◆ WriteInt32()

void Gorgon::IO::WriteInt32 ( std::ostream &  stream,
long  value 
)

Writes a 32-bit integer to the stream.

◆ WriteInt8()

void Gorgon::IO::WriteInt8 ( std::ostream &  stream,
char  value 
)

Writes an 8-bit integer from the stream.

A char is at least 8 bits, could be more however, only 1 byte will be written to the stream

◆ WritePoint()

void Gorgon::IO::WritePoint ( std::ostream &  stream,
Geometry::Point  p 
)

Saves the point as two consecutive 32bit integers.

References WriteInt32(), basic_Point< T_ >::X, and basic_Point< T_ >::Y.

◆ WritePointf()

std::enable_if<std::is_same<F_, float>::value, void>::type Gorgon::IO::WritePointf ( std::ostream &  stream,
Geometry::Pointf  p 
)

Saves the point as two consecutive floats. This function will not work if float type is double.

References WriteFloat(), basic_Point< T_ >::X, and basic_Point< T_ >::Y.

◆ WriteRGBA()

void Gorgon::IO::WriteRGBA ( std::ostream &  stream,
Graphics::RGBA  value 
)

Writes a RGBA color, R will be saved first.

References RGBA::A, RGBA::B, RGBA::G, RGBA::R, and WriteUInt8().

◆ WriteRGBAf()

void Gorgon::IO::WriteRGBAf ( std::ostream &  stream,
Graphics::RGBAf  value 
)

Writes a RGBAf color, R will be saved first.

References RGBAf::A, RGBAf::B, RGBAf::G, RGBAf::R, and WriteFloat().

◆ WriteSize()

void Gorgon::IO::WriteSize ( std::ostream &  stream,
Geometry::Size  s 
)

Saves the size as two consecutive 32bit integers.

References basic_Size< T_ >::Height, basic_Size< T_ >::Width, and WriteInt32().

◆ WriteString()

void Gorgon::IO::WriteString ( std::ostream &  stream,
const std::string &  value 
)

Writes a string without its size.

◆ WriteStringWithSize()

void Gorgon::IO::WriteStringWithSize ( std::ostream &  stream,
const std::string &  value 
)

Writes a string from a given stream.

The size of the string is appended before the string as 32-bit unsigned value.

References WriteUInt32().

◆ WriteUInt16()

void Gorgon::IO::WriteUInt16 ( std::ostream &  stream,
unsigned  value 
)

Writes a 16-bit unsigned integer from the stream.

An unsigned int is at least 16 bits, could be more however, only 2 bytes will be written to the stream

◆ WriteUInt32()

void Gorgon::IO::WriteUInt32 ( std::ostream &  stream,
unsigned long  value 
)

Writes a 32-bit unsigned integer from the stream.

An unsigned long is at least 32 bits, could be more however, only 4 bytes will be written to the stream

◆ WriteUInt8()

void Gorgon::IO::WriteUInt8 ( std::ostream &  stream,
Byte  value 
)

Writes an 8-bit unsigned integer from the stream.

A char is at least 8 bits, could be more however, only 1 byte will be written to the stream

◆ WriteVector()

void Gorgon::IO::WriteVector ( std::ostream &  stream,
const std::vector< T_ > &  data 
)

Writes a vector to the stream.

Type of vector elements should be given a fixed size construct, otherwise a mismatch between binary formats will cause trouble.