serializer.textstream - Palamecia/mint GitHub Wiki
Module
load serializer.textstream
This module provides the Serializer.TextStream class which implement a stream interface for reading and writing text on any kind of object.
Packages
Classes
Serializer.TextStream
This class provides an interface to use any object as a stream for reading and writing text.
Public members
Modifiers | Member | Description |
---|---|---|
const |
<< | Writes the string data to the stream, and returns a reference to the stream... |
const |
>> | Reads a word from the stream and stores it in data , then returns a referenc... |
const |
getCodec | Returns the codec that is current assigned to the stream. It correspond to th... |
const |
isEmpty | Returns true if the stream has no more data to read; otherwise returns fa ... |
const |
new | Creates a new stream on the stream object. If the object provides all the m... |
const |
read | Reads all remaining data from the stream, and returns it as a string. |
const |
readChar | Reads the next character from the stream, and returns it as a string. Data is... |
const |
readLine | Reads the next line from the stream, and returns it as a string. Data is read... |
const |
readLines | Returns an iterator on each remaining lines of the stream. |
const |
readWord | Reads a word from the stream, and returns it as a string. Words are separated... |
const |
setCodec | Forwards the codec to the underling object if supported. |
const |
write | Writes the content of data to the stream. The write method of the underli... |
Private members
Modifiers | Member | Description |
---|---|---|
final const |
createInternalStream | Returns a stream object for stream-like manipulations on the stream object. |
final |
stream | Internal underling stream. |
Descriptions
Serializer.TextStream.<<
def (self, data)
Writes the string data
to the stream, and returns a reference to the
stream. The string is first encoded using the assigned codec (the default
is UTF-8) before it is written to the stream.
Serializer.TextStream.>>
def (self, data)
Reads a word from the stream and stores it in data
, then returns a
reference to the stream. Words are separated by whitespace (i.e., all
characters for which isSpace returns true
).
Leading whitespace are skipped.
Serializer.TextStream.createInternalStream
def (self, stream)
Returns a stream object for stream-like manipulations on the stream
object.
Serializer.TextStream.getCodec
def (const self)
Returns the codec that is current assigned to the stream. It correspond
to the codec of the underling stream or none
if the underling stream
does not support codec.
Serializer.TextStream.isEmpty
def (const self)
Returns true
if the stream has no more data to read; otherwise returns
false
.
Serializer.TextStream.new
def (self, stream)
Creates a new stream on the stream
object.
If the object provides all the methods of a stream object (readChar
,
readWord
, readLine
, readLines
, read
and write
), that methods
are directly used by the class.
If the object provides at least read
and write
methods, the object
is used through an instance of Serializer.BufferedStream. The read
method can also be replaced by a readString
and a readDataStream
or
readUInt8
method.
If the object does not provides any of that methods, it is used through an instance of Serializer.StringStream.
Serializer.TextStream.read
def (self)
Reads all remaining data from the stream, and returns it as a string.
Serializer.TextStream.readChar
def (self)
Reads the next character from the stream, and returns it as a string. Data is read until a valid character is read or if the end of stream is detected.
Serializer.TextStream.readLine
def (self)
Reads the next line from the stream, and returns it as a string.
Data is read until a '\n'
character is read or if the end of
stream is detected.
Serializer.TextStream.readLines
def (self)
Returns an iterator on each remaining lines of the stream.
Serializer.TextStream.readWord
def (self)
Reads a word from the stream, and returns it as a string. Words are
separated by whitespace (i.e., all characters for which isSpace
returns true
).
Leading whitespace are skipped.
Serializer.TextStream.setCodec
def (self, codec)
Forwards the codec
to the underling object if supported.
Serializer.TextStream.stream
null
Internal underling stream.
Serializer.TextStream.write
def (self, data)
Writes the content of data
to the stream.
The write
method of the underling object is used to write the data.