Module Kaitai_of_data_encoding.Helpers

type tid_gen = unit -> string

A tid_gen is a generator for tuple ids.

val mk_tid_gen : string -> tid_gen

mk_tid_gen prefix is a tid_gen where generated ids have the given prefix.

val default_doc_spec : Kaitai.Types.DocSpec.t

default_doc_spec is without summary and references.

cond_no_cond is default conditional specification that has no if expression and no repetition.

val default_attr_spec : id:string -> Kaitai.Types.AttrSpec.t

default_attr_spec ~id is initialized with default (empty) values except id set to ~id.

val default_meta_spec : ?imports:string list -> unit -> Kaitai.Types.MetaSpec.t

default_meta_spec ~id returns default MetaSpec.t.

The following meta section properties are set:

  • endian is set to BE (as per data-encoding default).
  • imports is set to imports if not empty.
  • Other fields are [] or None.
val default_class_spec : ?description:string -> ?imports:string list -> unit -> Kaitai.Types.ClassSpec.t

default_class_spec ?id builds an default (empty) ClassSpec.t.

  • parameter [?description]

    is added into doc section as summary.

  • parameter [?imports]

    is added to class specification if not empty.

val add_uniq_assoc : (string * 'a) list -> (string * 'a) -> (string * 'a) list

add_uniq_assoc kvs kv returns an association list with associations from kvs as well as kv.

If kvs already contains kv, then kvs is returned.

  • raises Invalid_argument

    if kvs includes an association with the same key as but a different value than kv.

val class_spec_of_attrs : ?description:string -> ?enums:(string * Kaitai.Types.EnumSpec.t) list -> ?types:(string * Kaitai.Types.ClassSpec.t) list -> ?instances:(string * Kaitai.Types.InstanceSpec.t) list -> ?imports:string list -> Kaitai.Types.AttrSpec.t list -> Kaitai.Types.ClassSpec.t

class_spec_of_attrs ~id ?description ?enums ?instances attrs returns a ClassSpec.t for the seq attrs.

  • parameter [?description]

    is used as doc section summary.

  • parameter [?enums]

    is added to class specification if present.

  • parameter [?types]

    is added to class specification if present.

  • parameter [?instances]

    is added to class specification if present.

  • parameter [?imports]

    is added to class specification if not empty.

val default_instance_spec : id:string -> Kaitai.Types.Ast.t -> Kaitai.Types.InstanceSpec.t

default_instance_spec ~id expr returns a default instance specification for of a given id and expr.

val merge_summaries : Kaitai.Types.AttrSpec.t -> string option -> Kaitai.Types.AttrSpec.t

merge_summaries a s adds the summary s to the doc of a preserving the existing doc if any.

merge_valid a v adds the validation-spec v to the attribute a, combining the validation-specs if one is already present.