MPD  0.20.15
Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions | Static Protected Member Functions
Page Class Reference

A dynamically allocated buffer which keeps track of its reference count. More...

#include <Page.hxx>

Public Member Functions

void Ref ()
 Increases the reference counter. More...
 
bool Unref ()
 Decreases the reference counter. More...
 

Static Public Member Functions

static PageCopy (const void *data, size_t size)
 Creates a new #page object, and copies data from the specified buffer. More...
 
static PageConcat (const Page &a, const Page &b)
 Concatenates two pages to a new page. More...
 

Data Fields

const size_t size
 The size of this buffer in bytes. More...
 
unsigned char data [sizeof(long)]
 Dynamic array containing the buffer data. More...
 

Protected Member Functions

 Page (size_t _size)
 
 ~Page ()=default
 

Static Protected Member Functions

static PageCreate (size_t size)
 Allocates a new Page object, without filling the data element. More...
 

Detailed Description

A dynamically allocated buffer which keeps track of its reference count.

This is useful for passing buffers around, when several instances hold references to one buffer.

Definition at line 37 of file Page.hxx.

Constructor & Destructor Documentation

◆ Page()

Page::Page ( size_t  _size)
inlineprotected

Definition at line 58 of file Page.hxx.

◆ ~Page()

Page::~Page ( )
protecteddefault

Member Function Documentation

◆ Concat()

static Page* Page::Concat ( const Page a,
const Page b 
)
static

Concatenates two pages to a new page.

Parameters
athe first page
bthe second page, which is appended

◆ Copy()

static Page* Page::Copy ( const void *  data,
size_t  size 
)
static

Creates a new #page object, and copies data from the specified buffer.

It is initialized with a reference count of 1.

Parameters
datathe source buffer
sizethe size of the source buffer

◆ Create()

static Page* Page::Create ( size_t  size)
staticprotected

Allocates a new Page object, without filling the data element.

◆ Ref()

void Page::Ref ( )
inline

Increases the reference counter.

Definition at line 89 of file Page.hxx.

◆ Unref()

bool Page::Unref ( )

Decreases the reference counter.

If it reaches zero, the #page is freed.

Returns
true if the #page has been freed

Field Documentation

◆ data

unsigned char Page::data[sizeof(long)]

Dynamic array containing the buffer data.

Definition at line 55 of file Page.hxx.

◆ size

const size_t Page::size

The size of this buffer in bytes.

Definition at line 50 of file Page.hxx.


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