src/pmc/stringbuilder.pmc - StringBuilder PMC Class


TODO: Add description here.


void init()
Initializes the StringBuilder.
void init_int()
Initializes the StringBuilder with initial size of buffer.
void destroy()
Free the buffer on destruction.
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_str()
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 current, size_t additional)
Calculate capacity for string. Usually StringBuilders used for "large" strings. So capacity rounded up by next algorithm: - By 128 bytes if total capacity less then 1KB - By 1KB if total less than 4KB - By 4KB if total less than 1MB - By 1MB otherwise.This function is subject for tuning on real-world usage scenarios.