This page has been translated automatically.
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
Bounds-Related Classes
Containers
Controls-Related Classes
Engine-Related Classes
GUI-Related Classes
Node-Related Classes
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Utility Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Stream Class

This class cannot be instantiated. It is a base class for:

Stream class allows to write data into a stream, that is into files (stored on the disk), buffers (stored in system memory) and sockets (to be sent over the network), as well as read data from a stream.

Stream Class

Members


Variable puts (string str)

Writes a non-binary string of characters to the stream.

Arguments

  • string str - String to write.

Return value

1 if a string of characters is written successfully; otherwise, 0.

int writeIVec2 (ivec2 value)

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

Arguments

  • ivec2 value - Vector value.

Return value

1 if the operation was successful; otherwise, 0.

int readInt ()

Reads an integer in a binary format (4 bytes) from the stream.

Return value

Received integer.

int writeInt2 (int value)

Writes a compact signed integer in a binary format to the stream.

Arguments

  • int value - A compact signed integer to write.

Return value

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

int read (void * ptr, int size)

Reads unsigned char data in a binary format from the stream into a vector.

Arguments

  • void * ptr - Vector, into which data will be read.
  • int size - Size of data to read.

Return value

1 if data is read successfully; otherwise, 0.

dvec2 readDVec2 ()

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

Return value

Vector value.

int readChar ()

Reads a ASCII character in a binary format (1 byte) from the stream.

Return value

Received character.

ivec3 readIVec3 ()

Reads an ivec3 in a binary format (4*3 bytes) from the stream.

Return value

Received ivec3.

Variable readString2 ()

Reads a compact string in a binary format from the stream. Each binary string should be preceded by its length (the string length + the string itself). The string length is written as the compact signed integer.

Return value

Received string.

double readDouble ()

Reads a double in a binary format (8 bytes) from the stream.

Return value

Received double.

int readUChar ()

Reads an unsigned character in a binary format from the stream.

Return value

Unsigned character in a binary format.

dvec4 readDVec4 ()

Reads a dvec4 in a binary format (8*4 bytes) from the stream.

Return value

Received dvec4.

int writeMat4 (mat4 value)

Writes a mat4 (a matrix of float values, 4*16 bytes) to the stream.

Arguments

  • mat4 value - A matrix to write.

Return value

1 if a matrix is written successfully; otherwise, 0.

int write (const void * ptr, int size)

Writes contents of a vector into the stream as unsigned char data in a binary format.

Arguments

  • const void * ptr - Buffer, from which data will be written.
  • int size - Size of data to write.

Return value

1 if data is sent successfully; otherwise, 0.

mat4 readMat4 ()

Reads a mat4 (a matrix in a binary format, 4*16 bytes) from the stream.

Return value

Received matrix.

int writeDMat4 (dmat4 value)

Writes a dmat4 (a matrix of double values, 8*12 bytes) to the stream.

Arguments

  • dmat4 value - A matrix to write.

Return value

1 if a matrix is written successfully; otherwise, 0.

int writeChar (int char)

Writes an ASCII character in a binary format (1 byte) to the stream.

Arguments

  • int char - ASCII code of a character to write.

Return value

1 if a character is written successfully; otherwise 0.

void * getInterface ()

Return value

int readUShort ()

Reads an unsigned short integer from the stream.

Return value

Received unsigned short integer.

int writeDVec3 (dvec3 value)

Writes a dvec3 in a binary format (8*3 bytes) to the stream.

Arguments

  • dvec3 value - A dvec3 value to write.

Return value

1 if a vector is written successfully; otherwise, 0.

short readShort ()

Reads a short integer in a binary format (2 bytes) from the stream.

Return value

Received short integer.

int writeVec4 (vec4 value)

Writes a vec4 in a binary format (4*4 bytes) to the stream.

Arguments

  • vec4 value - A vec4 to write.

Return value

1 if a vector is written successfully; otherwise, 0.

int readInt2 ()

Reads a compact signed integer in a binary format from the stream.

Return value

Received number.

float readFloat ()

Reads a float in a binary format (4 bytes) from the stream.

Return value

Received float

int writeFloat (float value)

Writes a float (4 bytes) in a binary format to the stream.

Arguments

  • float value - A float value to write.

Return value

1 if data is written successfully; otherwise, 0.

dmat4 readDMat4 ()

Reads dmat4 (a matrix of double values, 8*12 bytes) in a binary format from the stream.

Return value

Received matrix.

Stream getStream ()

Returns a stream pointer.

Return value

Stream pointer.

Variable writeString2 (string str)

Writes a compact string in a binary format to the stream. Each binary string should be preceded by its length (the string length + the string itself). The string length is written as the compact signed integer.

Arguments

  • string str - String to write.

Return value

1 if the string is written successfully; otherwise, 0.

quat readQuat ()

Reads a quaternion in a binary format (4*4 bytes) from the stream.

Return value

Received quaternion.

vec4 readVec4 ()

Reads a vec4 in a binary format (4*4 bytes) from the stream.

Return value

Received vec4.

int writeDVec2 (dvec2 value)

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

Arguments

  • 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.

int writeStream (Stream src, int size)

Reads the number of bytes from the given stream and writes data directly into the current one.

Arguments

  • Stream src - Stream to read data from.
  • int size - Size of data to be read from the stream.

Return value

1 if both streams are opened and data is successfully written; otherwise, 0.

int isOpened ()

Checks whether the stream is opened.

Return value

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

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 writeIVec4 (ivec4 value)

Writes an ivec4 in a binary format (4*4 bytes) to the stream.

Arguments

  • ivec4 value - An ivec4 to write.

Return value

1 if a vector is written successfully; otherwise, 0.

int writeUInt2 (unsigned int value)

Writes a compact unsigned integer to the stream.

Arguments

  • unsigned int value - Data value.

Return value

int writeUShort (int value)

Writes a unsigned short integer to the stream.

Arguments

  • int value - Unsigned short integer to write.

Return value

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

int writeShort (short value)

Writes a short integer in a binary format (2 bytes) to the stream.

Arguments

  • short value - A short integer value to write.

Return value

1 if data is written successfully; otherwise, 0.

int writeVec3 (vec3 value)

Writes a vec3 in a binary format (4*3 bytes) to the stream.

Arguments

  • vec3 value - A vec3 to write.

Return value

1 if a vector is written successfully; otherwise, 0.

int writeUChar (int value)

Writes an unsigned character to the stream.

Arguments

  • int value - Unsigned character to write.

Return value

1 if the unsigned character is written successfully; otherwise, 0.

int writeQuat (quat value)

Writes a quaternion in a binary format (4*4 bytes) to the stream.

Arguments

  • quat value - A quaternion to write.

Return value

1 if a quaternion is written successfully; otherwise, 0.

int isAvailable ()

Returns the status of the stream.

Return value

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

int writeInt (int value)

Writes an integer (4 bytes) in a binary format to the stream.

Arguments

  • int value - An integer value to write.

Return value

1 if data is written successfully; otherwise, 0.

int getByteOrder ()

Return value

vec3 readVec3 ()

Reads a vec3 in a binary format (4*3 bytes) from the stream.

Return value

Received vec3.

int writeLong (long value)

Writes a long integer (8 bytes) in a binary format to the stream.

Arguments

  • long value - A long value to write.

Return value

1 if data is written successfully; otherwise, 0.

unsigned int readUInt2 ()

Reads a compact unsigned integer from the stream.

Return value

Data value.

dvec3 readDVec3 ()

Reads a dvec3 in a binary format (8*3 bytes) from the stream.

Return value

Received dvec3.

Variable writeString (string str)

Writes a string in a binary format to the stream. Each binary string should be preceded by its length (4 bytes defining the length of string + the string itself).

Arguments

  • string str - String to write.

Return value

1 if the string is written successfully; otherwise, 0.

int writeDVec4 (dvec4 value)

Writes a dvec4 in a binary format (8*4 bytes) to the stream.

Arguments

  • dvec4 value - A dvec4 value to write.

Return value

1 if a vector is written successfully; otherwise, 0.

Variable readLine ()

Reads a line of non-binary characters from the stream: starting from the current position until the end of line is reached ("\n"). The maximum length of the line is 4096 bytes.

Return value

Received line.

ivec4 readIVec4 ()

Reads an ivec4 in a binary format (4*4 bytes) from the stream.

Return value

Received ivec4.

vec2 readVec2 ()

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

Return value

Vector value.

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 (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

  • mat4 value - A 4x4 matrix.

Return value

1 if data is written successfully; otherwise, 0.

int writeVec2 (vec2 value)

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

Arguments

  • vec2 value - Vector value.

Return value

1 if the operation was successful; otherwise, 0.

int isError ()

Checks whether the stream has a read/write error.

Return value

1 if the stream is opened; 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.

Variable readToken ()

Reads a token from the stream. A token is a single word delimited by white space or a string in quotes, for example, "word" or "many words". A token is read starting from the current position up to the white space or line feed ("\n"), or if the first character is a double quote mark (") up to the second double quote mark (returned token will not contain any quotes). The maximum length of the string is 4096 bytes

Return value

Received token.

long readLong ()

Reads a long integer in a binary format (8 bytes) from the stream.

Return value

Received long integer.

Variable gets ()

Reads the stream data from the current position.

Return value

Stream data starting from the current position.

Variable readString ()

Reads a compact string in a binary format from the stream. Each binary string should be preceded by its length (the string length + the string itself). The string length is written as the compact signed integer.

Return value

Received string.

int writeDouble (double value)

Writes a double (8 bytes) in a binary format to the stream.

Arguments

  • double value - A double value to write.

Return value

1 if data is written successfully; otherwise, 0.

int writeIVec3 (ivec3 value)

Writes a ivec3 in a binary format (4*3 bytes) to the stream.

Arguments

  • ivec3 value - An ivec3 value to write.

Return value

1 if a vector is written successfully; otherwise, 0.

int readStream (Stream dest, int size)

Reads the number of bytes from the current stream and writes data directly into the specified stream.

Arguments

  • Stream dest - Stream to write data into.
  • int size - Size of data to be read from the current stream.

Return value

1 if both streams are opened and data is successfully written; otherwise, 0.
Last update: 2017-07-03
Build: ()