Module Line.Key_value

module Key_value: sig .. end
Line structure to represent associations of keys with values.

val key : Line.t -> string
The key of a key-value pair. (accessor, required)
val set_key : string -> Line.t -> Line.t
Updater for Line.Key_value.key
val value : Line.t -> string
The value of a key-value pair. (accessor, required)
val set_value : string -> Line.t -> Line.t
Updater for Line.Key_value.value
val as_int : Line.t -> int option
The value of the key-value pair, as an integer.
val as_float : Line.t -> float option
The value of the key-value pair, as an float.
val as_bool : Line.t -> bool option
The value of the key-value pair, as a boolean.

The strings yes, y, 1, true, on, enabled, and enable are all considered true. The strings no, n, 0, false, off, disabled, and disable are all considered false. (Case insensitive.)

val as_string : ?quoted:bool -> Line.t -> string
The value of the string with interpreted escapes.

Backslash escapes are interpreted in the style of echo(1). The optional argument ?quoted (default true) specifies whether to remove double-quotes from the string as well (unless they are escaped).

val as_list : ?delim:char -> Line.t -> string list
The value, split into a list.

The optional argument ?delim (default ' ') specifies the list separator.

val section : Line.t -> string
The section in a key-value file.

For example, in SSH configuration files, Host statements begin a new section. (accessor, nullable)

val set_section : string -> Line.t -> Line.t
Updater for Line.Key_value.section
val create : key:string -> value:string -> Line.t -> Line.t
Add the Line.Key_value substructure to a line.