This page has been translated automatically.
Programming
Fundamentals
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
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
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.

Blob Class

Inherits:Stream

This class is used to store data in the memory (unlike File which is stored on the disk). The blob uses either an Unigine allocator (if #define USE_MEMORY is set, by default) or a system allocator.

Blob Class

Members


static Blob(int size = 0)

Constructor. Creates a new blob of the specified size.

Arguments

  • int size - Blob size.

Blob cast(Stream stream)

Casts a Blob out of the Stream instance.

Arguments

Return value

Blob.

void set(int offset, int value)

Sets the value of the specified byte in the blob.

Arguments

  • int offset - The offset in the blob.
  • int value - The byte value.

int get(int offset)

Returns the value of the specified byte in the blob.

Arguments

  • int offset - The offset, in bytes.

Return value

The byte value.

int getc()

Returns the next symbol from the blob.

Return value

The blob symbol.

String getCRC32()

Returns the 32-bit CRC checksum.

Return value

The 32-bit CRC checksum.

String getMD5()

Returns a 128-bit MD5 checksum.

Return value

128-bit MD5 checksum.

String getSHA1()

Returns a 160-bit SHA1 checksum.

Return value

160-bit SHA1 checksum.

String getSHA256()

Returns a 256-bit SHA256 checksum.

Return value

256-bit SHA256 checksum.

int getSize()

Returns the current size of the blob.

Return value

The size of the blob.

void allocate(int size)

Allocates the required memory without resizing the blob.
Notice
The blob will be resized dynamically when the allocated memory is filled.

Arguments

  • int size - Size of the allocated memory, in bytes.

void clear()

Clears the size of the blob to 0.

int compress(Stream dest, int quality)

Compresses the blob and writes it into the given stream.

Arguments

  • Stream dest - Destination stream.
  • int quality - Compression quality (0 is for a fast compression, 1 is for a small size).

Return value

1 if the data is successfully compressed; otherwise, 0.

int compressLz4(Stream dest, int quality)

Compresses the blob with Lz4 algorithm and writes it into the given stream.

Arguments

  • Stream dest - Destination stream.
  • int quality - Compression quality (0 is for a fast compression, 1 is for a small size).

Return value

1 if the data is successfully compressed; otherwise, 0.

int decode(string src)

Decodes a base64 encoded string into the blob.

Arguments

  • string src - Source base64 encoded string.

Return value

Returns 1 if the data is decoded successfully; otherwise, 0.

int decodeZBase32(string src)

Decodes a Zbase32 encoded string into the blob.

Arguments

  • string src - Source Zbase32 encoded string.

Return value

Returns 1 if the data is decoded successfully; otherwise, 0.

int decompress(Stream src)

Reads and decompresses a previously compressed blob from a given stream.

Arguments

  • Stream src - Stream to read data from.

Return value

1 if the blob is decompressed successfully; otherwise, 0.

int decompressLz4(Stream src)

Reads and decompresses a previously compressed blob with Lz4 algorithm from a given stream.

Arguments

  • Stream src - Source stream to read data from.

Return value

1 if the blob is successfully decompressed; otherwise, 0.

StringStack<256> encode()

Encodes the blob into the base64 encoded string.

Return value

Base64 encoded string.

int eof()

Checks if the end of the blob has been reached.

Return value

1 if the end of blob is reached; otherwise, 0.

int flush()

Flushes the blob. This function has an empty body; it is created for Blob class to have the same number of methods as the File class has.

Return value

Returns 1 if the blob is successfully flushed; otherwise, 0.

void reserve(int size)

Reserves the blob, i.e. allocates (size * 1.5) bytes without resizing the blob.
Notice
The blob will be resized dynamically when the allocated memory is filled.

Arguments

  • int size - The size of the allocated memory, in bytes.

void resize(int size)

Allocates the required memory and resizes the blob.

Arguments

  • int size - The size of the blob, in bytes.

int seekCur(int offset)

Seeks the position relative to the current offset.

Arguments

  • int offset - The offset from the current position of the indicator, in bytes.

Return value

Returns 1 if the new blob position indicator is successfully set; otherwise, 0.

int seekEnd(int offset)

Seeks the position relative to the end of the blob.

Arguments

  • int offset - The offset from the end of the blob, in bytes.

Return value

Returns 1 if the blob position indicator is successfully set; otherwise, 0.

int seekSet(int offset)

Seeks the position relative to the start of blob.

Arguments

  • int offset - The offset from the beginning of the blob, in bytes.

Return value

Returns 1 if the blob position indicator is successfully set; otherwise, 0.

int tell()

Returns the current blob offset.

Return value

The blob offset.
Last update: 2017-07-03
Build: ()