Hoa central
Public Member Functions | List of all members
Hoa\Stringbuffer\ReadWrite Class Reference
Inheritance diagram for Hoa\Stringbuffer\ReadWrite:

Public Member Functions

 eof ()
 
 read ($length)
 
 readString ($length)
 
 readCharacter ()
 
 readBoolean ()
 
 readInteger ($length=1)
 
 readFloat ($length=1)
 
 readArray ($format=null)
 
 readLine ()
 
 readAll ($offset=0)
 
 scanf ($format)
 
 write ($string, $length)
 
 writeString ($string)
 
 writeCharacter ($char)
 
 writeBoolean ($boolean)
 
 writeInteger ($integer)
 
 writeFloat ($float)
 
 writeArray (Array $array)
 
 writeLine ($line)
 
 writeAll ($string)
 
 truncate ($size)
 
 __toString ()
 
- Public Member Functions inherited from Hoa\Stringbuffer\Stringbuffer
 __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 ()
 

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 Member Functions inherited from Hoa\Stringbuffer\Stringbuffer
_open ($streamName, Stream\Context $context=null)
 
 _close ()
 
- Protected Member Functions inherited from Hoa\Stream\Stream
_open ($streamName, Context $context=null)
 
 _close ()
 
 getStream ()
 
- Protected Attributes inherited from Hoa\Stream\Stream
 $_bucket = []
 
 $_bufferSize = 8192
 
 $_streamName = null
 
 $_context = null
 
 $_hasBeenDiffered = false
 
 $_on = null
 
 $_borrowed = false
 

Detailed Description

Class .

Read/write a string buffer.

Definition at line 49 of file ReadWrite.php.

Member Function Documentation

Hoa\Stringbuffer\ReadWrite::__toString ( )

Transform this object to a string.

Returns
string

Definition at line 320 of file ReadWrite.php.

321  {
322  return $this->readAll();
323  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Stringbuffer\ReadWrite::eof ( )

Test for end-of-file.

Returns
bool

Implements Hoa\Stream\IStream\In.

Definition at line 59 of file ReadWrite.php.

60  {
61  return feof($this->getStream());
62  }

Here is the call graph for this function:

Hoa\Stringbuffer\ReadWrite::read (   $length)

Read n characters.

Parameters
int$lengthLength.
Returns
string
Exceptions

Implements Hoa\Stream\IStream\In.

Definition at line 71 of file ReadWrite.php.

72  {
73  if (0 > $length) {
74  throw new Exception(
75  'Length must be greater than 0, given %d.',
76  0,
77  $length
78  );
79  }
80 
81  return fread($this->getStream(), $length);
82  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Stringbuffer\ReadWrite::readAll (   $offset = 0)

Read all, i.e. read as much as possible.

Parameters
int$offsetOffset.
Returns
string

Implements Hoa\Stream\IStream\In.

Definition at line 165 of file ReadWrite.php.

166  {
167  return stream_get_contents($this->getStream(), -1, $offset);
168  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Stringbuffer\ReadWrite::readArray (   $format = null)

Read an array. Alias of the $this->scanf() method.

Parameters
string$formatFormat (see printf's formats).
Returns
array

Implements Hoa\Stream\IStream\In.

Definition at line 144 of file ReadWrite.php.

145  {
146  return $this->scanf($format);
147  }

Here is the call graph for this function:

Hoa\Stringbuffer\ReadWrite::readBoolean ( )

Read a boolean.

Returns
bool

Implements Hoa\Stream\IStream\In.

Definition at line 110 of file ReadWrite.php.

111  {
112  return (bool) $this->read(1);
113  }

Here is the call graph for this function:

Hoa\Stringbuffer\ReadWrite::readCharacter ( )

Read a character.

Returns
string

Implements Hoa\Stream\IStream\In.

Definition at line 100 of file ReadWrite.php.

101  {
102  return fgetc($this->getStream());
103  }

Here is the call graph for this function:

Hoa\Stringbuffer\ReadWrite::readFloat (   $length = 1)

Read a float.

Parameters
int$lengthLength.
Returns
float

Implements Hoa\Stream\IStream\In.

Definition at line 132 of file ReadWrite.php.

133  {
134  return (float) $this->read($length);
135  }

Here is the call graph for this function:

Hoa\Stringbuffer\ReadWrite::readInteger (   $length = 1)

Read an integer.

Parameters
int$lengthLength.
Returns
int

Implements Hoa\Stream\IStream\In.

Definition at line 121 of file ReadWrite.php.

122  {
123  return (int) $this->read($length);
124  }

Here is the call graph for this function:

Hoa\Stringbuffer\ReadWrite::readLine ( )

Read a line.

Returns
string

Implements Hoa\Stream\IStream\In.

Definition at line 154 of file ReadWrite.php.

155  {
156  return fgets($this->getStream());
157  }

Here is the call graph for this function:

Hoa\Stringbuffer\ReadWrite::readString (   $length)

Alias of $this->read().

Parameters
int$lengthLength.
Returns
string

Implements Hoa\Stream\IStream\In.

Definition at line 90 of file ReadWrite.php.

91  {
92  return $this->read($length);
93  }

Here is the call graph for this function:

Hoa\Stringbuffer\ReadWrite::scanf (   $format)

Parse input from a stream according to a format.

Parameters
string$formatFormat (see printf's formats).
Returns
array

Implements Hoa\Stream\IStream\In.

Definition at line 176 of file ReadWrite.php.

177  {
178  return fscanf($this->getStream(), $format);
179  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Stringbuffer\ReadWrite::truncate (   $size)

Truncate a file to a given length.

Parameters
int$sizeSize.
Returns
bool

Implements Hoa\Stream\IStream\Out.

Definition at line 310 of file ReadWrite.php.

311  {
312  return ftruncate($this->getStream(), $size);
313  }

Here is the call graph for this function:

Hoa\Stringbuffer\ReadWrite::write (   $string,
  $length 
)

Write n characters.

Parameters
string$stringString.
int$lengthLength.
Returns
mixed
Exceptions

Implements Hoa\Stream\IStream\Out.

Definition at line 189 of file ReadWrite.php.

190  {
191  if (0 > $length) {
192  throw new Exception(
193  'Length must be greater than 0, given %d.',
194  1,
195  $length
196  );
197  }
198 
199  return fwrite($this->getStream(), $string, $length);
200  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Stringbuffer\ReadWrite::writeAll (   $string)

Write all, i.e. as much as possible.

Parameters
string$stringString.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 299 of file ReadWrite.php.

300  {
301  return $this->write($string, strlen($string));
302  }
write($string, $length)
Definition: ReadWrite.php:189

Here is the call graph for this function:

Hoa\Stringbuffer\ReadWrite::writeArray ( Array  $array)

Write an array.

Parameters
array$arrayArray.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 269 of file ReadWrite.php.

270  {
271  $array = var_export($array, true);
272 
273  return $this->write($array, strlen($array));
274  }
write($string, $length)
Definition: ReadWrite.php:189

Here is the call graph for this function:

Hoa\Stringbuffer\ReadWrite::writeBoolean (   $boolean)

Write a boolean.

Parameters
bool$booleanBoolean.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 232 of file ReadWrite.php.

233  {
234  return $this->write((string) (bool) $boolean, 1);
235  }
write($string, $length)
Definition: ReadWrite.php:189

Here is the call graph for this function:

Hoa\Stringbuffer\ReadWrite::writeCharacter (   $char)

Write a character.

Parameters
string$charCharacter.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 221 of file ReadWrite.php.

222  {
223  return $this->write((string) $char[0], 1);
224  }
write($string, $length)
Definition: ReadWrite.php:189

Here is the call graph for this function:

Hoa\Stringbuffer\ReadWrite::writeFloat (   $float)

Write a float.

Parameters
float$floatFloat.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 256 of file ReadWrite.php.

257  {
258  $float = (string) (float) $float;
259 
260  return $this->write($float, strlen($float));
261  }
write($string, $length)
Definition: ReadWrite.php:189

Here is the call graph for this function:

Hoa\Stringbuffer\ReadWrite::writeInteger (   $integer)

Write an integer.

Parameters
int$integerInteger.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 243 of file ReadWrite.php.

244  {
245  $integer = (string) (int) $integer;
246 
247  return $this->write($integer, strlen($integer));
248  }
write($string, $length)
Definition: ReadWrite.php:189

Here is the call graph for this function:

Hoa\Stringbuffer\ReadWrite::writeLine (   $line)

Write a line.

Parameters
string$lineLine.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 282 of file ReadWrite.php.

283  {
284  if (false === $n = strpos($line, "\n")) {
285  return $this->write($line . "\n", strlen($line) + 1);
286  }
287 
288  ++$n;
289 
290  return $this->write(substr($line, 0, $n), $n);
291  }
write($string, $length)
Definition: ReadWrite.php:189

Here is the call graph for this function:

Hoa\Stringbuffer\ReadWrite::writeString (   $string)

Write a string.

Parameters
string$stringString.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 208 of file ReadWrite.php.

209  {
210  $string = (string) $string;
211 
212  return $this->write($string, strlen($string));
213  }
write($string, $length)
Definition: ReadWrite.php:189

Here is the call graph for this function:


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