1 ! Copyright (C) 2009 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax io math ;
8 { "stream" "an input stream" } { "limit" integer }
9 { "stream'" "an input stream" }
11 { $description "Constructs a new " { $link limited-stream } " from an existing stream. User code should use " { $link limit-stream } " or " { $link limited-input } "." } ;
15 { "stream" "an input stream" } { "limit" integer }
16 { "stream'" "a stream" }
18 { $description "Changes a decoder's stream to be a limited stream, or wraps " { $snippet "stream" } " in a " { $link limited-stream } "." }
20 "Limiting a longer stream to length three:"
22 "USING: accessors continuations io io.streams.limited"
23 "io.streams.string kernel prettyprint ;"
24 "\"123456\" <string-reader> 3 limit-stream"
25 "100 swap stream-read ."
32 { "value" "a limited-stream class" }
34 { $description "Limited streams wrap other streams, changing their behavior to throw an exception or return " { $link f } " upon exhaustion." } ;
37 { $values { "limit" integer } }
38 { $description "Wraps the current " { $link input-stream } " in a " { $link limited-stream } "." } ;
40 ARTICLE: "io.streams.limited" "Limited input streams"
41 "The " { $vocab-link "io.streams.limited" } " vocabulary wraps a stream to behave as if it had only a limited number of bytes. Limiting a seekable stream creates a window of bytes that supports seeking and re-reading of bytes in that window. If it is desirable for a stream to throw an exception upon exhaustion, use the " { $vocab-link "io.streams.throwing" } " vocabulary in conjunction with this one." $nl
42 "Wrap a stream in a limited stream:"
43 { $subsections limited-stream }
44 "Wrap the current " { $link input-stream } " in a limited stream:"
45 { $subsections limited-input } ;
47 ABOUT: "io.streams.limited"