This project has retired. For details please refer to its Attic page.
Clownfish::CharBuf – Apache Clownfish Documentation
Apache Lucy™

NAME

Clownfish::CharBuf - Growable buffer holding Unicode characters.

SYNOPSIS

my $buf = Clownfish::CharBuf->new;
$buf->cat('abc');
$buf->cat_char(ord("\n"));
print $buf->to_string;

DESCRIPTION

CONSTRUCTORS

new

my $char_buf = Clownfish::CharBuf->new(
    capacity => $capacity  # default: 0
);

Return a new CharBuf.

  • capacity - Initial minimum capacity of the CharBuf, in bytes.

METHODS

cat

$char_buf->cat($string);

Concatenate the contents of String string onto the end of the caller.

  • string - The String to concatenate.

cat_char

$char_buf->cat_char($code_point);

Concatenate one Unicode character onto the end of the CharBuf.

  • code_point - The code point of the Unicode character.

grow

$char_buf->grow($capacity);

Assign more memory to the CharBuf, if it doesn’t already have enough room to hold a string of size bytes. Cannot shrink the allocation.

  • capacity - The new minimum capacity of the ByteBuf.

clear

$char_buf->clear();

Clear the CharBuf.

get_size

my $int = $char_buf->get_size();

Return the size of the CharBuf’s content in bytes.

clone

my $result = $char_buf->clone();

Return a clone of the object.

yield_string

my $string = $char_buf->yield_string();

Return the content of the CharBuf as String and clear the CharBuf. This is more efficient than to_string().

INHERITANCE

Clownfish::CharBuf isa Clownfish::Obj.