Skip to main content

Zymba Documentation

IO.Stream

Text
object @IO.Stream(@Base) {
MODE_READ;
MODE_WRITE;
canRead(): bool {}
canSeek(): bool {}
canWrite(): bool {}
close() {}
copyTo(@IO.Stream $stream, ?int $length): int {}
disableBlocking(): $this {}
echo(?int $length): int {}
echoAll(): int {}
echoLine(): int {}
enableBlocking(): $this {}
exit() {}
flush(): $this {}
getPosition(): int {}
getURI(): string {}
hasMore(): bool {}
hasTimedOut(): bool {}
isBlocking(): bool {}
isLocal(): bool {}
next(): object {}
overwrite(string $string): int {}
pollExceptional(): bool {}
pollRead(): bool {}
pollWrite(): bool {}
read(?int $length): string {}
readAll(): string {}
readLine(): string {}
readLineCSV(string $delimiter): object {}
reset(): $this {}
seek(int $position): $this {}
seekEnd(): $this {}
setReadBuffer(int $size): $this {}
setTimeout(int $timeout): $this {}
setWriteBuffer(int $size): $this {}
skip(int $offset): $this {}
toString(): string {}
truncate(int $size): $this {}
write(string $string, ?int $length): int {}
writeFormatted(string $format, ...$arguments): int {}
writeLine(string $string): int {}
writeLineCSV(object $array, string $delimiter): int {}
}

Abstract IO stream prototype.

Prototype

Base

Methods

Determines whether this stream can be read from.

CODE
$this.canRead(): bool
Returns
TypeValue
bool

Determines whether this stream can be sought.

CODE
$this.canSeek(): bool
Returns
TypeValue
bool

Determines whether this stream can be written to.

CODE
$this.canWrite(): bool
Returns
TypeValue
bool

Closes this stream and frees its associated resources.

CODE
$this.close(): void
CODE
$this.copyTo(@IO.Stream $stream, ?int $length): int
Parameters
NameTypeValueDefault
stream@IO.Streamnull
length?intmaximum length
Returns
TypeValue
int

Disables blocking mode for this stream.

CODE
$this.disableBlocking(): this
Returns
TypeValue
$this

Outputs the content of this stream up to a specific byte-based length and returns the number of bytes outputted.

CODE
$this.echo(?int $length): int
Parameters
NameTypeValueDefault
length?intmaximum length
Returns
TypeValue
int
CODE
$this.echoAll(): int
Returns
TypeValue
int

Outputs the content of this stream as far as and including the next end-of-line sequence and returns the number of bytes outputted.

CODE
$this.echoLine(): int
Returns
TypeValue
int

Enables blocking mode for this stream.

CODE
$this.enableBlocking(): this
Returns
TypeValue
$this

Closes this stream and frees its associated resources for the purpose of contextualization.

CODE
$this.exit(): void

Flushes the write buffer of this stream.

CODE
$this.flush(): this
Returns
TypeValue
$this

Gets the current position within this stream as the number of bytes from its beginning.

CODE
$this.getPosition(): int
Returns
TypeValue
int

Gets the URI associated with this stream.

CODE
$this.getURI(): string
Returns
TypeValue
string

Determines whether this stream has more content.

CODE
$this.hasMore(): bool
Returns
TypeValue
bool

Determines whether this stream has timed out.

CODE
$this.hasTimedOut(): bool
Returns
TypeValue
bool

Determines whether this stream is in blocking mode.

CODE
$this.isBlocking(): bool
Returns
TypeValue
bool

Determines whether this stream is local.

CODE
$this.isLocal(): bool
Returns
TypeValue
bool

Reads the content of this stream as far as and including the next end-of-line sequence for the purpose of iteration.

CODE
$this.next(): object
Returns
TypeValue
object[position: line]
null
CODE
$this.overwrite(string $string): int
Parameters
NameTypeValueDefault
stringstring""
Returns
TypeValue
int
CODE
$this.pollExceptional(): bool
Returns
TypeValue
bool
CODE
$this.pollRead(): bool
Returns
TypeValue
bool
CODE
$this.pollWrite(): bool
Returns
TypeValue
bool

Reads the content of this stream up to a specific byte-based length.

CODE
$this.read(?int $length): string
Parameters
NameTypeValueDefault
length?intmaximum length
Returns
TypeValue
string

Reads the entire content of this stream.

CODE
$this.readAll(): string
Returns
TypeValue
string

Reads the content of this stream as far as and including the next end-of-line sequence.

CODE
$this.readLine(): string
Returns
TypeValue
string
null
CODE
$this.readLineCSV(string $delimiter): object
Parameters
NameTypeValueDefault
delimiterstring";"
Returns
TypeValue
object[value, ...]
null
CODE
$this.reset(): this
Returns
TypeValue
$this
CODE
$this.seek(int $position): this
Parameters
NameTypeValueDefault
positionint0
Returns
TypeValue
$this
CODE
$this.seekEnd(): this
Returns
TypeValue
$this

Sets the read buffer size of this stream to a specific number of bytes.

CODE
$this.setReadBuffer(int $size): this
Parameters
NameTypeValueDefault
sizeint0
Returns
TypeValue
$this

Sets the timeout period of this stream to a specific number of seconds.

CODE
$this.setTimeout(int $timeout): this
Parameters
NameTypeValueDefault
timeoutint60
Returns
TypeValue
$this

Sets the write buffer size of this stream to a specific number of bytes.

CODE
$this.setWriteBuffer(int $size): this
Parameters
NameTypeValueDefault
sizeint0
Returns
TypeValue
$this
CODE
$this.skip(int $offset): this
Parameters
NameTypeValueDefault
offsetint1
Returns
TypeValue
$this

Converts this stream to a string by returning its associated URI.

CODE
$this.toString(): string
Returns
TypeValue
string

Truncates this stream to a specific size in number of bytes.

CODE
$this.truncate(int $size): this
Parameters
NameTypeValueDefault
sizeint0
Returns
TypeValue
$this

Writes a string to this stream up to a specific byte-based length and returns the number of bytes written.

CODE
$this.write(string $string, ?int $length): int
Parameters
NameTypeValueDefault
stringstring""
length?intmaximum length
Returns
TypeValue
int

Writes a formatted string to this stream with "printf"-compatible format specifiers ("%...") substituted with variadic arguments.

CODE
$this.writeFormatted(string $format, variadic $arguments): int
Parameters
NameTypeValueDefault
formatstring""
argumentsvariadic...
Returns
TypeValue
int

Writes a string appended by an end-of-line sequence to this stream and returns the number of bytes written.

CODE
$this.writeLine(string $string): int
Parameters
NameTypeValueDefault
stringstring""
Returns
TypeValue
int
CODE
$this.writeLineCSV(object $array, string $delimiter): int
Parameters
NameTypeValueDefault
arrayobject[value, ...][]
delimiterstring";"
Returns
TypeValue
int