ITextStream

Description

interface Tinman.Core.IO.Streams.ITextStream

A IDataStream object provides access to a file in the filesystem in a stream oriented (i.e. sequential) manner.

The interface provides methods for manipulating the file cursor of the underlying file in the filesystem and methods for reading and writing of single bytes values and blocks of bytes.

Additional methods provide support for reading and writing of multibyte values, byte endianness and a file cursor stack for simplified navigation in data streams that support seeking.

Public / Methods

Read


public method Read → (3)

chars in : char [ ]

[not-null]
The buffer where the read characters will be stored.

offset opt : int32 = 0

[0..chars.Length]
Offset into chars in.

count opt : int32 = -1

[-1..chars.Length-offset]
Number of characters to read. If -1, characters will be read up to the end of chars in.

returns → int32

The number of characters that have been read into chars in. A value of 0 indicates that the end of the stream has been reached (assuming that the given count was greater than zero).

Reads a number of characters from the stream.

The number of characters that are read from the stream may be less than the given count, for any reason.

IOException

If an I/O error has occurred.

Read​Char


public method ReadChar → ()

returns → char

The read character.

Reads a single character from the stream.

IOException

If an I/O error has occurred.

Read​To​End


[OwnerThis]
public method ReadToEnd → ()

returns → string

The read string.

Reads all remaining characters from this stream and disposes this stream afterwards.

IOException

If an I/O error has occurred.

Skip


public method Skip → (1)

count in : int64

[>=0]
The number of characters to skip.

Skips the next characters in the stream.

IOException

If an I/O error has occurred.

Try​Read​Char


public method TryReadChar → ()

returns → int32

The read character or -1 if the end of the stream has been reached.

Reads a single character from the stream.

IOException

If an I/O error has occurred.

Write

4 overloads


public method Write1 → (1)

chars in : string

[not-null]
The characters to write.

Writes a number of characters to the stream.

IOException

If an I/O error has occurred.


public method Write2 → (1)

chars in : char [ ]

[not-null]
The characters to write.

Writes a number of characters to the stream.

IOException

If an I/O error has occurred.


public method Write3 → (3)

chars in : string

[not-null]
The characters to write.

offset in : int32

[>=0]
Offset into chars in.

count in : int32

[>=0]
Number of characters to write.

Writes a number of characters to the stream.

IOException

If an I/O error has occurred.


public method Write4 → (3)

chars in : char [ ]

[not-null]
The characters to write.

offset in : int32

[>=0]
Offset into chars in.

count in : int32

[>=0]
Number of characters to write.

Writes a number of characters to the stream.

IOException

If an I/O error has occurred.

Write​Char


public method WriteChar → (1)

value in : char

The character to write.

Writes a single characters to the stream.

IOException

If an I/O error has occurred.

Public / Attributes

Encoding


public attribute Encoding → (get)

value : CharacterEncoding

The character encoding or null if not known or if there is no underlying binary data stream.

Returns the character encoding that is used by this text stream.

Extensions

Decode​Base85


[OwnerReturn] [OwnerThis]
public static method DecodeBase85 → ()

returns → IDataStream

The read-only data stream.

Decodes binary data using a base-85 encoding after reading it from this text stream.

This is the mapping between base-85 digits and printable 7-bit ASCII characters:

!#$%()*+,-.0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[^_abcdefghijklmnopqrstuvwxyz{|}~
^         ^         ^         ^         ^         ^         ^         ^         ^    ^
0         10        20        30        40        50        60        70        80   85

The following printable ASCII characters are not used by the encoding, which allows encoded string to be used safely in various contexts (e.g. string literals, XML text, XML attributes, XML CDATA sections):

"&'/<>\]`

Encode​Base85


[OwnerReturn] [OwnerThis]
public static method EncodeBase85 → (2)

columns opt : int32 = 80

[>=0]
Number of columns to output before a line break is emitted. If set to 0, no line breaks will be emitted at all.

lineEnding opt : LineEnding = LineEnding.Native

The line ending token to use for emitting line breaks.

returns → IDataStream

The write-only data stream.

Encodes binary data using a base-85 encoding before writing it to this text stream.

This is the mapping between base-85 digits and printable 7-bit ASCII characters:

!#$%()*+,-.0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[^_abcdefghijklmnopqrstuvwxyz{|}~
^         ^         ^         ^         ^         ^         ^         ^         ^    ^
0         10        20        30        40        50        60        70        80   85

The following printable ASCII characters are not used by the encoding, which allows encoded string to be used safely in various contexts (e.g. string literals, XML text, XML attributes, XML CDATA sections):

"&'/<>\]`

Read​Eof


public static method ReadEof → (3)

chars in : char [ ]

[not-null]
The buffer where the read characters will be stored.

offset opt : int32 = 0

[0..chars.Length]
Offset into chars in.

count opt : int32 = -1

[-1..chars.Length-offset]
Number of characters to read. If -1, characters will be read up to the end of chars in.

returns → int32

The number of characters that have been read into chars in. A value of 0 indicates that the end of the stream has been reached (assuming that the given count was greater than zero).

Reads a number of characters from the stream.

The number of characters that are read from the stream will be less than the given count only if the end of the stream has been reached.

IOException

If an I/O error has occurred.