src/pmc/stringbuilder.pmc - StringBuilder PMC


Helper class to create and manipulate strings, which are outside of StringBuilder immutable.


void init()
Initializes the StringBuilder.
void init_int()
Initializes the StringBuilder with initial size of buffer.
void init_pmc()
Initializes the StringBuilder with an array of STRINGs.
void mark()
Mark the buffer.
STRING *get_string()
Returns created string.
STRING *push_string()
Append string to current buffer.
VTABLE i_concatenate_str()
VTABLE i_concatenate()
Append string. Synonym for push_string
VTABLE set_string_native(STRING)
VTABLE set_pmc(PMC)
Set content of buffer to passed string or PMC
VTABLE get_integer()
Returns current capacity of allocated buffer.For testing purpose only?
VTABLE substr()
Returns a copied substring of the STRING.
append_format(string fmt [, pmc args ] [, pmc hash ])
Add a line to a StringBuilder object according to fmt. The fmt string can contain any number of "%-replacements" which are replaced by the corresponding values from args or hash prior to being appended to the string. (Here args is a slurpy array, and hash is a slurpy hash.)The currently defined replacements include:
    %0 %1 ... %9     the value from the args array at index 0..9
    %,               the values of the args array separated by commas
    %%               a percent sign
A percent-sign followed by any other character that is a hash key receives the value of the hash element.
INTVAL get_string_length()
Returns length of currently built string.

Helper functions.

static size_t calculate_capacity(PARROT_INTERP, size_t needed)
Calculate capacity for string. We overallocate by 2 for smaller buffers resp. onto the next block size.
static void convert_encoding(PARROT_INTERP, STR_VTABLE *dest_encoding, STRING *buffer, size_t size_to_add)
Convert buffer content to the encoding specified and increase its size, reallocating it if needed.