]> gitweb.factorcode.org Git - factor.git/blob - core/io/string-streams.facts
e1664aaea642a1ba93286ec1f0a79700facb7b20
[factor.git] / core / io / string-streams.facts
1 USING: help io strings ;
2
3 HELP: <string-writer>
4 { $values { "stream" "an output stream" } }
5 { $description "Creates an output stream that collects text into a delegate string buffer. The contents of the buffer can be recovered by executing " { $link >string } ", and indeed all other sequence operations are permitted by virtue of the delegation." } ;
6
7 HELP: string-out
8 { $values { "quot" "a quotation" } { "str" "a string" } }
9 { $description "Calls the quotation in a new dynamic scope with " { $link stdio } " rebound to a new string writer. The accumulated string is output when the quotation returns." } ;
10
11 HELP: <string-reader>
12 { $values { "str" "a string" } { "stream" "an input stream" } }
13 { $description "Creates a new stream for reading " { $snippet "str" } " from beginning to end." }
14 { $notes "The implementation exploits the ability of string buffers to respond to the input stream protocol by reading characters from the end of the buffer." } ;
15
16 HELP: string-in
17 { $values { "str" "a string" } { "quot" "a quotation" } }
18 { $description "Calls the quotation in a new dynamic scope with " { $link stdio } " rebound to an input stream reading " { $snippet "str" } " from beginning to end. The accumulated string is output when the quotation returns." } ;
19
20 HELP: contents
21 { $values { "stream" "an input stream" } { "str" "a string" } }
22 { $description "Reads the contents of a stream into a string." }
23 $io-error ;