Module Reader

module Reader: sig .. end
Readers are responsible for breaking input data into pieces, or "raw lines". A Reader.t need not be concerned with the meaning of data in a line. Its goal is merely to determine boundaires. Given an in_channel from which to read, a reader reads some data, and produces a Reader.raw_line record. It should keep track of any non-data (formatting or record separators) that it encounters, using the before and after fields, making its operation somewhat invertible.

type raw_line = {
   content : string; (*
The data of the line
*)
   before : string; (*
Delimiting text from before the data
*)
   after : string; (*
Delimiting text from after the data
*)
}
An raw line as returned by a reader
type t = Pervasives.in_channel -> raw_line 
The type of a reader. A reader extracts Reader.raw_lines from an input channel.
val raw_of_string : ?before:string -> ?after:string -> string -> raw_line
Construct an raw line from its contents. The optional parameter ?before defaults to "" and ?after defaults to "\n".
val make : [ `Buf of eof:bool -> Buffer.t -> raw_line option
| `Char of char
| `Fixed of int * int
| `Set of string ] -> t
Construct a reader with a predefined behavior. Readers constructed by Reader.make are stateless between calls.
val lines : t
Read newline-terminated raw lines. If the last line is not newline-terminated, a newline is stored in the trailing delimiter nonetheless.

Reader Transformers

Reader transformers add behavior to a reader.

val ignore_if : (string -> bool) -> t -> t
Ignore raw lines satisfying a string predicate. Given a predicate and a reader, returns a new reader that skips lines whose content satisfies the predicate.
val join_on : char -> t -> t
Read raw lines with a line continuation character. If a line ends with the given character, the character will be removed and the next line will be concatenated.
val empty : string -> bool
Predicate for empty strings.
val blank : string -> bool
Predicate for empty or white space strings.
val starts_with : string -> string -> bool
Predicate for strings starting with a given string. starts_with patt s returns whether s starts with the string patt. Allows additional leading white space in the subject string.
val ends_with : string -> string -> bool
Predicate for strings ending with a given string. ends_with patt s returns whether s ends with the string patt. Allows additional trailing white space in the subject string.
val contains : ?regexp:bool -> string -> string -> bool
Predicate for strings containing a given pattern. contains patt s returns whether the string s contains the string patt. Calling contains ~regexp:true patt s returns whether the string s matches the Perl-compatible regular expression patt.