Buffer used to parse strings into lines.
type
t
The buffer handle.
exception No_next_line
The exception thrown by next_line_exn
.
val make : ?filename:string -> unit -> t
Make a new empty buffer. The optional filename
is used only
for error reporting; it should be set to the name of the file,
if any, from which you will feed the buffer.
val feed_string : t -> string -> unit
Feed the parser with an arbitrary string buffer.
val queued_lines : t -> int
Get the number of lines ready-to-use in the buffer/queue.
val is_empty : t -> bool
Tell if the parser's buffers are empty or not. For instance,
when there is no more content to feed and next_line
returns
None
, is_empty p = true
means that the content did not end
with a complete line.
val current_position : t -> Biocaml_internal_utils.Pos.t
Get the current position in the stream.
val contents : t -> Biocaml_lines.item list * string option
Return any remaining lines and the unfinished string, without
removing them from the buffer.
val empty : t -> unit
Empty the buffer. Subsequent call to contents
will return
([], None)
.