This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
Программирование
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

Unigine::Stream Class

Header:#include <UnigineStreams.h>

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

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

void setByteOrder(int order)

Sets the endianess of the stream.

Arguments

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

int getByteOrder()

Returns the value indicating the endianess of the stream.

Return value

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

int isError()

Returns the status of the stream.

Return value

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

void * getInterface()

Returns an interface pointer.

Return value

Interface pointer.

int isOpened()

Returns the status of the stream.

Return value

1 if the stream is opened; otherwise, 0.

int isOwner()

Returns the owner flag. If the pointer is the owner, on its deletion the stream also will be deleted. Use grab() and release() functions to change ownership.

Return value

1 if the pointer is the owner; otherwise, 0.

String gets()

Reads the stream data from the current position.

Return value

Stream data starting from the current position.

Ptr<Stream> getStream()

Returns a smart pointer to the stream.

Return value

A Stream smart pointer.

int getType()

Return the type of the stream.

Return value

A value indicating the type of the stream.

void grab()

Sets the owner flag to 1 for the Stream pointer. The stream should not be handled by the class after this function is called.

int puts(const char * str)

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

Arguments

  • const char * str - String to write.

Return value

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

char readChar()

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

Return value

Received character.

Math::dmat4 readDMat4()

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

Return value

Vector value.

double readDouble()

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

Return value

Data value.

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.

Math::dvec2 readDVec2()

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

Return value

Vector value.

Math::dvec3 readDVec3()

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

Return value

Vector value.

Math::dvec4 readDVec4()

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

Return value

Vector value.

float readFloat()

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

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.

int readInt()

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

Return value

Data value.

int readInt2()

Reads a compact signed integer from the stream.

Return value

Data value.

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.

Math::ivec2 readIVec2()

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

Return value

Vector value.

Math::ivec3 readIVec3()

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

Return value

Vector value.

Math::ivec4 readIVec4()

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

Return value

Vector value.

int readLine(out char[] str)

Reads a line from the stream.

Arguments

  • out char[] str

Return value

Returns string.

String 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 long readLong()

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

Return value

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

Math::mat4 readMat4()

Reads a matrix 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).

Math::quat readQuat()

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

Return value

Vector value.

short readShort()

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

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.

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.

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

String readString2()

Return value

Received string.

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.

int readToken(char * str, int size)

Arguments

  • char * str
  • int size

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

unsigned short readUShort()

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

Return value

Data value.

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.

Math::vec2 readVec2()

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

Return value

Vector value.

Math::vec3 readVec3()

Reads a 3 component vector 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.

void release()

Sets the owner flag to 0 for the Stream pointer. The stream should be handled by the class after this function is called.

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.

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

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

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.

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

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

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

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.

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.

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

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 writeString(const char * 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

  • const char * str - String to write.

Return value

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

int writeString2(const char * 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

  • const char * str - String to write.

Return value

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

int writeUChar(unsigned char value)

Writes an unsigned character to the stream.

Arguments

  • unsigned char value - Unsigned character to write.

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

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.

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

Description

A stream for blobs.

int STREAM_FILE

Description

A stream for files.

int STREAM_NUM_TYPES

Description

A number of stream types.

int STREAM_SOCKET

Description

A stream for sockets.

int STREAM_USER

Description

A user stream inherited from StreamBase.
Last update: 10.08.2018
Build: ()