This page has been translated automatically.
Getting Started
Migrating to UNIGINE 2.0
C++ API Migration
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
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Blob Class

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.

Warning
The old Buffer class has been renamed Blob. All functionality remains the same.

See Also

Blob Class

This class inherits from Stream

Members


Blob (int size = 0)

Constructor. Creates a new blob of the specified size.

Arguments

  • int size - Blob size.

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

Returns 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 successfully decoded; 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

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

StringStack<256> encode ()

Encodes the blob into the base64 encoded string.

Return value

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

StringStack<256> getCRC32 ()

Returns the 32-bit CRC checksum.

Return value

The 32-bit CRC checksum.

void getCRC32 (int id = [])

Returns the 32-bit CRC checksum.

Arguments

  • int id - The array, into which the 32-bit CRC checksum is written. The array will be resized automatically.

StringStack<256> getMD5 ()

Returns the 128-bit MD5 checksum.

Return value

The 128-bit MD5 checksum.

void getMD5 (int id = [])

Returns the 128-bit MD5 checksum.

Arguments

  • int id - The array, into which the 128-bit MD5 checksum is written. The array will be resized automatically.

StringStack<256> getSHA1 ()

Returns the 160-bit SHA1 checksum.

Return value

The 160-bit SHA1 checksum.

void getSHA1 (int id = [])

Returns the 160-bit SHA1 checksum.

Arguments

  • int id - The array, into which the 160-bit SHA1 checksum is written. The array will be resized automatically.

int getSize ()

Returns the current size of the blob.

Return value

The size of the blob.

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.

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.

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

Returns the current blob offset.

Return value

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