Module Reader


module Reader: sig .. end
Readers are responsible for breaking input data into records. A reader need not be concerned with the meaning of data in a record. Its goal is merely to determine record boundaring. Given an in_channel from which to read, a reader must produce a string containing one record from the channel, and should also keep track of any non-data (formatting or record separators) that it encounters, making its operation somewhat invertible.


type raw_line = {
   content : string; (*Readers are responsible for breaking input data into records. A reader need not be concerned with the meaning of data in a record. Its goal is merely to determine record boundaring. Given an in_channel from which to read, a reader must produce a string containing one record from the channel, and should also keep track of any non-data (formatting or record separators) that it encounters, making its operation somewhat invertible.*)
   before : string; (*Readers are responsible for breaking input data into records. A reader need not be concerned with the meaning of data in a record. Its goal is merely to determine record boundaring. Given an in_channel from which to read, a reader must produce a string containing one record from the channel, and should also keep track of any non-data (formatting or record separators) that it encounters, making its operation somewhat invertible.*)
   after : string; (*Readers are responsible for breaking input data into records. A reader need not be concerned with the meaning of data in a record. Its goal is merely to determine record boundaring. Given an in_channel from which to read, a reader must produce a string containing one record from the channel, and should also keep track of any non-data (formatting or record separators) that it encounters, making its operation somewhat invertible.*)
}
An untyped record 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.

Readers are responsible for breaking input data into records. A reader need not be concerned with the meaning of data in a record. Its goal is merely to determine record boundaring. Given an in_channel from which to read, a reader must produce a string containing one record from the channel, and should also keep track of any non-data (formatting or record separators) that it encounters, making its operation somewhat invertible.

val raw_of_string : ?before:string -> ?after:string -> string -> raw_line
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 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 records satisfying a string predicate. Given a predicate and a reader, returns a new reader that skips records whose content satisfies the predicate.
val join_on : char -> t -> t
Read records with a line continuation character. If a record ends with the given character, the character will be removed and the next record 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.