|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace WebStream\IO; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* OutputStream |
|
7
|
|
|
* @author Ryuichi TANAKA. |
|
8
|
|
|
* @since 2016/02/24 |
|
9
|
|
|
* @version 0.7 |
|
10
|
|
|
*/ |
|
11
|
|
|
abstract class OutputStream |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var mixed 出力ストリーム |
|
15
|
|
|
*/ |
|
16
|
|
|
protected $stream; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* constructor |
|
20
|
|
|
* @param mixed $stream 出力ストリーム |
|
21
|
|
|
*/ |
|
22
|
15 |
|
public function __construct($stream) |
|
23
|
|
|
{ |
|
24
|
15 |
|
$this->stream = $stream; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* destructor |
|
29
|
|
|
*/ |
|
30
|
15 |
|
public function __destruct() |
|
31
|
|
|
{ |
|
32
|
15 |
|
$this->close(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* 出力ストリームに書き出す |
|
37
|
|
|
* @param mixed $buf 出力データ |
|
38
|
|
|
* @param int|null $off データ開始位置 |
|
39
|
|
|
* @param int|null $len 書き出すバイト数 |
|
40
|
|
|
* @throws WebStream\Exception\Extend\IOException |
|
41
|
|
|
*/ |
|
42
|
|
|
abstract public function write($buf, int $off = null, int $len = null); |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* バッファリングしているすべての出力バイトを書き出し、出力ストリームを閉じる |
|
46
|
|
|
* @throws WebStream\Exception\Extend\IOException |
|
47
|
|
|
*/ |
|
48
|
|
|
abstract public function close(); |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* バッファリングしているすべての出力バイトを出力ストリームを閉じずに強制的に書き出す |
|
52
|
|
|
* writeを実行した時点では書き出されておらず、flushした時点ですべて書き出す |
|
53
|
|
|
* @throws WebStream\Exception\Extend\IOException |
|
54
|
|
|
*/ |
|
55
|
|
|
abstract public function flush(); |
|
56
|
|
|
} |
|
57
|
|
|
|