src/Pure/PIDE/byte_message.ML
changeset 69467 e8893c893241
parent 69454 ef051edd4d10
child 69848 bf2cd27714fb
equal deleted inserted replaced
69466:796e01aba901 69467:e8893c893241
     6 
     6 
     7 signature BYTE_MESSAGE =
     7 signature BYTE_MESSAGE =
     8 sig
     8 sig
     9   val write: BinIO.outstream -> string list -> unit
     9   val write: BinIO.outstream -> string list -> unit
    10   val flush: BinIO.outstream -> unit
    10   val flush: BinIO.outstream -> unit
       
    11   val write_line: BinIO.outstream -> string -> unit
    11   val read: BinIO.instream -> int -> string
    12   val read: BinIO.instream -> int -> string
    12   val read_block: BinIO.instream -> int -> string option * int
    13   val read_block: BinIO.instream -> int -> string option * int
    13   val read_line: BinIO.instream -> string option
    14   val read_line: BinIO.instream -> string option
    14   val write_message: BinIO.outstream -> string list -> unit
    15   val write_message: BinIO.outstream -> string list -> unit
    15   val read_message: BinIO.instream -> string list option
    16   val read_message: BinIO.instream -> string list option
    23 (* output operations *)
    24 (* output operations *)
    24 
    25 
    25 fun write stream = List.app (fn s => BinIO.output (stream, Byte.stringToBytes s));
    26 fun write stream = List.app (fn s => BinIO.output (stream, Byte.stringToBytes s));
    26 
    27 
    27 fun flush stream = ignore (try BinIO.flushOut stream);
    28 fun flush stream = ignore (try BinIO.flushOut stream);
       
    29 
       
    30 fun write_line stream s = (write stream [s, "\n"]; flush stream);
    28 
    31 
    29 
    32 
    30 (* input operations *)
    33 (* input operations *)
    31 
    34 
    32 fun read stream n = Byte.bytesToString (BinIO.inputN (stream, n));
    35 fun read stream n = Byte.bytesToString (BinIO.inputN (stream, n));