Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changes between Version 2 and Version 3 of ChapterIoStreams

Show
Ignore:
Author:
kris (IP: 17.228.23.90)
Timestamp:
05/09/09 01:42:19 (15 years ago)
Comment:

reflects recent IO updates

Legend:

Unmodified
Added
Removed
Modified
  • ChapterIoStreams

    v2 v3  
    33= Streams = 
    44 
    5 == !BufferedStream == 
     5== Buffered == 
    66 
    77Buffers the flow of data from a upstream input. A downstream 
    1515neighbour can locate and use this buffer instead of creating another instance of their own. 
    1616 
    17 == !DataFileStream == 
     17== !DataFile == 
    1818!DataFileInput, !DataFileOutput composes a seekable file with buffer. A seek causes 
    1919the buffer to be cleared or flushed. 
    2020 
    21 == !DataStream == 
     21== Data == 
    2222!DataInput[[br]] 
    2323A simple way to read binary data from an arbitrary !InputStream, such as a file: 
    2424{{{ 
    2525#!d 
    26 auto input = new DataInput (new FileInput("path")); 
    27 auto x = input.readInt
    28 auto y = input.readDouble
    29 input.read (new char[10]); 
     26auto input = new DataInput (new File("path")); 
     27auto x = input.int32
     28auto y = input.float64
     29input.array (new char[10]); 
    3030input.close; 
    3131}}} 
    3535{{{ 
    3636#!d 
    37 auto output = new DataOutput (new FileOutput("path")); 
    38 output.writeInt (1024); 
    39 output.writeDouble (3.14159); 
    40 output.write ("hello world"); 
     37auto output = new DataOutput (new File("path", File.WriteCreate)); 
     38output.int32 (1024); 
     39output.float64 (3.14159); 
     40output.array ("hello world"); 
    4141output.flush.close; 
    4242}}} 
    4343 
    44 == !DigestStream == 
     44== Digest == 
    4545!DigestInput[[br]] 
    4646Inject a digest filter into an input stream, updating the digest as information flows through it 
    5151{{{ 
    5252#!d 
    53 auto output = new DigestOutput(new FileOutput("output"), new Md5); 
     53auto output = new DigestOutput(new File("output", File.WriteCreate), new Md5); 
    5454output.copy (new FileInput("input")); 
    5555 
    5757}}} 
    5858 
    59 == !EndianessStream == 
     59== Endian == 
    6060 
    6161Streams for swapping endian-order. The stream is treated as a set 
    6464!EndianInput and !EndianOutput 
    6565 
    66 == !FileStream == 
     66== Format == 
    6767 
    68 Trivial wrapper around a !FileConduit 
    69  
    70 !FileInput and !FileOutput 
    71  
    72 == !FormatStream == 
    73  
    74 Simple way to hook up a utf8 formatter to an arbitrary !OutputStream, 
     68Simple way to hook up a text formatter to an arbitrary !OutputStream, 
    7569such as a file: 
    7670 
    7771{{{ 
    7872#!d 
    79 auto output = new FormatOutput (new FileOutput("path")); 
     73auto output = new FormatOutput!(char) (new File("path", File.WriteCreate)); 
    8074output.formatln ("{} green bottles", 10); 
    81 output.close; 
     75output.flush.close; 
    8276}}} 
    8377 
    84 This is a trivial wrapper around the Print class, and is limited 
    85 to emitting utf8 output. Use the Print class directly in order to 
    86 generate utf16/32 output instead. 
    87  
    88 Note that this class is a true instance of !OutputStream, by way of 
    89 inheritance via the Print superclass. 
    90  
    91 == !GreedyStream == 
     78== Greedy == 
    9279 
    9380!GreedyOutput[[br]] 
    9784A conduit filter that ensures its input is read in full 
    9885 
    99 == !LineStream == 
     86== Lines == 
    10087 
    10188!LineInput[[br]] 
    10491{{{ 
    10592#!d 
    106 auto input = new LineInput (new FileInput("path")); 
     93auto input = new LineInput (new File("path")); 
    10794foreach (line; input) 
    10895            ... 
    11097}}} 
    11198 
    112 Note that this is just a simple wrapper around !LineIterator, and 
    113 supports utf8 lines only. Use !LineIterator directly for utf16/32 
    114 support, or use the other tango.text.stream classes directly for 
    115 other tokenizing needs. 
    116  
    117 Note that this class is a true instance of !InputStream, by way of 
    118 inheritance via the Iterator superclass. 
    119  
    120 == !MapStream == 
     99== Map == 
    121100 
    122101!MapInput!(T) 
    130109 
    131110 
    132 == !SnoopStream == 
     111== Snoop == 
    133112 
    134113!SnoopInput, !SnoopOutput 
    135114Streams to expose call behaviour. By default, activity trace is sent to Cerr. 
    136115 
    137 This is usefull for logging/debugging the stream calls. 
     116This is useful for logging/debugging the stream calls. 
    138117 
    139 == !TextFileStream == 
     118== !TextFile == 
    140119 
    141120!TextFileInput and !TextFileOutput[[br]] 
    142121Composes a file with line-oriented input 
    143122 
    144 == !TypedStream == 
     123== Typed == 
    145124 
    146125!TypedInput!(T) and !TypedOutput!(T)[[br]]