Manipulate the lines of a file.
module Biocaml_lines:
sig
typeitem =
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.tval write_file :?perm:int ->
?append:bool ->
string -> Biocaml_lines.item Future.Pipe.Reader.t -> unit Future.Deferred.tend
include ??
val of_char_stream : char Biocaml_internal_utils.Stream.t ->
item Biocaml_internal_utils.Stream.t
val of_channel : Pervasives.in_channel -> item Biocaml_internal_utils.Stream.t
val to_channel : item Biocaml_internal_utils.Stream.t ->
Pervasives.out_channel -> unit
module Buffer:
sig
type
t
exception No_next_line
next_line_exn
.val make : ?filename:string -> unit -> t
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
val feed_string : t -> string -> unit
val queued_lines : t -> int
val is_empty : t -> bool
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
val next_line : t -> Biocaml_lines.item option
val next_line_exn : t -> Biocaml_lines.item
No_next_line
if there is no line
to return.val current_position : t -> Biocaml_internal_utils.Pos.t
val contents : t -> Biocaml_lines.item list * string option
end
module Transform:
sig
Lines.item
.val string_to_item : unit -> (string, Biocaml_lines.item) Biocaml_transform.t
val group2 : unit ->
(Biocaml_lines.item,
(Biocaml_lines.item * Biocaml_lines.item, [> `premature_end_of_input ])
Biocaml_internal_utils.Result.t)
Biocaml_transform.t
val item_to_string : ?buffer:[ `clear of int | `reset of int ] ->
unit -> (Biocaml_lines.item, string) Biocaml_transform.t
Line.item
s 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
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
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
next_line_exn
.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.next_line
returns
None
, is_empty p = true
means that the content did not end
with a complete line.No_next_line
if there is no line
to return.contents
will return
([], None)
.Lines.item
.Line.item
s to strings (in other
words a buffer with the lines plus their end-of-line
character).make
but merge `incomplete_input _
with the
errors of ~next
(which must be polymorphic variants).end