up: IO     index Zimbu documentation

CLASS IO.StringWriter EXTENDS IO.Writer @public

summary

     

A Writer that stores the text in a string. Use ToString() to get the result.

$write(text) status @public  Writes text and returns OK.
$writeByte(byte) status @public  Appends one byte byte and returns OK.
$byteSize() int @public  Returns the current string length in bytes.
$Size() int @public  Returns the current string length in characters.
$empty() bool @public  Returns TRUE if the size is zero.
$ToString() string @public  Returns the current string.
$remove() int @public  Takes one character from the end of the string and returns it.
$clear() @public  Clear the contents of the writer, reset it to empty, free buffer.
$truncate() @public  Clear the contents of the writer, reset it to empty, keeping the buffer.
 
Inherited from IO.Writer:
$write(text) status @public  Writes text converted to a string.
$write(number) status @public  Writes number as a decimal number.
$write(number) status @public  Writes number as a decimal number.
$write(number) status @public  Writes number as a decimal number.
$write(flag) status @public  Writes flag as "TRUE" or "FALSE".
$write(ok) status @public  Writes ok as "FAIL" or "OK".
$write(arg) status @public  Writes arg depending on its actual type. Returns FAIL or OK.
$writeChar(char) status @public  Writes char as a UTF-8 byte sequence.
$print(text) status @public  Writes text and appends a newline. Returns FAIL or OK.
$print(number) status @public  Writes number and appends a newline. Returns FAIL or OK.
$print(number) status @public  Writes number and appends a newline. Returns FAIL or OK.
$print(number) status @public  Writes number and appends a newline. Returns FAIL or OK.
$print(flag) status @public  Writes flag as "TRUE" or "FALSE" and appends a newline. Returns FAIL or OK.
$print(ok) status @public  Writes ok as "FAIL" or "OK" and appends a newline. Returns FAIL or OK.
$print(arg) status @public  Writes arg depending on its actual type and appends a newline. Returns FAIL or OK.
$print() status @public  Writes a newline and returns FAIL or OK.
$format(fmt, arguments) status @public  Formats the string and writes it with a newline appended.
 

members (alphabetically)

     

FUNC $Size() int @public

     

Returns the current string length in characters.

FUNC $ToString() string @public

     

Returns the current string.

Writing may continue after this.

FUNC $byteSize() int @public

     

Returns the current string length in bytes.

PROC $clear() @public

     

Clear the contents of the writer, reset it to empty, free buffer.

When writing next a new buffer will be allocated.

FUNC $empty() bool @public

     

Returns TRUE if the size is zero.

This is quicker than using $Size() and comparing with zero.

FUNC $remove() int @public

     

Takes one character from the end of the string and returns it.

If the string is empty returns IO.eof.

PROC $truncate() @public

     

Clear the contents of the writer, reset it to empty, keeping the buffer.

The buffer will remain being allocated, memory will not be freed.

FUNC $write(string text) status @public

     

Writes text and returns OK.

FUNC $writeByte(int byte) status @replace @public

     

Appends one byte byte and returns OK.

Only the lower 8 bits of byte are used, the rest is ignored.

license

      Copyright 2009 Bram Moolenaar All Rights Reserved.

      Licensed under the Apache License, Version 2.0. See the LICENSE file or obtain a copy at: http://www.apache.org/licenses/LICENSE-2.0