module MakeBuffer:
Functor that creates resizable buffers (=string arrays) from
reallocation strategies.
include Nopres_intf.T
Includes all functions that exist in non-parameterized arrays.
String conversions
val sof_string : strategy -> string -> t
sof_string s ar
converts a string to a resizable buffer
using strategy s
.
val of_string : string -> t
of_string ar
converts a string to a resizable buffer using
the default strategy.
Functions found in the standard Buffer
-module
Note that the function create n
ignores the parameter n
and
uses the default strategy instead. You can supply a different
strategy with creates s n
as described above.
val contents : t -> string
contents b
Returns a copy of the current contents of the
buffer b
.
val reset : t -> unit
reset b
just clears the buffer, possibly resizing it.
val add_char : t -> char -> unit
add_char b c
appends the character c
at the end of
the buffer b
.
val add_string : t -> string -> unit
add_string b s
appends the string s
at the end of
the buffer b
.
val add_substring : t -> string -> int -> int -> unit
add_substring b s ofs len
takes len
characters from offset
ofs
in string s
and appends them at the end of the buffer
b
.
val add_buffer : t -> t -> unit
add_buffer b1 b2
appends the current contents of buffer b2
at the end of buffer b1
. b2
is not modified.
val add_channel : t -> Pervasives.in_channel -> int -> unit
add_channel b ic n
reads exactly n
character from the
input channel ic
and stores them at the end of buffer b
.
Raises End_of_file
if the channel contains fewer than n
characters.
val output_buffer : Pervasives.out_channel -> t -> unit
output_buffer oc b
writes the current contents of buffer b
on the output channel oc
.
Additional buffer functions
val add_full_channel : t -> Pervasives.in_channel -> unit
val add_full_channel_f : t -> Pervasives.in_channel -> int -> (int -> int) -> unit