! Copyright (C) 2003, 2009 Slava Pestov, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. USING: accessors io kernel math namespaces sequences sbufs strings generic splitting continuations destructors sequences.private io.streams.plain io.encodings math.order growable io.streams.sequence ; IN: io.streams.string M: growable dispose drop ; M: growable stream-write1 push ; M: growable stream-write push-all ; M: growable stream-flush drop ; : ( -- stream ) 512 ; : with-string-writer ( quot -- str ) swap [ output-stream get ] compose with-output-stream* >string ; inline ! New implementation TUPLE: string-reader { underlying string read-only } { i array-capacity } ; M: string-reader stream-read-partial stream-read ; M: string-reader stream-read sequence-read ; M: string-reader stream-read1 sequence-read1 ; M: string-reader stream-read-until sequence-read-until ; M: string-reader dispose drop ; : ( str -- stream ) 0 string-reader boa null-encoding ; : with-string-reader ( str quot -- ) [ ] dip with-input-stream ; inline INSTANCE: growable plain-writer