Changeset 4001
- Timestamp:
- 10/10/08 22:06:13 (1 month ago)
- Files:
-
- trunk/tango/io/stream/DataStream.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/tango/io/stream/DataStream.d
r3856 r4001 96 96 /*********************************************************************** 97 97 98 Read an array back from the source, with the assumption 99 it has been written using DataOutput.put() or otherwise 100 prefixed with an integer representing the total number 101 of bytes within the array content. That's *bytes*, not 102 elements. 103 104 An array of the appropriate size is allocated either via 105 the provided delegate, or from the heap, populated and 106 returned to the caller. Casting the return value to an 107 appropriate type will adjust the number of elements as 108 required: 109 --- 110 auto text = cast(char[]) input.get; 111 --- 112 113 114 ***********************************************************************/ 115 116 final void[] get (void[] delegate(uint bytes) dg = null) 117 { 118 auto len = getInt; 119 auto dst = (dg ? dg(len) : new void[len]); 120 input.readExact (dst.ptr, len); 121 return dst; 122 } 123 124 /*********************************************************************** 125 98 126 ***********************************************************************/ 99 127 … … 356 384 357 385 auto input = new DataInput (buf); 358 assert (input.get (new char[9])is 9);386 assert (input.get.length is 9); 359 387 assert (input.getInt is 1024); 360 input.getInt;361 388 } 362 389 }












