package ldp

  1. Overview
  2. Docs

Module Ldp.CtSource

Simple content-type parsing/printing. Tries to implement RFC 2045.

Base types

Sourcetype token = string

Non-empty string containing only ascii CHAR except SPACE, CTLs, or tspecials as defined here.

Sourcetype ty =
  1. | Application
  2. | Audio
  3. | Ietf of token
  4. | Image
  5. | Message
  6. | Multipart
  7. | Text
  8. | Video
  9. | X of token
Sourcetype subty = token
Sourcetype value =
  1. | T of token
  2. | Quoted of string
Sourcetype parameter = token * value
Sourcetype error = string * Lexing.position
Sourceval string_of_error : error -> string

Content-types

Sourcetype t = {
  1. ty : ty;
  2. subty : subty;
  3. parameters : parameter list;
}
Sourceval create : ?parameters:parameter list -> ty -> subty -> t

create ?paramers ty subty creates a new content-type.

Sourceval default : t

Default content-type is text/plain with charset parameter set to "us-ascii".

Sourceval of_string : string -> (t, error) result
Sourceval to_string : t -> string
Sourceval value : token -> t -> string option

value p t returns value associated to parameter p in t, if any.

Sourceval value_def : token -> string -> t -> string

value p def t returns value associated to p in t, or def if there is no parameter p in t.

Sourceval charset : t -> string option

Same as value but for parameter "charset".

Sourceval charset_def : string -> t -> string

Same as value_def but for paramter "charset".

Mime-types

Sourcetype mime = ty * subty
Sourceval to_mime : t -> mime
Sourceval of_mime : mime -> t
Sourceval mime_to_string : mime -> string
Sourceval mime_of_string : string -> (mime, error) result
Sourceval has_mime : t -> mime -> bool

has_mime ct mime returns true is type and subtype of mime are the same as in ct, else false.

Predefined content-types

Sourceval ct_turtle : t

text/turtle

Sourceval ct_xmlrdf : t

application/rdf+xml

Sourceval ct_sparql_update : t

application/sparql-update

Sourceval ct_text : t

text/plain

Sourceval ct_xhtml : t

application/xhtml+xml

Predefined mime-types

Sourceval mime_turtle : mime

text/turtle

Sourceval mime_xmlrdf : mime

application/rdf+xml

Sourceval mime_sparql_update : mime

application/sparql-update

Sourceval mime_text : mime

text/plain

Sourceval mime_xhtml : mime

application/xhtml+xml