serializer.bufferedstream - Palamecia/mint GitHub Wiki
Module
load serializer.bufferedstream
This module provides the Serializer.BufferedStream class which add reading
conveniant methods to an object which only provides read
and write
.
Packages
Classes
Serializer.BufferedStream
This class creates a conveniant interface for reading and writing data on an
object which only provides read
and write
. Data from the underling object
are stored in a buffer to get retrieved later.
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... |
- final |
buffer | Internal read buffer. |
- final |
codec | Internal stream codec. |
- final const |
fetchBuffer | Reads more data from the underling object and add it to the buffer. Returns ... |
+ const |
getCodec | Returns the codec that is current assigned to the stream. If the underling ob... |
+ const |
isEmpty | Returns true if the stream has no more data to read; otherwise returns fa ... |
+ const |
new | Creates a new stream for reading and writing data using object . |
- final |
object | Internal underling object. |
- final |
pos | Internal read index. |
+ 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. |
- final const |
readUntil | Reads data from the buffer until delim is found, and returns it as a string... |
+ const |
readWord | Reads a word from the stream, and returns it as a string. Words are separated... |
+ const |
setCodec | Sets the codec for this stream to codec . The codec is used for decoding any... |
+ const |
write | Writes the content of data to the stream. The content of data is converted ... |
Descriptions
Serializer.BufferedStream.<<
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.BufferedStream.>>
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.BufferedStream.buffer
null
Internal read buffer.
Serializer.BufferedStream.codec
none
Internal stream codec.
Serializer.BufferedStream.fetchBuffer
def (self)
Reads more data from the underling object and add it to the buffer. Returns
true
if more data was found; otherwise returns false
.
If the stream uses a codec initialiszed with setCodec, the object
must provide a readDataStream
or readUInt8
to read data unless it is
already an instance of Serializer.DataStream.
If no codec is provided to the stream, the object must provide a read
or readString
method.
Serializer.BufferedStream.getCodec
def (const self)
Returns the codec that is current assigned to the stream. If the underling object support codecs, the codec of the object is used; otherwise a codec is added at this level.
Serializer.BufferedStream.isEmpty
def (const self)
Returns true
if the stream has no more data to read; otherwise returns
false
.
Serializer.BufferedStream.new
def (self, object)
Creates a new stream for reading and writing data using object
.
Serializer.BufferedStream.object
null
Internal underling object.
Serializer.BufferedStream.pos
0
Internal read index.
Serializer.BufferedStream.read
def (self)
Reads all remaining data from the stream, and returns it as a string.
Serializer.BufferedStream.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.BufferedStream.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.BufferedStream.readLines
def (self)
Returns an iterator on each remaining lines of the stream.
Serializer.BufferedStream.readUntil
def (self, delim)
Reads data from the buffer until delim
is found, and returns it as a
string. The read index of the stream is then moved to the first character
identified by delim
.
Serializer.BufferedStream.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.BufferedStream.setCodec
def (self, codec)
Sets the codec for this stream to codec
. The codec is used for decoding
any data that is read from the assigned device, and for encoding any data
that is written.
If the underling class object support codecs, the codec is directly added to the pbject; otherwise the codec is managed by this class.
Serializer.BufferedStream.write
def (self, data)
Writes the content of data
to the stream. The content of data is
converted to string using the codec set by
Serializer.BufferedStream.setCodec or to an UTF-8 string by default.
The write
method of the underling object is used to write the data.