package core_extended

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Kitchen-sink module for functions shared by multiple parsers.

type ('a, 'b) reader = ?strip:bool -> ?skip_lines:int -> ?on_parse_error: [ `Raise | `Handle of string Core.Queue.t -> exn -> [ `Continue | `Finish ] ] -> header:'a -> 'b

If strip is true (default is false) then spaces will be stripped from the beginning and end of fields.

If skip_lines is given then that number of lines will be read and discarded from the top of the file or Reader.t given.

If on_parse_error is `Raise any lines that fail to parse will raise an exception. If `Handle is given the offending line will be passed to the function given, which may then indicate that processing should continue or finish.

val buffer_size : int

Recommendation based on the largest reads and writes observed off a disk or socket.

val strip_buffer : Core.Buffer.t -> string
val make_emit_field : strip:bool -> string Core.Queue.t -> Core.Buffer.t -> (unit -> unit) Core.Staged.t

make_emit_field ~strip row buffer returns a closure which enqueues buffer into row, stripping leading and trailing whitespace if strip = true.

val make_emit_row : string Core.Queue.t -> Delimited_kernel__.Row.t Core.Queue.t -> [ `No | `Yes | `Require of string list | `Replace of string list | `Add of string list | `Transform of string list -> string list | `Filter_map of string list -> string option list ] -> lineno:int Core.ref -> [ `on_eof of unit -> unit ] * (unit -> unit)

make_emit_row row rows header ~lineno returns (`on_eof on_eof, emit_row). After zero or more calls to emit_row and a call to on_eof, rows will contain the parsed file.

Note that rows may have fewer elements than the number of calls to emit_row, if header specifies that the first row is a header line.

OCaml

Innovation. Community. Security.