UnigineScript
The Language
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials

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


StringStack<256> 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 isOpened ()

Checks whether the stream is opened.

Return value

1 if the stream is opened; otherwise, 0.

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

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

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

Return value

Received matrix.

dvec3 readDVec3 ()

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

Return value

Received dvec3.

dvec4 readDVec4 ()

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

Return value

Received dvec4.

double readDouble ()

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

Return value

Received number.

float readFloat ()

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

Return value

Received number.

ivec3 readIVec3 ()

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

Return value

Received ivec3.

ivec4 readIVec4 ()

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

Return value

Received ivec4.

int readInt2 ()

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

Return value

Received number.

int readInt ()

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

Return value

Received number.

StringStack<256> 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 ()

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

Return value

Received number.

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

mat4 readMat4 ()

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

Return value

Received matrix.

quat readQuat ()

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

Return value

Received quaternion.

int readShort ()

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

Return value

Received number.

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.

StringStack<256> 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.

StringStack<256> readString ()

Reads a string in a binary format from the stream. Each binary string should be preceded by its length (4 bytes defining the length of string + the string itself). The maximum length of the string is 4096 bytes.

Return value

Received string.

StringStack<256> readToken ()

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

Return value

Received token.

variable readVariable ()

Reads a variable from the current stream.

Return value

Variable.

vec3 readVec3 ()

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

Return value

Received vec3.

vec4 readVec4 ()

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

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)

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

Arguments

  • dmat4 value - Matrix to write.

Return value

1 if a matrix is written successfully; otherwise 0.

int writeDVec3 (dvec3 value)

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

Arguments

  • dvec3 value - A dvec3 to write.

Return value

1 if a vector 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 to write.

Return value

1 if a vector is written successfully; otherwise 0.

int writeDouble (double value)

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

Arguments

  • double value - Number to write.

Return value

1 if data is written successfully; otherwise 0.

int writeFloat (float number)

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

Arguments

  • float number - Number 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 - A ivec3 to write.

Return value

1 if a vector is written successfully; otherwise 0.

int writeIVec4 (ivec4 value)

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

Arguments

  • ivec4 value - A ivec4 to write.

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 - Number to write.

Return value

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

int writeInt (int number)

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

Arguments

  • int number - Number to write.

Return value

1 if data is written successfully; otherwise 0.

int writeLong (long value)

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

Arguments

  • long value - Number to write.

Return value

1 if data is written successfully; otherwise 0.

int writeMat44 (mat4 value)

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

Arguments

  • mat4 value - 4x4 matrix.

Return value

1 if data is written successfully; otherwise 0.

int writeMat4 (mat4 value)

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

Arguments

  • mat4 value - Matrix to write.

Return value

1 if a matrix is written successfully; otherwise 0.

int writeQuat (quat quaternion)

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

Arguments

  • quat quaternion - Quaternion to write.

Return value

1 if a quaternion is written successfully; otherwise 0.

int writeShort (int number)

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

Arguments

  • int number - Number to write.

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.

int writeString2 (string value)

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 value - String to write.

Return value

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

int 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 a string 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 vec)

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

Arguments

  • vec3 vec - A vec3 to write.

Return value

1 if a vector is written successfully; otherwise 0.

int writeVec4 (vec4 vec)

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

Arguments

  • vec4 vec - A vec4 to write.

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