This page has been translated automatically.
UnigineScript
The Language
Core Library
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
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::Buffer Class

Interface for data handling.

To use this class, include the UnigineBuffer.h file.

Unigine::Buffer Class

Members


static Ptr< Buffer > create (int size)

Buffer constructor.

Arguments

  • int size - Size of the buffer in bytes.

static Ptr< Buffer > create (const StreamPtr & stream)

Buffer constructor.

Arguments

  • const StreamPtr & stream - Stream smart pointer.

virtual void resize (int size) const =0

Allocates the required memory and resizes the buffer.

Arguments

  • int size - Size of the buffer in bytes.

virtual void allocate (int size) const =0

Allocates the required memory without resizing the buffer. It will be resized dynamically when the allocated memory is filled.

Arguments

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

virtual void reserve (int size) const =0

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

Arguments

  • int size - Size of the allocated memory.

virtual void clear () const =0

Clears the buffer size to 0.

virtual int getSize () const =0

Returns the current buffer size.

Return value

Buffer size.

virtual unsigned char * getData () const =0

Returns the current buffer data.

Return value

Buffer data.

virtual int eof () const =0

Tests if the end of the buffer has been reached.

Return value

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

virtual int getc () const =0

Gets a next symbol from the buffer.

Return value

Character read from the buffer.

virtual int seekSet (int offset) const =0

Seeks to position relative to the start of the buffer.

Arguments

  • int offset - Offset in bytes from the beginning of the buffer.

Return value

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

virtual int seekEnd (int offset) const =0

Seeks to position relative to the end of the buffer.

Arguments

  • int offset - Offset in bytes from the end of the buffer.

Return value

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

virtual int seekCur (int offset) const =0

Seeks to position relative to the current offset.

Arguments

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

Return value

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

virtual int tell () const =0

Gets the current buffer offset position indicator.

Return value

Returns the current buffer offset.

virtual int flush () const =0

Flushes the buffer.

Return value

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

virtual int decode (const char * src) const =0

Decodes a base64 encoded string into the buffer.

Arguments

  • const char * src - Source base64 encoded string.

Return value

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

virtual String encode () const =0

Encodes the buffer into the base64 encoded string.

Return value

Base64 encoded string.

virtual int compress (const Stream * dest, int quality) const =0

Compresses the buffer and writes it into the given stream.

Arguments

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

Return value

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

virtual int decompress (const Stream * src) const =0

Reads the compressed buffer from a stream and decompresses it.

Arguments

  • const Stream * src - Source stream to read data from.

Return value

Returns 1 if the buffer is decompressed successfully; otherwise, 0.
Last update: 2017-07-03
Build: ()