This page has been translated automatically.
UnigineScript
The Language
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1
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.

See Also

Stream Class

Members


Variable gets ()

Reads the stream data from the current position.

Return value

Stream data starting from the current position.

int isAvailable ()

Returns the status of the stream.

Return value

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

int isError ()

Checks whether the stream has a read/write error.

Return value

1 if the stream is opened; otherwise, 0.

int isOpened ()

Checks whether the stream is opened.

Return value

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

Variable printf (string format, ... )

Writes a formatted non-binary string to the stream. The maximum length of the string is 4096 bytes.

Arguments

Return value

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

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.

void readArray (int id [] = [])

Reads an array of variables from the stream.

Arguments

  • int id [] - An array to read.

int readChar ()

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

Return value

Received character.

dmat4 readDMat4 (int endianness = 0)

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

Arguments

  • int endianness - 1 to read in big-endian order, 1 to read in little-endian order. By default, little-endian order is used.

Return value

Received matrix.

dvec3 readDVec3 (int endianness = 0)

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

Arguments

  • int endianness - 1 to read data in big-endian order, 0 to read data in little-endian order. By default, little-endian order is used.

Return value

Received dvec3.

dvec4 readDVec4 (int endianness = 0)

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

Arguments

  • int endianness - 1 to read data in big-endian order, 0 to read data in little-endian order. By default, little-endian order is used.

Return value

Received dvec4.

double readDouble (int endianness = 0)

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

Arguments

  • int endianness - 1 to read data in big-endian order, 0 to read data in little-endian order. By default, little-endian order is used.

Return value

Received double.

float readFloat (int endianness = 0)

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

Arguments

  • int endianness - 1 to read data in big-endian order, 0 to read data in little-endian order. By default, little-endian order is used.

Return value

Received float

ivec3 readIVec3 (int endianness = 0)

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

Arguments

  • int endianness - 1 to read data in big-endian order, 0 to read data in little-endian order. By default, little-endian order is used.

Return value

Received ivec3.

ivec4 readIVec4 (int endianness = 0)

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

Arguments

  • int endianness - 1 to read data in big-endian order, 0 to read data in little-endian order. By default, little-endian order is used.

Return value

Received ivec4.

int readInt2 ()

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

Return value

Received number.

int readInt (int endianness = 0)

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

Arguments

  • int endianness - 1 to read data in big-endian order, 0 to read data in little-endian order. By default, little-endian order is used.

Return value

Received integer.

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.

long readLong (int endianness = 0)

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

Arguments

  • int endianness - 1 to read data in big-endian order, 0 to read data in little-endian order. By default, little-endian order is used.

Return value

Received long integer.

mat4 readMat44 (int endianness = 0)

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

Arguments

  • int endianness - 1 to read data in big-endian order, 0 to read data in little-endian order. By default, little-endian order is used.

Return value

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

mat4 readMat4 (int endianness = 0)

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

Arguments

  • int endianness - 1 to read data in big-endian order, 0 to read data in little-endian order. By default, little-endian order is used.

Return value

Received matrix.

quat readQuat (int endianness = 0)

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

Arguments

  • int endianness - 1 to read data in big-endian order, 0 to read data in little-endian order. By default, little-endian order is used.

Return value

Received quaternion.

int readShort (int endianness = 0)

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

Arguments

  • int endianness - 1 to read data in big-endian order, 0 to read data in little-endian order. By default, little-endian order is used.

Return value

Received short integer.

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.

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.

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.

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.

int readUChar ()

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

Return value

Unsigned character in a binary format.

int readUShort (int endianness = 0)

Reads an unsigned short integer from the stream.

Arguments

  • int endianness - 1 to read data in big-endian order, 0 to read data in little-endian order. By default, little-endian order is used.

Return value

Received unsigned short integer.

variable readVariable ()

Reads a variable from the current stream.

Return value

Variable.

vec3 readVec3 (int endianness = 0)

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

Arguments

  • int endianness - 1 to read data in big-endian order, 0 to read data in little-endian order. By default, little-endian order is used.

Return value

Received vec3.

vec4 readVec4 (int endianness = 0)

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

Arguments

  • int endianness - 1 to read data in big-endian order, 0 to read data in little-endian order. By default, little-endian order is used.

Return value

Received vec4.

int read (int buffer[] = [], int size)

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

Arguments

  • int buffer[] - Vector, into which data will be read.
  • int size - Size of data to read.

Return value

1 if data is read successfully; otherwise, 0.

int writeArray (int id [] = [])

Writes an array of variables to the stream.

Arguments

  • int id [] - An array to write.

Return value

1 if an array 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.

int writeDMat4 (dmat4 value, int endianness = 0)

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

Arguments

  • dmat4 value - A matrix to write.
  • int endianness - 1 to write data in big-endian order, 1 to write data in little-endian order. By default, little-endian order is used.

Return value

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

int writeDVec3 (dvec3 value, int endianness = 0)

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

Arguments

  • dvec3 value - A dvec3 value to write.
  • int endianness - 1 to write data in big-endian order, 0 to write data in little-endian order. By default, little-endian order is used.

Return value

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

int writeDVec4 (dvec4 value, int endianness = 0)

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

Arguments

  • dvec4 value - A dvec4 value to write.
  • int endianness - 1 to write data in big-endian order, 0 to write data in little-endian order. By default, little-endian order is used.

Return value

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

int writeDouble (double value, int endianness = 0)

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

Arguments

  • double value - A double value to write.
  • int endianness - 1 to write data in big-endian order, 0 to write data in little-endian order. By default, little-endian order is used.

Return value

1 if data is written successfully; otherwise, 0.

int writeFloat (float value, int endianness = 0)

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

Arguments

  • float value - A float value to write.
  • int endianness - 1 to write data in big-endian order, 0 to write data in little-endian order. By default, little-endian order is used.

Return value

1 if data is written successfully; otherwise, 0.

int writeIVec3 (ivec3 value, int endianness = 0)

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

Arguments

  • ivec3 value - An ivec3 value to write.
  • int endianness - 1 to write data in big-endian order, 0 to write data in little-endian order. By default, little-endian order is used.

Return value

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

int writeIVec4 (ivec4 value, int endianness = 0)

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

Arguments

  • ivec4 value - An ivec4 to write.
  • int endianness - 1 to write data in big-endian order, 0 to write data in little-endian order. By default, little-endian order is used.

Return value

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

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 writeInt (int value, int endianness = 0)

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

Arguments

  • int value - An integer value to write.
  • int endianness - 1 to write data in big-endian order, 0 to write data in little-endian order. By default, little-endian order is used.

Return value

1 if data is written successfully; otherwise, 0.

int writeLong (long value, int endianness = 0)

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

Arguments

  • long value - A long value to write.
  • int endianness - 1 to write data in big-endian order, 0 to write data in little-endian order. By default, little-endian order is used.

Return value

1 if data is written successfully; otherwise, 0.

int writeMat44 (mat4 value, int endianness = 0)

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.
  • int endianness - 1 to write data in big-endian order, 0 to write data in little-endian order. By default, little-endian order is used.

Return value

1 if data is written successfully; otherwise, 0.

int writeMat4 (mat4 value, int endianness = 0)

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

Arguments

  • mat4 value - A matrix to write.
  • int endianness - 1 to write data in big-endian order, 0 to write data in little-endian order. By default, little-endian order is used.

Return value

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

int writeQuat (quat value, int endianness = 0)

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

Arguments

  • quat value - A quaternion to write.
  • int endianness - 1 to write data in big-endian order, 0 to write data in little-endian order. By default, little-endian order is used.

Return value

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

int writeShort (int value, int endianness = 0)

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

Arguments

  • int value - A short integer value to write.
  • int endianness - 1 to write data in big-endian order, 0 to write data in little-endian order. By default, little-endian order is used.

Return value

1 if data is written successfully; otherwise, 0.

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.

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.

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 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 writeUShort (int value, int endianness = 0)

Writes a unsigned short integer to the stream.

Arguments

  • int value - Unsigned short integer to write.
  • int endianness - 1 to write data in big-endian order, 1 to write data in little-endian order. By default, little-endian order is used.

Return value

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

int writeVariable (variable v)

Writes a given variable into the current stream.

Arguments

  • variable v - Variable.

Return value

1 if a variable is written successfully; otherwise 0.

int writeVec3 (vec3 value, int endianness = 0)

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

Arguments

  • vec3 value - A vec3 to write.
  • int endianness - 1 to write data in big-endian order, 0 to write data in little-endian order. By default, little-endian order is used.

Return value

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

int writeVec4 (vec4 value, int endianness = 0)

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

Arguments

  • vec4 value - A vec4 to write.
  • int endianness - 1 to write data in big-endian order, 0 to write data in little-endian order. By default, little-endian order is used.

Return value

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

int write (int vector[] = [], int size)

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

Arguments

  • int vector[] - Buffer, from which data will be written.
  • int size - Size of data to write.

Return value

1 if data is sent successfully; otherwise, 0.
Last update: 2017-07-03
Build: ()