Programming
Fundamentials
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Engine Classes
Node-Related Classes
Rendering-Related Classes
Physics-Related Classes
Bounds-Related Classes
GUI-Related Classes
Controls-Related Classes
Pathfinding-Related Classes
Utility Classes

Stream Class

Interface for data serialization.

To use this class, include the UnigineStream.h file.

Stream Class

Members


int writeIVec2 (const Math::ivec2 & value)

Writes a 2 component integer vector to the stream in accordance with the little-endian order.

Arguments

  • const Math::ivec2 & value - Vector value.

Return value

1 if the operation was successful; otherwise, 0.

int readInt ()

Reads a signed integer from the stream in accordance with the little-endian order.

Return value

Data value.

int readLine (out char[] str)

Reads a line from the stream.

Arguments

  • out char[] str

Return value

Returns string.

int readIntArray (out int[] dest)

Reads an array of signed integers from the stream in accordance with the little-endian order.

Arguments

  • out int[] dest

Return value

1 if the operation was successful; otherwise, 0.

int readDoubleArray (out double[] dest)

Reads an array of double floating-point numbers from the stream in accordance with the little-endian order.

Arguments

  • out double[] dest

Return value

1 if the operation was successful; otherwise, 0.

int writeInt2 (int value)

Writes a compact signed integer to the stream.

Arguments

  • int value - Data value.

Return value

1 if the compact integer is written successfully; otherwise, 0.

size_t read (void * ptr, size_t size)

Reads the number of bytes from the stream.

Arguments

  • void * ptr - Destination buffer pointer.
  • size_t size - Size of the buffer, in bytes.

Return value

The number of read bytes.

Math::dvec2 readDVec2 ()

Reads a 2 component double vector from the stream in accordance with the little-endian order.

Return value

Vector value.

int writeUChar (unsigned char value)

Writes an unsigned character to the stream.

Arguments

  • unsigned char value - Data value.

Return value

Math::ivec3 readIVec3 ()

Reads a 3 component integer vector from the stream in accordance with the little-endian order.

Return value

Vector value.

int puts (const char * str)

Writes a string of characters to the stream.

Arguments

  • const char * str - String pointer.

Return value

1 if the operation was successful; otherwise, 0.

int writeString2 (const char * str)

Writes a string to the stream in accordance with the big-endian order.

Arguments

  • const char * str - String pointer.

Return value

1 if the operation was successful; otherwise, 0.

double readDouble ()

Reads a double floating-point number from the stream in accordance with the little-endian order.

Return value

Data value.

int writeFloatArray (float[] src)

Writes an array of floating-point numbers to the stream in accordance with the little-endian order.

Arguments

  • float[] src

Return value

1 if the operation was successful; otherwise, 0.

Math::dvec4 readDVec4 ()

Reads a 4 component double vector from the stream in accordance with the little-endian order.

Return value

Vector value.

int writeMat4 (const Math::mat4 & value)

Writes a matrix to the stream in accordance with the little-endian order.

Arguments

  • const Math::mat4 & value - Vector value.

Return value

1 if the operation was successful; otherwise, 0.

size_t write (const void * ptr, size_t size)

Writes the number of bytes to the stream.

Arguments

  • const void * ptr - Source buffer pointer.
  • size_t size - Size of the buffer in bytes.

Return value

The number of written bytes.

Math::mat4 readMat4 ()

Reads a matrix from the stream in accordance with the little-endian order.

Return value

Vector value.

int writeDMat4 (const Math::dmat4 & value)

Writes a double matrix to the stream in accordance with the little-endian order.

Arguments

  • const Math::dmat4 & value - Vector value.

Return value

1 if the operation was successful; otherwise, 0.

int writeUIntArray (uint[] src)

Writes an array of unsigned integers to the stream in accordance with the little-endian order.

Arguments

  • uint[] src

Return value

1 if the operation was successful; otherwise, 0.

void * getInterface ()

Return value

unsigned short readUShort ()

Reads a unsigned short integer from the stream in accordance with the little-endian order.

Return value

Data value.

int readString2 (out char[] str)

Reads a string from the stream in accordance with the big-endian order.

Arguments

  • out char[] str

Return value

Returns string.

int writeChar (char value)

Writes a signed character to the stream.

Arguments

  • char value - Data value.

Return value

int writeDVec3 (const Math::dvec3 & value)

Writes a 3 component double vector to the stream in accordance with the little-endian order.

Arguments

  • const Math::dvec3 & value - Vector value.

Return value

1 if the operation was successful; otherwise, 0.

int writeShortArray (short[] src)

Writes an array of signed short integers to the stream in accordance with the little-endian order.

Arguments

  • short[] src

Return value

1 if the operation was successful; otherwise, 0.

short readShort ()

Reads a signed short integer from the stream in accordance with the little-endian order.

Return value

Data value.

int writeVec4 (const Math::vec4 & value)

Writes a 4 component vector to the stream in accordance with the little-endian order.

Arguments

  • const Math::vec4 & value - Vector value.

Return value

1 if the operation was successful; otherwise, 0.

int readInt2 ()

Reads a compact signed integer from the stream.

Return value

Data value.

int readFloatArray (out float[] dest)

Reads an array of floating-point numbers from the stream in accordance with the little-endian order.

Arguments

  • out float[] dest

Return value

1 if the operation was successful; otherwise, 0.

float readFloat ()

Reads a floating-point number from the stream in accordance with the little-endian order.

Return value

Data value.

int writeUShortArray (ushort[] src)

Writes an array of unsigned short integers to the stream in accordance with the little-endian order.

Arguments

  • ushort[] src

Return value

1 if the operation was successful; otherwise, 0.

int writeFloat (float value)

Writes a floating-point number to the stream in accordance with the little-endian order.

Arguments

  • float value - Data value.

Return value

1 if the operation was successful; otherwise, 0.

Math::dmat4 readDMat4 ()

Reads a double matrix from the stream in accordance with the little-endian order.

Return value

Vector value.

Ptr<Stream> getStream ()

Returns a stream pointer.

Return value

Stream pointer.

char readChar ()

Reads a signed character from the stream.

Return value

Data value.

Math::quat readQuat ()

Reads a quaternion from the stream in accordance with the little-endian order.

Return value

Vector value.

Math::vec4 readVec4 ()

Reads a 4 component vector from the stream in accordance with the little-endian order.

Return value

Vector value.

int writeDVec2 (const Math::dvec2 & value)

Writes a 2 component double vector to the stream in accordance with the little-endian order.

Arguments

  • const Math::dvec2 & value - Vector value.

Return value

1 if the operation was successful; otherwise, 0.

unsigned int readUInt ()

Reads a unsigned integer from the stream in accordance with the little-endian order.

Return value

Data value.

size_t writeStream (const Ptr<Stream> & src, size_t size)

Writes the number of bytes directly to the stream.

Arguments

  • const Ptr<Stream> & src - Source stream pointer.
  • size_t size - Size of the data in bytes.

Return value

The number of written bytes.

int writeDoubleArray (double[] src)

Writes an array of double floating-point numbers to the stream in accordance with the little-endian order.

Arguments

  • double[] src

Return value

1 if the operation was successful; otherwise, 0.

int writeIntArray (int[] src)

Writes an array of signed integers to the stream in accordance with the little-endian order.

Arguments

  • int[] src

Return value

1 if the operation was successful; otherwise, 0.

int isOpened ()

Returns the status of the stream.

Return value

1 if the stream is opened; otherwise, 0.

Math::ivec2 readIVec2 ()

Reads a 2 component integer vector from the stream in accordance with the little-endian order.

Return value

Vector value.

void setByteOrder (int order)

Arguments

  • int order

int readUShortArray (out ushort[] dest)

Reads an array of unsigned short integers from the stream in accordance with the little-endian order.

Arguments

  • out ushort[] dest

Return value

1 if the operation was successful; otherwise, 0.

String readString2 ()

Reads a string from the stream in accordance with the big-endian order.

Return value

Returns string.

int writeIVec4 (const Math::ivec4 & value)

Writes a 4 component integer vector to the stream in accordance with the little-endian order.

Arguments

  • const Math::ivec4 & value - Vector value.

Return value

1 if the operation was successful; otherwise, 0.

int writeUInt2 (unsigned int value)

Writes a compact unsigned integer to the stream.

Arguments

  • unsigned int value - Data value.

Return value

int readUIntArray (out uint[] dest)

Reads an array of unsigned integers from the stream in accordance with the little-endian order.

Arguments

  • out uint[] dest

Return value

1 if the operation was successful; otherwise, 0.

int writeUShort (unsigned short value)

Writes a unsigned short integer to the stream in accordance with the little-endian order.

Arguments

  • unsigned short value - Data value.

Return value

1 if the operation was successful; otherwise, 0.

unsigned char readUChar ()

Reads an unsigned character from the stream.

Return value

Data value.

String gets ()

Reads the stream data from the current position

Return value

Returns string.

int writeShort (short value)

Writes a signed short integer to the stream in accordance with the little-endian order.

Arguments

  • short value - Data value.

Return value

1 if the operation was successful; otherwise, 0.

int writeVec3 (const Math::vec3 & value)

Writes a 3 component vector to the stream in accordance with the little-endian order.

Arguments

  • const Math::vec3 & value - Vector value.

Return value

1 if the operation was successful; otherwise, 0.

int writeQuat (const Math::quat & value)

Writes a quaternion to the stream in accordance with the little-endian order.

Arguments

  • const Math::quat & value - Vector value.

Return value

1 if the operation was successful; otherwise, 0.

int isAvailable ()

Returns the status of the stream.

Return value

1 if the stream data is available; otherwise, 0.

int writeInt (int value)

Writes a signed integer to the stream in accordance with the little-endian order.

Arguments

  • int value - Data value.

Return value

1 if the operation was successful; otherwise, 0.

int getByteOrder ()

Return value

String readToken ()

Return value

Math::vec3 readVec3 ()

Reads a 3 component vector from the stream in accordance with the little-endian order.

Return value

Vector value.

int writeLong (long long value)

Writes a signed long to the stream in accordance with the little-endian order.

Arguments

  • long long value - Data value.

Return value

1 if the operation was successful; otherwise, 0.

unsigned int readUInt2 ()

Reads a compact unsigned integer from the stream.

Return value

Data value.

int readShortArray (out short[] dest)

Reads an array of signed short integers from the stream in accordance with the little-endian order.

Arguments

  • out short[] dest

Return value

1 if the operation was successful; otherwise, 0.

Math::dvec3 readDVec3 ()

Reads a 3 component double vector from the stream in accordance with the little-endian order.

Return value

Vector value.

int writeDVec4 (const Math::dvec4 & value)

Writes a 4 component double vector to the stream in accordance with the little-endian order.

Arguments

  • const Math::dvec4 & value - Vector value.

Return value

1 if the operation was successful; otherwise, 0.

int writeLongArray (llong[] src)

Writes an array of signed longs to the stream in accordance with the little-endian order.

Arguments

  • llong[] src

Return value

1 if the operation was successful; otherwise, 0.

String readLine ()

Reads a line from the stream.

Return value

Returns string.

Math::ivec4 readIVec4 ()

Reads a 4 component integer vector from the stream in accordance with the little-endian order.

Return value

Vector value.

Math::vec2 readVec2 ()

Reads a 2 component vector from the stream in accordance with the little-endian order.

Return value

Vector value.

Math::mat4 readMat44 ()

Reads the first 12 elements of 4x4 matrix from the current stream. The last 4 elements of the matrix are discarded.

Return value

4x4 matrix with 12 read elements (the last four elements are equal to 0 0 0 1).

int writeMat44 (const Math::mat4 & value)

Writes the first 12 elements of 4x4 matrix in a binary format into the current stream. The last 4 elements of the matrix are discarded.

Arguments

  • const Math::mat4 & value - A 4x4 matrix.

Return value

1 if data is written successfully; otherwise, 0.

int writeString (const char * str)

Writes a string to the stream in accordance with the big-endian order.

Arguments

  • const char * str - String pointer.

Return value

1 if the operation was successful; otherwise, 0.

int writeVec2 (const Math::vec2 & value)

Writes a 2 component vector to the stream in accordance with the little-endian order.

Arguments

  • const Math::vec2 & value - Vector value.

Return value

1 if the operation was successful; otherwise, 0.

int isError ()

Returns the status of the stream.

Return value

1 if there is a read/write error; otherwise, 0.

int writeUInt (unsigned int value)

Writes a unsigned integer to the stream in accordance with the little-endian order.

Arguments

  • unsigned int value - Data value.

Return value

1 if the operation was successful; otherwise, 0.

int readString (out char[] str)

Reads a string from the stream in accordance with the big-endian order.

Arguments

  • out char[] str

Return value

Returns string.

String readString ()

Reads a string from the stream in accordance with the big-endian order.

Return value

Returns string.

int readToken (char * str, int size)

Arguments

  • char * str
  • int size

Return value

int readLongArray (out llong[] dest)

Reads an array of signed longs from the stream in accordance with the little-endian order.

Arguments

  • out llong[] dest

Return value

1 if the operation was successful; otherwise, 0.

long long readLong ()

Reads a signed long from the stream in accordance with the little-endian order.

Return value

Data value.

int writeDouble (double value)

Writes a double floating-point number to the stream in accordance with the little-endian order.

Arguments

  • double value - Data value.

Return value

1 if the operation was successful; otherwise, 0.

int writeIVec3 (const Math::ivec3 & value)

Writes a 3 component integer vector to the stream in accordance with the little-endian order.

Arguments

  • const Math::ivec3 & value - Vector value.

Return value

1 if the operation was successful; otherwise, 0.

size_t readStream (const Ptr<Stream> & dest, size_t size)

Reads the number of bytes directly from the stream.

Arguments

  • const Ptr<Stream> & dest - Destination stream pointer.
  • size_t size - Size of the data in bytes.

Return value

The number of read bytes.
Last update: 2017-07-03