Module Biocaml_lines (.ml)

Manipulate the lines of a file.

module Biocaml_lines: 
sig
type item = Biocaml_internal_utils.Line.t 

module MakeIO: 
functor (Future : Future.S) ->
sig
val read : Future.Reader.t -> Biocaml_lines.item Future.Pipe.Reader.t
val write : Future.Writer.t ->
Biocaml_lines.item Future.Pipe.Reader.t -> unit Future.Deferred.t
val write_file : ?perm:int ->
?append:bool ->
string -> Biocaml_lines.item Future.Pipe.Reader.t -> unit Future.Deferred.t
end
include ??
val of_char_stream : char Biocaml_internal_utils.Stream.t ->
item Biocaml_internal_utils.Stream.t
Parse a stream of characters into a stream of lines.
val of_channel : Pervasives.in_channel -> item Biocaml_internal_utils.Stream.t
Get a stream of lines out of an input-channel.
val of_string : string -> item Biocaml_internal_utils.Stream.t
Get a stream of lines out a string
val to_channel : item Biocaml_internal_utils.Stream.t ->
Pervasives.out_channel -> unit
Write a stream of lines to an output-channel.

module Buffer: 
sig

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_line : t -> Biocaml_lines.item -> unit
Feed the parser with a line.
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 peek_line : t -> Biocaml_lines.item option
Peek at the next line, without removing it from the buffer.
val next_line : t -> Biocaml_lines.item option
Get the next line.
val next_line_exn : t -> Biocaml_lines.item
Get the next line, but throw No_next_line if there is no line to return.
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).
end

module Transform: 
sig

Transforms from/to Lines.item.
val string_to_item : unit -> (string, Biocaml_lines.item) Biocaml_transform.t
Return a transform that converts a stream of arbitrary strings to a stream of lines. If the input terminates without a newline, the trailing string is still considered a line.
val group2 : unit ->
(Biocaml_lines.item,
(Biocaml_lines.item * Biocaml_lines.item, [> `premature_end_of_input ])
Biocaml_internal_utils.Result.t)
Biocaml_transform.t
Return a transform that converts a stream of lines to a stream of pairs of lines. It is considered an error if input ends with an odd number of lines.
val item_to_string : ?buffer:[ `clear of int | `reset of int ] ->
unit -> (Biocaml_lines.item, string) Biocaml_transform.t
Return a transform that output Line.items to strings (in other words a buffer with the lines plus their end-of-line character).
val make : ?name:string ->
?filename:string ->
next:(Biocaml_lines.Buffer.t ->
[ `not_ready
| `output of ('b, 'errnext) Biocaml_internal_utils.Result.t ]) ->
on_error:([ `incomplete_input of
Biocaml_internal_utils.Pos.t * string list * string option
| `next of 'errnext ] -> 'err) ->
unit ->
(string, ('b, 'err) Biocaml_internal_utils.Result.t) Biocaml_transform.t
Build a stoppable line-oriented parsing_buffer.
val make_merge_error : ?name:string ->
?filename:string ->
next:(Biocaml_lines.Buffer.t ->
[ `not_ready
| `output of
('a,
[> `incomplete_input of
Biocaml_internal_utils.Pos.t * string list * string option ]
as 'b)
Biocaml_internal_utils.Result.t ]) ->
unit ->
(string, ('a, 'b) Biocaml_internal_utils.Result.t) Biocaml_transform.t
Do like make but merge `incomplete_input _ with the errors of ~next (which must be polymorphic variants).
end
val item_of_sexp : Sexplib.Sexp.t -> item
val sexp_of_item : item -> Sexplib.Sexp.t
val item_of_sexp : Sexplib.Sexp.t -> item
val sexp_of_item : item -> Sexplib.Sexp.t

Parse a stream of characters into a stream of lines.

Get a stream of lines out of an input-channel.

Get a stream of lines out a string

Write a stream of lines to an output-channel.

Buffer used to parse strings into lines.

The buffer handle.

The exception thrown by next_line_exn.

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.

Feed the parser with a line.

Feed the parser with an arbitrary string buffer.

Get the number of lines ready-to-use in the buffer/queue.

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.

Peek at the next line, without removing it from the buffer.

Get the next line.

Get the next line, but throw No_next_line if there is no line to return.

Get the current position in the stream.

Return any remaining lines and the unfinished string, without removing them from the buffer.

Empty the buffer. Subsequent call to contents will return ([], None).

Transforms from/to Lines.item.

Return a transform that converts a stream of arbitrary strings to a stream of lines. If the input terminates without a newline, the trailing string is still considered a line.

Return a transform that converts a stream of lines to a stream of pairs of lines. It is considered an error if input ends with an odd number of lines.

Return a transform that output Line.items to strings (in other words a buffer with the lines plus their end-of-line character).

Build a stoppable line-oriented parsing_buffer.

Do like make but merge `incomplete_input _ with the errors of ~next (which must be polymorphic variants).
end