132
|
1 /*******************************************************************************
|
|
2
|
|
3 copyright: Copyright (c) 2007 Kris Bell. All rights reserved
|
|
4
|
|
5 license: BSD style: $(LICENSE)
|
|
6
|
|
7 version: Initial release: Oct 2007
|
|
8
|
|
9 author: Kris
|
|
10
|
|
11 *******************************************************************************/
|
|
12
|
|
13 module tango.io.stream.BufferStream;
|
|
14
|
|
15 private import tango.io.Buffer;
|
|
16
|
|
17 /*******************************************************************************
|
|
18
|
|
19 Buffers the flow of data from a upstream input. A downstream
|
|
20 neighbour can locate and use this buffer instead of creating
|
|
21 another instance of their own.
|
|
22
|
|
23 (note that upstream is closer to the source, and downstream is
|
|
24 further away)
|
|
25
|
|
26 *******************************************************************************/
|
|
27
|
|
28 class BufferInput : Buffer
|
|
29 {
|
|
30 /***********************************************************************
|
|
31
|
|
32 Propagate ctor to superclass
|
|
33
|
|
34 ***********************************************************************/
|
|
35
|
|
36 this (InputStream stream, uint size = 16 * 1024)
|
|
37 {
|
|
38 super (size);
|
|
39 super.input = stream;
|
|
40 }
|
|
41 }
|
|
42
|
|
43
|
|
44 /*******************************************************************************
|
|
45
|
|
46 Buffers the flow of data from a upstream output. A downstream
|
|
47 neighbour can locate and use this buffer instead of creating
|
|
48 another instance of their own.
|
|
49
|
|
50 (note that upstream is closer to the source, and downstream is
|
|
51 further away)
|
|
52
|
|
53 Don't forget to flush() buffered content before closing.
|
|
54
|
|
55 *******************************************************************************/
|
|
56
|
|
57 class BufferOutput : Buffer
|
|
58 {
|
|
59 /***********************************************************************
|
|
60
|
|
61 Propagate ctor to superclass
|
|
62
|
|
63 ***********************************************************************/
|
|
64
|
|
65 this (OutputStream stream, uint size = 16 * 1024)
|
|
66 {
|
|
67 super (size);
|
|
68 super.output = stream;
|
|
69 }
|
|
70 }
|
|
71
|
|
72
|