Make buffered_line_reader handle CRLF; also let it read specified size buffers
[hiphop-php.git] / hphp / hack / src / utils / buffered_line_reader.mli
blobee18e7eb36505b83eea9e9823ba6007d1f31363e
1 (**
2 * Copyright (c) 2015, Facebook, Inc.
3 * All rights reserved.
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the "hack" directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
9 *)
11 (**
12 * This module is needed because Unix.select doesn't play well with
13 * input_line on Ocaml channels.. i.e., when a buffered read into an
14 * Ocaml channel consumes two complete lines from the file descriptor, the next
15 * select will say there is nothing to read when in fact there is
16 * something in the channel. This wouldn't be a problem if Ocaml channel's API
17 * supported a "has buffered content" call, so you could check if the
18 * buffer contains something as well as doing a Unix select to know for real if
19 * there is content coming.
21 * The "has_buffered_content" method below does exactly that.
24 type t
26 val create: Unix.file_descr -> t
28 val get_null_reader: unit -> t
30 val has_buffered_content: t -> bool
32 val get_fd: t -> Unix.file_descr
34 val get_next_line: ?approx_size: int -> t -> string
36 val get_next_bytes: t -> int -> string