Loading...
Searching...
No Matches
Bufferabstract

#include <Ultralight/Buffer.h>

Overview

A fixed-size container for raw byte data.

This class is used to represent raw data buffers in Ultralight. It intelligently manages the lifetime of the data and can optionally call a user-supplied callback to deallocate the data when the Buffer is destroyed.

Inheritance diagram for Buffer:
RefCounted

Static Public Member Functions

static RefPtr< BufferCreate (void *data, size_t size, void *user_data, DestroyBufferCallback destruction_callback)
 Create a Buffer from existing, user-owned data without any copies.
 
static RefPtr< BufferCreateFromCopy (const void *data, size_t size)
 Create a Buffer from existing data, a deep copy of data will be made.
 

Public Member Functions

virtual void * data ()=0
 Get a pointer to the raw byte data.
 
virtual size_t size () const =0
 Get the size in bytes.
 
virtual void * user_data ()=0
 Get the user data associated with this Buffer, if any.
 
virtual bool owns_data () const =0
 Check whether this Buffer owns its own data (Buffer was created via CreateFromCopy).
 
- Public Member Functions inherited from RefCounted
virtual void AddRef () const =0
 
virtual void Release () const =0
 
virtual int ref_count () const =0
 

Protected Member Functions

 Buffer ()
 
virtual ~Buffer ()
 
 Buffer (const Buffer &)
 
void operator= (const Buffer &)
 
- Protected Member Functions inherited from RefCounted
virtual ~RefCounted ()
 

Constructor & Destructor Documentation

◆ Buffer() [1/2]

Buffer ( )
protected

◆ ~Buffer()

virtual ~Buffer ( )
protectedvirtual

◆ Buffer() [2/2]

Buffer ( const Buffer & )
protected

Member Function Documentation

◆ Create()

static RefPtr< Buffer > Create ( void * data,
size_t size,
void * user_data,
DestroyBufferCallback destruction_callback )
static

Create a Buffer from existing, user-owned data without any copies.

An optional, user-supplied callback will be called to deallocate data upon destruction.

Parameters
dataA pointer to the data.
sizeSize of the data in bytes.
user_dataOptional user data that will be passed to destruction_callback when the returned Buffer is destroyed.
destruction_callbackOptional callback that will be called upon destruction. Pass a null pointer if you don't want to be informed of destruction.
Returns
A ref-counted Buffer object that wraps the existing data.

◆ CreateFromCopy()

static RefPtr< Buffer > CreateFromCopy ( const void * data,
size_t size )
static

Create a Buffer from existing data, a deep copy of data will be made.

◆ data()

virtual void * data ( )
pure virtual

Get a pointer to the raw byte data.

◆ operator=()

void operator= ( const Buffer & )
protected

◆ owns_data()

virtual bool owns_data ( ) const
pure virtual

Check whether this Buffer owns its own data (Buffer was created via CreateFromCopy).

If this is false, Buffer will call the user-supplied destruction callback to deallocate data when this Buffer instance is destroyed.

◆ size()

virtual size_t size ( ) const
pure virtual

Get the size in bytes.

◆ user_data()

virtual void * user_data ( )
pure virtual

Get the user data associated with this Buffer, if any.


The documentation for this class was generated from the following file: