xplo.re Medusa Core Framework 3.1
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Event
  • Todo
  • Download

Namespaces

  • Core
    • Authentication
      • Auto
        • Driver
      • Driver
    • Cache
      • Driver
    • Charset
      • Driver
    • Configuration
    • Controller
    • Converter
      • Driver
    • Decoder
      • Driver
    • Encoder
      • Driver
    • Env
      • Authentication
      • Locale
      • Proxy
      • Server
        • HTTP
        • Redirect
        • X
    • Exception
    • Exchange
      • Driver
    • Field
    • Filter
      • Driver
    • Formatter
      • Driver
        • coreuimarkup
          • Token
    • Hash
    • Loader
    • Locale
    • Log
      • Driver
    • Module
      • Dependency
        • Requirement
          • Core
          • PHP
      • Linkage
        • Driver
    • PDF
    • Plugin
    • Query
      • Driver
    • Server
      • Driver
    • Session
      • Driver
    • Set
    • Storage
      • Driver
      • Field
        • Element
    • Stream
      • Driver
    • String
    • Translation
      • Driver
      • Language
        • Driver
    • URI
      • Driver
    • Version
    • View
      • Driver
        • coreui
          • Control
            • Button
            • Table
          • Element
        • htmlbuilder
          • Tags
        • yui
          • Modules
  • None
  • PHP

Classes

  • Authentication
  • Authentication_Token
  • Autoloader
  • Cache
  • Charset
  • ClassDescriptor
  • Closure
  • Controller
  • Converter
  • Date
  • Decoder
  • Delegate
  • Dispatcher
  • Encoder
  • Env
  • Env_Field
  • Env_File
  • Env_FileList
  • Env_Request
  • Env_SERVER
  • Exchange
  • Fault
  • Field
  • Filter
  • Filter_Value
  • Formatter
  • Hash
  • IP
  • Loader
  • Locale
  • Locale_Iterator
  • Locale_Node
  • Log
  • Module
  • Module_Iterator
  • Nothing
  • Object
  • OS
  • Plugin
  • Profiler
  • Query
  • Registry
  • Resource
  • Server
  • Session
  • Session_Token
  • Set
  • Storage
  • Storage_Result
  • Storage_Statement
  • Stream
  • String
  • Translation
  • URI
  • URI_Parameters
  • UUID
  • Value
  • Version
  • View

Interfaces

  • Accessor
  • Chainable
  • Comparable
  • Configurable
  • Equality
  • Identity
  • Inquiry
  • Masquerade
  • Mutator
  • SeekableStream
  • Storable
  • Variator

Exceptions

  • Exception

Constants

  • Copyright
  • ProductName
  • UseVersion
  • Version

Functions

  • ns_expand
  • ns_file_exists
  • ns_get_version
  • ns_resolve

Class Stream

Streaming interface base class.

Core\Object implements Core\Chainable
Extended by Core\Set implements Core\Accessor
Extended by Core\Stream

Direct known subclasses

Core\Stream\Buildin, Core\Stream\Driver\csv, Core\Stream\Driver\null

Indirect known subclasses

Core\Stream\Driver\file, Core\Stream\Driver\input, Core\Stream\Driver\memory, Core\Stream\Driver\output, Core\Stream\Driver\stderr, Core\Stream\Driver\stdin, Core\Stream\Driver\stdout, Core\Stream\Driver\swap

Abstract
Namespace: Core
Package: Core\Stream
Since: 3.0
Requires: PHP 5.3
Version: 1.0
Located at Stream.inc.php

Methods summary

public
# __construct( Core\URI $uri )

Initialises a new stream interface.

Initialises a new stream interface.

Parameters

$uri
URI instance describing the stream interface to initialise.

Since

3.0
public
# __destruct( )

Automatically dismantles the stream, if required.

Automatically dismantles the stream, if required.

Since

3.0
protected
# _verifyAccess( integer $access )

Parameters

$access

Throws

Core\Exception\Stream

Since

3.0
public static Core\Stream
# autocreate( Core\URI $uri )

Creates a new stream object specified by the given URI.

Creates a new stream object specified by the given URI.

Parameters

$uri
URI object describing the requested stream interface.

Returns

Core\Stream
New Stream object from given identifier.

Throws

Core\Exception\InvalidDriver
Failed to load driver specified by the named interface.

Since

3.0
public boolean
# canCreate( )

Returns

boolean

Since

3.0
public boolean
# canRead( )

Returns

boolean

Since

3.0
public boolean
# canWrite( )

Returns

boolean

Since

3.0
public boolean
# canStat( )

Returns

boolean

Since

3.0
public boolean
# canTruncate( )

Returns

boolean

Since

3.0
public integer|boolean
# chain( Core\Chainable $object, array $flags = null )

Connects another object to the current object. Usage depends on the actual class implementation; common examples are lazy configuration completion or layer expansions. Assigned Encoder or Decoder wrappers to the current Stream object.

Connects another object to the current object. Usage depends on the actual class implementation; common examples are lazy configuration completion or layer expansions. Assigned Encoder or Decoder wrappers to the current Stream object.

Support for Encoder oder Decoder wrappers depend on the implementation of the derived Stream class. Supporting Stream derivations pass segments for writing through the chain of Encoders, read segments are passed through the chain of Decoders.

Parameters

$object
Object to chain to instance.
$flags

Optional array of additional chain flags. Usage depends on the actual chain implementation.

Returns

integer|boolean
Returns a non-zero value on success, otherwise false.

Throws

Core\Exception\InvalidArgument
Class of provided object is not supported.

Since

3.0

Overrides

Core\Object::chain
public
# dismantle( )

Returns


$this

Event

Delegate Stream.Dismantle triggered after a stream has been dismantled.

Since

3.0
public
# establish( integer $access )

Establishes the stream interface.

Establishes the stream interface.

Parameters

$access

Returns


$this

Since

3.0
public boolean
# flush( )

Flushes any stream-specific output buffers.

Flushes any stream-specific output buffers.

This method is heavily depended on the actual driver back-end. The default implementation does nothing and returns true.

Returns

boolean
true on success, otherwise false.

Since

3.0
abstract public integer|null
# length( )

Returns the size of the Stream in units.

Returns the size of the Stream in units.

Returns

integer|null
Size of stream in units or null, if length is unknown.

Since

3.0
abstract public mixed
# read( integer $units )

Reads from stream.

Reads from stream.

Parameters

$units
Length in units to read from stream.

Returns

mixed
Returns segments read from stream or null on error.

Remark

Implementations of derived classes should implement support for chained Decoder instances.


See

Core\Stream::readln()

Since

3.0
public mixed|null
# readln( integer $limit = null )

Reads a line from the stream.

Reads a line from the stream.

Parameters

$limit
Optional. Maximum number of units to read from stream.

Returns

mixed|null
Returns segments read from stream or null on error.

Remark

Chained Decoder instances are applied equally to the standard Core\Stream::read() method (with a ending newline character excluded).


See

Core\Stream::read()

Since

3.0
public mixed|null
# readRemainingSegments( )

Reads all available segments from stream, if stream is finite.

Reads all available segments from stream, if stream is finite.

Returns

mixed|null
Returns segments read from stream or null, if stream is infinite.

Remark

The default implementation is based on the value returned from Core\Stream::length(); thus even though a stream is finite, this method might not work as expected for incomplete wrappers.


Since

3.0
public static Core\Stream
# stderr( )

Returns a new and established standard error Stream object.

Returns a new and established standard error Stream object.

Returns

Core\Stream
New established standard error Stream object.

See

Core\Stream::stdout()
Core\Stream::stdin()

Since

3.1
public static Core\Stream
# stdin( )

Returns a new and established standard input Stream object.

Returns a new and established standard input Stream object.

Returns

Core\Stream
New established standard input Stream object.

See

Core\Stream::stdout()
Core\Stream::stderr()

Since

3.1
public static Core\Stream
# stdout( )

Returns a new and established standard output Stream object.

Returns a new and established standard output Stream object.

Returns

Core\Stream
New established standard output Stream object.

See

Core\Stream::stderr()
Core\Stream::stdin()

Since

3.1
abstract public integer
# write( mixed $segments, integer $units = null )

Writes to stream.

Writes to stream.

Parameters

$segments
Segments to write to stream.
$units
Maximum number of units to write to stream.

Returns

integer
Returns the number of units written to the stream.

Remark

Implementations of derived classes should implement support for chained Encoder instances.


See

Core\Stream::writeln()

Since

3.0
public integer
# writeln( string $string = null )

Writes a string, followed by a newline (LF) character, to the stream.

Writes a string, followed by a newline (LF) character, to the stream.

Parameters

$string
String to write to stream.

Returns

integer
Returns the number of units written to the stream.

Remark

Chained Encoder instances are applied equaly to the standard Core\Stream::write() method (with the ending newline character included).


See

Core\Stream::write()

Since

3.0

Methods inherited from Core\Set

__get(), __isset()

Methods inherited from Core\Object

__autocreateFactory(), __call(), __processParameters(), __toString(), attachMethod(), getValueForKey(), getValueForKeyPath(), getValueForUndefinedKey(), hash(), issetValueForKey(), setValueForKey(), setValueForKeyPath(), setValueForUndefinedKey(), uuid()

Constants summary

string CharsetParameter

Charset of Stream data (for reading and writing). Defaults to false, which does not perform on-the-fly character set translations.

Charset of Stream data (for reading and writing). Defaults to false, which does not perform on-the-fly character set translations.

Since

3.0
# 'charset'
integer Stat

Access flag for readings stream status information.

Access flag for readings stream status information.

Since

3.0
# 1
integer Read

Establishes Stream connection for reading.

Establishes Stream connection for reading.

Since

3.0
# 2
integer Write

Establishes Stream connection for writing.

Establishes Stream connection for writing.

This flag does not create a non-existing the Stream endpoint. Write operations will append the Stream, if the Truncate flag is not set.

See

Core\Stream::Create
Core\Stream::Truncate

Since

3.0
# 4
integer Truncate

Truncates the Stream if possible. Otherwise write operations append stream data.

Truncates the Stream if possible. Otherwise write operations append stream data.

Since

3.0
# 8
integer Create

Creates the Stream endpoint, if the destination does not exist.

Creates the Stream endpoint, if the destination does not exist.

If this flag is not set, status flags, reading and writing will fail, if the Stream endpoint does not exist.

Since

3.0
# 16

Constants inherited from Core\Object

AnyParameterType, AutochainParameterType, AutocreateParameterType, BooleanParameterType, CharParameterType, EnumParameterType, IntegerParameterType, RealParameterType, StringParameterType, UserParameterType

Properties summary

protected integer $_v_access

Currently established access bit flags.

Currently established access bit flags.

Since

3.0
# 0
protected Core\Decoder $_v_decoder

Active (chained) decoder instance or null, if no decoder is used.

Active (chained) decoder instance or null, if no decoder is used.

Since

3.0
#
protected Core\Encoder $_v_encoder

Active (chained) encoder instance or null, if no encoder is used.

Active (chained) encoder instance or null, if no encoder is used.

Since

3.0
#
protected boolean $_v_established

true, if stream is established, otherwise false.

true, if stream is established, otherwise false.

Since

3.0
#
protected Core\Delegate $_v_onDismantle

Delegate invoked if an established stream is dismantled.

Delegate invoked if an established stream is dismantled.

Since

3.1
#
protected array $_v_parameters

Associative array of Stream parameters set for this instance.

Associative array of Stream parameters set for this instance.

Since

3.0
#
protected Core\URI $_v_uri

URI used to create the current Stream instance.

URI used to create the current Stream instance.

Since

3.0
#

Magic properties

public read-only integer $access

Access status flag.

public read-only boolean $canCreate

true, if the stream is established and has create access, otherwise false.

public read-only boolean $canRead

true, if the stream is established and has read access, otherwise false.

public read-only boolean $canStat

true, if the stream is established and has stat access, otherwise false.

public read-only boolean $canTruncate

true, if the stream is established and has truncation enabled, otherwise false.

public read-only boolean $canWrite

true, if the stream is established and has write access, otherwise false.

public read-only Core\Decoder $decoder

Chained decoder instance to transparently decode data being read.

public read-only Core\Encoder $encoder

Chained encoder instance to transparently encode data being written.

public read-only boolean $established

true, if the stream is established, otherwise false.

public read-only integer $length

Length of the stream in units or null, if the length is unknown.

public read-only Core\Delegate $onDismantle

Callback invoked if stream is dismantled.

public read-only array $parameters

Associative array of stream parameters from configuration URI.

public read-only Core\URI $uri

Configuration URI.

Magic properties inherited from Core\Object

$hash, $uuid

xplo.re Medusa Core Framework 3.1 API documentation generated by ApiGen