123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134(** A functor for displaying a type as a sequence of ASCII characters printed in
hexadecimal.
[sexp_of_t] and [to_string_hum] print [t] in a similar format to 'hexdump' on Unix
systems. For example, the string "Back off, man, I'm a scientist." renders as:
{v
00000000 42 61 63 6b 20 6f 66 66 2c 20 6d 61 6e 2c 20 49 |Back off, man, I|
00000010 27 6d 20 61 20 73 63 69 65 6e 74 69 73 74 2e |'m a scientist.|
v}
[to_sequence] produces a sequence of strings representing lines in the hex dump. It
can be used to process a hex dump incrementally, for example with potentially infinite
values, or to avoid keeping the entire output in memory at once. *)open!ImportmoduletypeS=sigtypetmoduleHexdump:sigtypenonrect=t[@@derivingsexp_of](** [to_string_hum] renders [t] as a multi-line ASCII string in hexdump format. [pos]
and [len] select a subrange of [t] to render. [max_lines] determines the maximum
number of lines of hex dump to produce. If the full hex dump exceeds this number,
lines in the middle are replaced by a single "..."; the beginning and end of the
hex dump are left intact. In order to produce at least some readable hex dump, at
least 3 lines are always produced. *)valto_string_hum:?max_lines:int(** default: [!default_max_lines] *)->?pos:int->?len:int->t->string(** [to_sequence] produces the lines of [to_string_hum] as a sequence of strings.
This may be useful for incrementally rendering a large hex dump without producing
the whole thing in memory. Optional arguments function as in [to_string_hum]. *)valto_sequence:?max_lines:int(** default: [!default_max_lines] *)->?pos:int->?len:int->t->stringSequence.t(** [[%sexp_of: Hexdump.Pretty.t]] is the same as [[%sexp_of: Hexdump.t]], unless the
underlying sequence of characters is entirely printable. In that case, it is
rendered directly as a string. This allows e.g. test output to be much more
compact in the common (printable) case while still being interpretable for any
byte sequence. *)modulePretty:sigtypenonrect=t[@@derivingsexp_of]endendendmoduletypeS1=sigtype_tmoduleHexdump:sigtypenonrec'at='at[@@derivingsexp_of]valto_string_hum:?max_lines:int->?pos:int->?len:int->_t->stringvalto_sequence:?max_lines:int->?pos:int->?len:int->_t->stringSequence.tmodulePretty:sigtypenonrec'at='at[@@derivingsexp_of]endendendmoduletypeS2=sigtype(_,_)tmoduleHexdump:sigtypenonrec('a,'b)t=('a,'b)t[@@derivingsexp_of]valto_string_hum:?max_lines:int->?pos:int->?len:int->(_,_)t->stringvalto_sequence:?max_lines:int->?pos:int->?len:int->(_,_)t->stringSequence.tmodulePretty:sigtypenonrec('a,'b)t=('a,'b)t[@@derivingsexp_of]endendend(** The functor [Hexdump.Of_indexable] uses [length] and [get] to iterate over the
characters in a value and produce a hex dump. *)moduletypeIndexable=sigtypetvallength:t->intvalget:t->int->charendmoduletypeIndexable1=sigtype_tvallength:_t->intvalget:_t->int->charendmoduletypeIndexable2=sigtype(_,_)tvallength:(_,_)t->intvalget:(_,_)t->int->charendmoduletypeHexdump=sigmoduletypeIndexable=IndexablemoduletypeIndexable1=Indexable1moduletypeIndexable2=Indexable2moduletypeS=SmoduletypeS1=S1moduletypeS2=S2(** Can be used to override the default [~lines] argument for [to_string_hum] and
[to_sequence] in [S]. *)valdefault_max_lines:intrefmoduleOf_indexable(T:Indexable):Swithtypet:=T.tmoduleOf_indexable1(T:Indexable1):S1withtype'at:='aT.tmoduleOf_indexable2(T:Indexable2):S2withtype('a,'b)t:=('a,'b)T.tend