This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related 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

Warning
UnigineScript is deprecated and will be removed in future releases. Please consider using C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScipt is not guaranteed, as the current level of support assumes only fixing critical issues.

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

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

Stream Class

Members


int isAvailable ( ) #

Returns the status of the stream.

Return value

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

void setByteOrder ( int order ) #

Sets the endianness of the stream.

Arguments

  • int order - A value indicating the endianness of the stream: 0 value is for LSB (least significant), 1 is for MSB (most significant).

int getByteOrder ( ) #

Returns the value indicating the endianness of the stream.

Return value

A value indicating the endianness of the stream: 0 value is for LSB (least significant), 1 is for MSB (most significant).

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.

gets ( ) #

Reads the stream data from the current position.

Return value

Stream data starting from the current position.

int getType ( ) #

Return the type of the stream.

Return value

A value indicating the type of the stream.

int puts ( ) #

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

Arguments

    Return value

    1 if a string of characters 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.

    dmat4 readDMat4 ( ) #

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

    Return value

    Received matrix.

    double readDouble ( ) #

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

    Return value

    Received double.

    dvec2 readDVec2 ( ) #

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

    Return value

    Vector value.

    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.

    float readFloat ( ) #

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

    Return value

    Received float

    int readInt ( ) #

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

    Return value

    Received integer.

    int readInt2 ( ) #

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

    Return value

    Received number.

    ivec2 readIVec2 ( ) #

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

    Return value

    Vector value.

    ivec3 readIVec3 ( ) #

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

    Return value

    Received ivec3.

    ivec4 readIVec4 ( ) #

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

    Return value

    Received ivec4.

    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 long integer.

    mat4 readMat4 ( ) #

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

    Return value

    Received matrix.

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

    quat readQuat ( ) #

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

    Return value

    Received quaternion.

    short readShort ( ) #

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

    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.

    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.

    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.

    readUChar ( ) #

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

    Return value

    Unsigned character in a binary format.

    unsigned int readUInt ( ) #

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

    Return value

    Data value.

    unsigned int readUInt2 ( ) #

    Reads a compact unsigned integer from the stream.

    Return value

    Data value.

    int readUShort ( ) #

    Reads an unsigned short integer from the stream.

    Return value

    Received unsigned short integer.

    vec2 readVec2 ( ) #

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

    Return value

    Vector value.

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

    int writeChar ( char value ) #

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

    Arguments

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

    Return value

    1 if a character is written successfully; otherwise 0.

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

    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.

    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.

    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.

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

    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 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 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 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 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 writeString ( ) #

    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

      Return value

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

      int writeString2 ( ) #

      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

        Return value

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

        int writeUChar ( ) #

        Writes an unsigned character to the stream.

        Arguments

          Return value

          1 if the unsigned character is written successfully; 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 writeUInt2 ( unsigned int value ) #

          Writes a compact unsigned integer to the stream.

          Arguments

          • unsigned int value - Data 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 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 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 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.
          Last update: 2020-04-10
          Build: ()