Back to index

d-push  2.0
Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes
StringStreamWrapper Class Reference

List of all members.

Public Member Functions

 stream_open ($path, $mode, $options, &$opened_path)
 Opens the stream The string to be streamed is passed over the context.
 stream_read ($len)
 Reads from stream.
 stream_tell ()
 Returns the current position on stream.
 stream_eof ()
 Indicates if 'end of file' is reached.

Static Public Member Functions

static Open ($string)
 Instantiates a StringStreamWrapper.

Public Attributes

const PROTOCOL = "stringstream"

Private Attributes

 $stringstream
 $position
 $stringlength

Detailed Description

Definition at line 45 of file stringstreamwrapper.php.


Member Function Documentation

static StringStreamWrapper::Open ( string) [static]

Instantiates a StringStreamWrapper.

Parameters:
string$stringThe string to be wrapped

public

Returns:
StringStreamWrapper

Definition at line 123 of file stringstreamwrapper.php.

                                          {
        $context = stream_context_create(array(self::PROTOCOL => array('string' => &$string)));
        return fopen(self::PROTOCOL . "://",'r', false, $context);
    }

Here is the caller graph for this function:

Indicates if 'end of file' is reached.

public

Returns:
boolean

Definition at line 111 of file stringstreamwrapper.php.

                                 {
        return ($this->position >= $this->stringlength);
    }
StringStreamWrapper::stream_open ( path,
mode,
options,
&$  opened_path 
)

Opens the stream The string to be streamed is passed over the context.

Parameters:
string$pathSpecifies the URL that was passed to the original function
string$modeThe mode used to open the file, as detailed for fopen()
int$optionsHolds additional flags set by the streams API
string$opened_pathIf the path is opened successfully, and STREAM_USE_PATH is set in options, opened_path should be set to the full path of the file/resource that was actually opened.

public

Returns:
boolean

Definition at line 65 of file stringstreamwrapper.php.

                                                                       {
        $contextOptions = stream_context_get_options($this->context);
        if (!isset($contextOptions[self::PROTOCOL]['string']))
            return false;

        $this->position = 0;

        // this is our stream!
        $this->stringstream = $contextOptions[self::PROTOCOL]['string'];

        $this->stringlength = strlen($this->stringstream);
        ZLog::Write(LOGLEVEL_DEBUG, sprintf("StringStreamWrapper::stream_open(): initialized stream length: %d", $this->stringlength));

        return true;
    }

Here is the call graph for this function:

Reads from stream.

Parameters:
int$lenamount of bytes to be read

public

Returns:
string

Definition at line 89 of file stringstreamwrapper.php.

                                      {
        $data = substr($this->stringstream, $this->position, $len);
        $this->position += strlen($data);
        return $data;
    }

Returns the current position on stream.

public

Returns:
int

Definition at line 101 of file stringstreamwrapper.php.

                                  {
        return $this->position;
    }

Member Data Documentation

Definition at line 49 of file stringstreamwrapper.php.

Definition at line 50 of file stringstreamwrapper.php.

Definition at line 48 of file stringstreamwrapper.php.

const StringStreamWrapper::PROTOCOL = "stringstream"

Definition at line 46 of file stringstreamwrapper.php.


The documentation for this class was generated from the following file: