Hoa central
Public Member Functions | Protected Member Functions | Static Private Attributes | List of all members
Hoa\Stringbuffer\Stringbuffer Class Reference
Inheritance diagram for Hoa\Stringbuffer\Stringbuffer:

Public Member Functions

 __construct ($streamName=null)
 
 newBuffer ($callable=null, $size=null)
 
 flush ()
 
 deleteBuffer ()
 
 getBufferLevel ()
 
 getBufferSize ()
 
 lock ($operation)
 
 rewind ()
 
 seek ($offset, $whence=Stream\IStream\Pointable::SEEK_SET)
 
 tell ()
 
 initializeWith ($string)
 
- Public Member Functions inherited from Hoa\Stream\Stream
 __construct ($streamName, $context=null, $wait=false)
 
 open ()
 
 close ()
 
 getStreamName ()
 
 getStreamContext ()
 
 _setStream ($stream)
 
 isOpened ()
 
 setStreamTimeout ($seconds, $microseconds=0)
 
 setStreamBlocking ($mode)
 
 setStreamBuffer ($buffer)
 
 disableStreamBuffer ()
 
 getStreamBufferSize ()
 
 getStreamWrapperName ()
 
 getStreamMetaData ()
 
 isBorrowing ()
 
 on ($listenerId, $callable)
 
 _notify ($ncode, $severity, $message, $code, $transferred, $max)
 
 __toString ()
 
 __destruct ()
 

Protected Member Functions

_open ($streamName, Stream\Context $context=null)
 
 _close ()
 
- Protected Member Functions inherited from Hoa\Stream\Stream
_open ($streamName, Context $context=null)
 
 _close ()
 
 getStream ()
 

Static Private Attributes

static $_i = 0
 

Additional Inherited Members

- Static Public Member Functions inherited from Hoa\Stream\Stream
static getStreamHandler ($streamName)
 
static _Hoa_Stream ()
 
- Public Attributes inherited from Hoa\Stream\Stream
const NAME = 0
 
const HANDLER = 1
 
const RESOURCE = 2
 
const CONTEXT = 3
 
- Public Attributes inherited from Hoa\Stream\IStream\Lockable
const LOCK_SHARED = LOCK_SH
 
const LOCK_EXCLUSIVE = LOCK_EX
 
const LOCK_RELEASE = LOCK_UN
 
const LOCK_NO_BLOCK = LOCK_NB
 
- Public Attributes inherited from Hoa\Stream\IStream\Pointable
const SEEK_SET = SEEK_SET
 
const SEEK_CURRENT = SEEK_CUR
 
const SEEK_END = SEEK_END
 
- Protected Attributes inherited from Hoa\Stream\Stream
 $_bucket = []
 
 $_bufferSize = 8192
 
 $_streamName = null
 
 $_context = null
 
 $_hasBeenDiffered = false
 
 $_on = null
 
 $_borrowed = false
 

Detailed Description

Class .

This class allows to manipulate a string as a stream.

Definition at line 50 of file Stringbuffer.php.

Constructor & Destructor Documentation

Hoa\Stringbuffer\Stringbuffer::__construct (   $streamName = null)

Open a new string buffer.

Parameters
string$streamNameStream name.
Returns
void
Exceptions

Definition at line 72 of file Stringbuffer.php.

73  {
74  if (null === $streamName) {
75  $streamName = 'hoa://Library/Stringbuffer#' . self::$_i++;
76  }
77 
78  parent::__construct($streamName, null);
79 
80  return;
81  }

Member Function Documentation

Hoa\Stringbuffer\Stringbuffer::_close ( )
protected

Close the current stream.

Returns
bool

Definition at line 106 of file Stringbuffer.php.

107  {
108  return @fclose($this->getStream());
109  }

Here is the call graph for this function:

& Hoa\Stringbuffer\Stringbuffer::_open (   $streamName,
Stream\Context  $context = null 
)
protected

Open the stream and return the associated resource.

Parameters
string$streamNameStream name (here, it is null).
\Hoa\Stream\Context$contextContext.
Returns
resource
Exceptions

Definition at line 92 of file Stringbuffer.php.

93  {
94  if (false === $out = @tmpfile()) {
95  throw new Exception('Failed to open a string buffer.', 0);
96  }
97 
98  return $out;
99  }
Hoa\Stringbuffer\Stringbuffer::deleteBuffer ( )

Delete buffer.

Returns
bool

Implements Hoa\Stream\IStream\Bufferable.

Definition at line 143 of file Stringbuffer.php.

144  {
145  return $this->disableStreamBuffer();
146  }

Here is the call graph for this function:

Hoa\Stringbuffer\Stringbuffer::flush ( )

Flush the output to a stream.

Returns
bool

Implements Hoa\Stream\IStream\Bufferable.

Definition at line 133 of file Stringbuffer.php.

134  {
135  return fflush($this->getStream());
136  }

Here is the call graph for this function:

Hoa\Stringbuffer\Stringbuffer::getBufferLevel ( )

Get bufffer level.

Returns
int

Implements Hoa\Stream\IStream\Bufferable.

Definition at line 153 of file Stringbuffer.php.

154  {
155  return 1;
156  }
Hoa\Stringbuffer\Stringbuffer::getBufferSize ( )

Get buffer size.

Returns
int

Implements Hoa\Stream\IStream\Bufferable.

Definition at line 163 of file Stringbuffer.php.

164  {
165  return $this->getStreamBufferSize();
166  }

Here is the call graph for this function:

Hoa\Stringbuffer\Stringbuffer::initializeWith (   $string)

Initialize the string buffer.

Parameters
string$stringString.
Returns

Definition at line 225 of file Stringbuffer.php.

226  {
227  ftruncate($this->getStream(), 0);
228  fwrite($this->getStream(), $string, strlen($string));
229  $this->rewind();
230 
231  return $this;
232  }

Here is the call graph for this function:

Hoa\Stringbuffer\Stringbuffer::lock (   $operation)

Portable advisory locking.

Parameters
int$operationOperation, use the ::LOCK_* constants.
Returns
bool

Implements Hoa\Stream\IStream\Lockable.

Definition at line 175 of file Stringbuffer.php.

176  {
177  return flock($this->getStream(), $operation);
178  }

Here is the call graph for this function:

Hoa\Stringbuffer\Stringbuffer::newBuffer (   $callable = null,
  $size = null 
)

Start a new buffer. The callable acts like a light filter.

Parameters
mixed$callableCallable.
int$sizeSize.
Returns
int

Implements Hoa\Stream\IStream\Bufferable.

Definition at line 119 of file Stringbuffer.php.

120  {
121  $this->setStreamBuffer($size);
122 
123  //@TODO manage $callable as a filter?
124 
125  return 1;
126  }
setStreamBuffer($buffer)
Definition: Stream.php:465

Here is the call graph for this function:

Hoa\Stringbuffer\Stringbuffer::rewind ( )

Rewind the position of a stream pointer.

Returns
bool

Implements Hoa\Stream\IStream\Pointable.

Definition at line 185 of file Stringbuffer.php.

186  {
187  return rewind($this->getStream());
188  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Stringbuffer\Stringbuffer::seek (   $offset,
  $whence = Stream\IStream\Pointable::SEEK_SET 
)

Seek on a stream pointer.

Parameters
int$offsetOffset (negative value should be supported).
int$whenceWhen, use the ::SEEK_* constants.
Returns
int

Implements Hoa\Stream\IStream\Pointable.

Definition at line 198 of file Stringbuffer.php.

199  {
200  return fseek($this->getStream(), $offset, $whence);
201  }

Here is the call graph for this function:

Hoa\Stringbuffer\Stringbuffer::tell ( )

Get the current position of the stream pointer.

Returns
int

Implements Hoa\Stream\IStream\Pointable.

Definition at line 208 of file Stringbuffer.php.

209  {
210  $stream = $this->getStream();
211 
212  if (null === $stream) {
213  return 0;
214  }
215 
216  return ftell($stream);
217  }

Here is the call graph for this function:

Member Data Documentation

Hoa\Stringbuffer\Stringbuffer::$_i = 0
staticprivate

Definition at line 61 of file Stringbuffer.php.


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