OCamlResRegistryRegistration 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:
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)
module type Format = sig ... endThe 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.
val register_format : string -> (module Format) -> unitRegister a new named format module or override one.
val find_format : string -> (module Format)Find a format module from its name. May throw Not_found.
val formats : unit -> (module Format) Map.Make(String).tRetrive the currently available formats
module type SubFormat = sig ... endThe type of subformat plug-ins
val register_subformat : string -> (module SubFormat) -> unitRegister a new named subformat module or override one.
val find_subformat : string -> (module SubFormat)Find a subformat module from its name. May throw Not_found.
val subformats : unit -> (module SubFormat) Map.Make(String).tRetrive the currently available subformats
module PredefOptions : sig ... endPredefined options that you can use in your own formats
module ExtensionDispatcherSubFormat :
OCamlResSubFormats.SubFormat with type t = stringOutput 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.