package plist-xml

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type error = [
  1. | `Expected_tag of string
  2. | `Expected_start
  3. | `Expected_end
  4. | `Expected_start_or_end
  5. | `Expected_data
  6. | `Malformed_base64 of string
  7. | `Malformed_date of string
  8. | `Malformed_int of string
  9. | `Malformed_real of string
  10. | `Unknown_tag of string
]
exception Error of int * int * error

Error ((line, col), msg) indicates a syntax error at line number line and column number col. The line and column numbers start from 1.

val error_message : error -> string

Simple Interface

The simple interface provides functions for reading plist documents into a tree data structure.

type t = [
  1. | `Bool of bool
  2. | `Data of string
  3. | `Date of float * float option
    (*

    (timestamp, timezone)

    *)
  4. | `Float of float
  5. | `Int of int
  6. | `String of string
  7. | `Array of t list
    (*

    Array

    *)
  8. | `Dict of (string * t) list
    (*

    Dictionary

    *)
]

Plist values.

val parse : (unit -> int) -> t

parse source reads an XML representation of a plist value by repeatedly calling source, which supplies the next byte of input. The input should include the XML header.

  • raises Error

    For errors pertaining to the plist format.

val from_channel : in_channel -> t

from_channel in_channel reads a plist from in_channel. See parse.

val from_string : string -> t

from_string string reads a plist from string. See parse.

val print : (int -> unit) -> t -> unit

print sink t outputs an XML representation of plist value t by repeatedly calling sink with each byte of output. The output includes the XML header and DTD.

val to_buffer : Buffer.t -> t -> unit

to_buffer buffer t outputs t to buffer. See print.

val to_channel : out_channel -> t -> unit

to_channel out_channel t outputs t to out_channel. See print.

val to_string : t -> string

to_string t returns the string representation of t. See print.

Streaming Interface

The streaming interface provides lower-level signal parsing and printing functions, which do not build up a tree in memory.

type token = [
  1. | `Array_start
  2. | `Array_end
  3. | `Data of string
  4. | `Date of float * float option
  5. | `Dict_start
  6. | `Dict_end
  7. | `False
  8. | `Int of int
  9. | `Key of string
  10. | `Real of float
  11. | `String of string
  12. | `True
]

A token of the logical syntax of a plist value. The logical syntax is an abstraction around an underlying format, such as XML.

A token sequence is well-formed iff it parses to a plist nonterminal:

plist ::= `Array_start plist* `Array_end
        | `Dict_start kv* `Dict_end
        | `False
        | `Data
        | `Date
        | `Int
        | `Real
        | `String
        | `True

kv ::= `Key plist
type signal = [
  1. | token
  2. | `EOI
]

Furthermore, a signal is either a token or an `EOI marker. A well-formed signal sequence consists of a well-formed token sequence followed by `EOI and represents a plist document.

doc ::= plist `EOI
val decode : (unit -> int) -> (signal -> unit) -> unit

decode source sink reads bytes of input by repeatedly calling source and calls sink upon reading enough to determine the next signal. The emitted signal sequence is guaranteed to be a well-formed document.

  • raises Error

    For errors pertaining to the plist format.

val encode : (unit -> signal) -> (int -> unit) -> unit

encode source sink reads signals by repeatedly calling source and outputs their XML representation to sink byte-by-byte.

val tokens : (token -> unit) -> t -> unit

tokens sink t repeatedly calls sink with the tokens that correspond with t.

OCaml

Innovation. Community. Security.