lib/streams: Rope now capable of using write_to
authorLucas Bajolet <r4pass@hotmail.com>
Thu, 5 Jun 2014 14:52:36 +0000 (10:52 -0400)
committerLucas Bajolet <r4pass@hotmail.com>
Mon, 9 Jun 2014 15:58:50 +0000 (11:58 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

lib/standard/stream.nit

index 507ba8d..504396a 100644 (file)
@@ -13,7 +13,7 @@
 # Input and output streams of characters
 module stream
 
-import string
+intrude import ropes
 
 in "C" `{
        #include <unistd.h>
@@ -136,6 +136,29 @@ redef class Text
        redef fun write_to(stream) do stream.write(self)
 end
 
+redef class RopeNode
+       super Streamable
+end
+
+redef class Leaf
+
+       redef fun write_to(s) do s.write(str)
+end
+
+redef class Concat
+
+       redef fun write_to(s)
+       do
+               if left != null then left.write_to(s)
+               if right != null then right.write_to(s)
+       end
+end
+
+redef class RopeString
+
+       redef fun write_to(s) do root.write_to(s)
+end
+
 # Input streams with a buffer
 abstract class BufferedIStream
        super IStream