package ocp-ocamlres

  1. Overview
  2. Docs
Manipulation, injection and extraction of embedded resources

Install

Dune Dependency

Authors

Maintainers

Sources

v0.4.tar.gz
sha256=658c2990e027e1e43a16290fd431f08c96b8630d91ac2b98003a9bc027179679
md5=725eb557e659c6febf8dc3044b323bd8

doc/ocplib-ocamlres/OCamlResRegistry/index.html

Module OCamlResRegistrySource

Registration of (sub)formats for use from the command line

This file implements the interface between OCaml defintions of Format and SubFormat module instances and the command line interface of ocp-ocamlres.

Basically, it consists in pre-instanciating the formats:

  • with string valued resource trees as input where the strings are the raw contents as extracted from the files
  • with a proxy subformat, performing a dynamic dispatch of the subformat depending on file extensions

To associate the extensions with the subformats, it maintains an assiciative table to link the command line name of the subformat to the OCaml implementation (as a packed module).

Same is done with the main format names, and both tables can be extended to the tool can be extended from outside this module (by recompiling it with / dynlinking a module performing a (sub)format registration at toplevel)

Formats registry

Sourcemodule type Format = sig ... end

The type of format plug-ins. Differs from OCamlResFormats.Format since it is dedicated to be used by the command line tool. For this, the parameters are provided not as a data type but as a list of command line args that can mutate global references, which can then be read from the output function. This is because parameters come from the user, not the programmer. Also, the tool is dedicated to use with the filesystem, so the type of data is fixed to strings representing the raw encoding of data.

Sourceval register_format : string -> (module Format) -> unit

Register a new named format module or override one.

Sourceval find_format : string -> (module Format)

Find a format module from its name. May throw Not_found.

Sourceval formats : unit -> (module Format) Map.Make(String).t

Retrive the currently available formats

SubFormats registry

Sourcemodule type SubFormat = sig ... end

The type of subformat plug-ins

Sourceval register_subformat : string -> (module SubFormat) -> unit

Register a new named subformat module or override one.

Sourceval find_subformat : string -> (module SubFormat)

Find a subformat module from its name. May throw Not_found.

Sourceval subformats : unit -> (module SubFormat) Map.Make(String).t

Retrive the currently available subformats

Predefined Subformats

Sourcemodule Raw : SubFormat with type t = string

Registered under the name "raw".

Sourcemodule Int : SubFormat with type t = int

Registered under the name "int".

Sourcemodule Lines : SubFormat with type t = string list

Registered under the name "lines".

Predefined Formats

Sourcemodule PredefOptions : sig ... end

Predefined options that you can use in your own formats

Output subformat dispatching the output depending on file extensions and the command line options. To be polymorphic, the t type is a string containing the raw resource representation, and the from_raw method of the selected subformat is used at every operation. The SubFormat used is resolved using table PredefOptions.subformats.

Sourceval disclaimer : string

Disclaimer that you can use in your own formats

Registered under the name "ocaml".

Sourcemodule Res : Format

Registered under the name "ocamlres".

Registered under the name "variants".

Registered under the name "files".

OCaml

Innovation. Community. Security.