Module Bi_io
Input and output functions for the Biniou serialization format
Node tags
val bool_tag : node_tagTag indicating a bool node.
val int8_tag : node_tagTag indicating a bool node.
Tag indicating an int8 node.
val int16_tag : node_tagTag indicating an int8 node.
Tag indicating an int16 node.
val int32_tag : node_tagTag indicating an int16 node.
Tag indicating an int32 node.
val int64_tag : node_tagTag indicating an int32 node.
Tag indicating an int64 node.
val float32_tag : node_tagTag indicating an int64 node.
Tag indicating a float32 node.
val float64_tag : node_tagTag indicating a float32 node.
Tag indicating a float64 node.
val uvint_tag : node_tagTag indicating a float64 node.
Tag indicating a uvint node.
val svint_tag : node_tagTag indicating a uvint node.
Tag indicating an svint node.
val string_tag : node_tagTag indicating an svint node.
Tag indicating a string node.
val array_tag : node_tagTag indicating a string node.
Tag indicating an array node.
val tuple_tag : node_tagTag indicating an array node.
Tag indicating a tuple node.
val record_tag : node_tagTag indicating a tuple node.
Tag indicating a record node.
val num_variant_tag : node_tagTag indicating a record node.
Tag indicating a num_variant node.
val variant_tag : node_tagTag indicating a num_variant node.
Tag indicating a variant node.
val unit_tag : node_tagTag indicating a variant node.
Tag indicating a unit node.
val table_tag : node_tagTag indicating a unit node.
Tag indicating a table node.
Tag indicating a table node.
Tag indicating a shared node.
val write_tag : Bi_outbuf.t -> node_tag -> unitWrite one-byte tag to a buffer.
val read_tag : Bi_inbuf.t -> node_tagRead one-byte tag from a buffer.
Tags of variants and record fields
val hash_name : string -> hashHash function used to compute field name tags and variant tags from their full name.
val write_hashtag : Bi_outbuf.t -> hash -> bool -> unitwrite_hashtag ob h has_argwrites variant taghto bufferob.has_argindicates whether the variant has an argument. This function can be used for record field names as well, in which casehas_argmay only betrue.
val string_of_hashtag : hash -> bool -> stringSame as
write_hashtagbut writes to a string.
val read_hashtag : Bi_inbuf.t -> (Bi_inbuf.t -> hash -> bool -> 'a) -> 'aread_hashtag ib freads a variant tag as hashhand flaghas_argand returnsf h has_arg.
val read_field_hashtag : Bi_inbuf.t -> hashread_field_hashtag ibreads a field tag and returns the 31-bit hash.
val make_unhash : string list -> hash -> string optionCompute the hash of each string of the input list and return a function that converts a hash back to the original string. Lookups do not allocate memory blocks.
- raises Failure
if the input list contains two different strings with the same hash.
val write_numtag : Bi_outbuf.t -> int7 -> bool -> unitwrite_numtag ob i has_argwrites the tag of a num_variant. The tag name is represented byiwhich must be within [0, 127] and the flaghas_argwhich indicates the presence of an argument.
val read_numtag : Bi_inbuf.t -> (Bi_inbuf.t -> int7 -> bool -> 'a) -> 'aread_numtag ib freads a num_variant tag and processes the tag nameiand flaghas_argusingf.
Atom writers
val write_untagged_unit : Bi_outbuf.t -> unit -> unitval write_untagged_bool : Bi_outbuf.t -> bool -> unitval write_untagged_char : Bi_outbuf.t -> char -> unitval write_untagged_int8 : Bi_outbuf.t -> int -> unitval write_untagged_int16 : Bi_outbuf.t -> int -> unitval write_untagged_int32 : Bi_outbuf.t -> int32 -> unitval write_untagged_int64 : Bi_outbuf.t -> int64 -> unitval write_untagged_float32 : Bi_outbuf.t -> float -> unitval write_untagged_float64 : Bi_outbuf.t -> float -> unitval write_untagged_string : Bi_outbuf.t -> string -> unitval write_untagged_uvint : Bi_outbuf.t -> int -> unitval write_untagged_svint : Bi_outbuf.t -> int -> unitval write_unit : Bi_outbuf.t -> unit -> unitval write_bool : Bi_outbuf.t -> bool -> unitval write_char : Bi_outbuf.t -> char -> unitval write_int8 : Bi_outbuf.t -> int -> unitval write_int16 : Bi_outbuf.t -> int -> unitval write_int32 : Bi_outbuf.t -> int32 -> unitval write_int64 : Bi_outbuf.t -> int64 -> unitval write_float32 : Bi_outbuf.t -> float -> unitval write_float64 : Bi_outbuf.t -> float -> unitval write_string : Bi_outbuf.t -> string -> unitval write_uvint : Bi_outbuf.t -> int -> unitval write_svint : Bi_outbuf.t -> int -> unit
Atom readers
val read_untagged_unit : Bi_inbuf.t -> unitval read_untagged_bool : Bi_inbuf.t -> boolval read_untagged_char : Bi_inbuf.t -> charval read_untagged_int8 : Bi_inbuf.t -> intval read_untagged_int16 : Bi_inbuf.t -> intval read_untagged_int32 : Bi_inbuf.t -> int32val read_untagged_int64 : Bi_inbuf.t -> int64val read_untagged_float32 : Bi_inbuf.t -> floatval read_untagged_float64 : Bi_inbuf.t -> floatval read_untagged_string : Bi_inbuf.t -> stringval read_untagged_uvint : Bi_inbuf.t -> intval read_untagged_svint : Bi_inbuf.t -> intval skip : Bi_inbuf.t -> unitRead and discard a value. Useful for skipping unknown record fields.
Generic tree
type tree=[|`Unit|`Bool of bool|`Int8 of char|`Int16 of int|`Int32 of Stdlib.Int32.t|`Int64 of Stdlib.Int64.t|`Float32 of float|`Float64 of float|`Uvint of int|`Svint of int|`String of string|`Array of (node_tag * tree array) option|`Tuple of tree array|`Record of (string option * hash * tree) array|`Num_variant of int * tree option|`Variant of string option * hash * tree option|`Table of ((string option * hash * node_tag) array * tree array array) option|`Shared of tree]Tree representing serialized data, useful for testing and for untyped transformations.
val write_tree : Bi_outbuf.t -> tree -> unitSerialization of a tree to a buffer.
val string_of_tree : tree -> stringSerialization of a tree into a string.
val read_tree : ?unhash:(hash -> string option) -> Bi_inbuf.t -> treeDeserialization of a tree from a buffer.
val tree_of_string : ?unhash:(hash -> string option) -> string -> treeDeserialization of a tree from a string.
val view_of_tree : tree -> stringval view : ?unhash:(hash -> string option) -> string -> stringPrints a human-readable representation of the data into a string.
val print_view_of_tree : tree -> unitval print_view : ?unhash:(hash -> string option) -> string -> unitPrints a human-readable representation of the data to stdout.
val output_view_of_tree : Stdlib.out_channel -> tree -> unitval output_view : ?unhash:(hash -> string option) -> Stdlib.out_channel -> string -> unitPrints a human-readable representation of the data to an out_channel.