Name
SPVM::StringBuffer - String Buffer
Usage
use StringBuffer;
# new
my $buffer = StringBuffer->new;
# push string
$buffer->push("abc");
$buffer->push("def");
# Convert to string - abcdef
my $string = $buffer->to_string;
Description
String buffer.
Fields
length
has length : ro int;
The length.
value
has value : ro mutable string;
The value. This is the internally used string, but it can be manipulated directly.
my $value = $buffer->value;
$valeu->[0] = 'a';
Class Methods
new
static method new : StringBuffer ()
Create new StringBuffer
object.
Instance Methods
push
method push : void ($string : string)
Add a string after the end of the string in the string buffer.
push_char
method push_char : void ($char : byte)
Add a character after the end of the string in the string buffer.
replace
method replace : void ($offset : int, $length : int, $replace : string)
Replace the characters of the range specified by the offset and the lenght with the replacement string.
The offset must be greater than or equal to 0
. Otherwise an exception will be thrown.
The offset + the removing lenght must be less than or equal to the length of the string buffer. Otherwise an exception will be thrown.
to_string
method to_string : string ()
Convert the string buffer to a string.