NAME

src/pmc/bytebuffer.pmc - A byte buffer

DESCRIPTION

ByteBuffer provides a resizable byte buffer with random access to individual bytes and conversions from and to parrot strings.

Vtable functions

void init()
Create an empty buffer
void init_int()
Create a buffer of initial_size capacity.
void mark()
Mark the source string if any.
void destroy()
Free the buffer when destroying.
INTVAL elements()
Get current size.
void set_integer_native()
Resize the buffer to the given value.
void set_string_native()
Reset the buffer with the content of the string.
INTVAL get_integer_keyed_int()
Get the value of the byte at position or 0 if out of bounds.
void set_integer_keyed_int()
Set the value of the byte at position, resizing the buffer if the position is out of current size.
void push_integer(INTVAL value)
Extends the buffer by adding a byte of value value to the end.
PMC *get_pointer()
Return a pointer to the content. Use with care.
PMC *get_iter()
Return a new Iterator for this PMC.

Methods

get_string(string encoding)
Create a string with the buffer content and the encoding specified.
get_string_as(string as)
Create a string with the buffer content and the same encoding as the string argument.
get_chars(int pos, int length, string encoding)
Get a string from the buffer content with the specified encoding and length in codepoints.

Auxiliar functions

static INTVAL grow_to(INTVAL position)
Calculate new size enough for using position and with some margin to decrease the number of reallocations.
static STRING * build_string(PARROT_INTERP, const unsigned char *content, INTVAL size, const STR_VTABLE *encoding)
Build a string from the buffer content with the encoding specified.
static STRING * build_string_from_string(PARROT_INTERP, STRING *from, INTVAL pos, INTVAL size, const STR_VTABLE *encoding)
Build a string from part of a string content with the encoding specified.