module Cf_message:Functional message buffer chains.sig..end
This module implements convenience functions useful when manipulating
lists of substrings that represent portable inter-process communication
messages. A list of substrings is very much like the "mbuf" chain commonly
found in network protocol stacks, and this module facilitates composing
and manipulating messages in this way.
typet =(string * int * int) list
val normalize : t -> tnormalize m to discard empty substrings from the list. Raises
Invalid_arg if any of the substrings have a negative length or which
specify invalid substrings of the string component of the triple.val create : string -> tcreate s to obtain a new message composed of a flattened message
containing the string s. Returns the empty list when the string is the
empty string.val length : t -> intlength m to compute the length of the message m.val contents : t -> stringcontents m to create a new string containing the entire text of the
message m.val copy : t -> tcopy m to create a new message with a deep copy of the contents of
m, i.e. it is equivalent to create (contents m).val flatten : t -> tflatten m to reduce a message list of two or more substrings to a
single substring. If m is already a single substring or the empty list,
then m itself is returned. Otherwise, the result is the same as what
copy m would return.val split : pos:int -> t -> t * tsplit ~pos m to return two new messages, the first containing all the
text in message m before the position pos, and the second containing
all the remaining text in message m. The strings themselves are not
copied; only the list of substrings is manipulated. Raises
Invalid_argument if the position is negative or beyond the length of the
message.val truncate : pos:int -> t -> ttruncate ~pos m to return a new message containing all the text in
message m before the position pos. The strings themselves are not
copied; only the list of substrings is manipulated. Raises
Invalid_argument if the position is negative or beyond the length of the
message.val shift : pos:int -> t -> tshift ~pos m to return a new message with all the text in message m
before the position pos removed. This strings themselves are not copied;
only the list of substrings is manipulated. Raises Invalid_argument if
the position is negative or beyond the length of the message.val insert : pos:int -> m:t -> t -> tinsert ~pos ~m m1 to return a new message with all the text in
message m inserted into the message m1 at the position pos. The
strings themselves are not copied; only the list of substrings is
manipulated. Raises Invalid_argument if the position is negative or
beyond the length of the message.val to_seq : t -> char Cf_seq.tto_seq m to obtain the sequence of characters in message m. The
message is immediately normalized with normalize m.val to_seq2 : t -> (char * t) Cf_seq.tto_seq2 m to obtain the sequence of characters in message m with
each character associated with the remainder of the message. The message
is immediately normalized with normalize m.