module Netbuffer:A Netbuffer.t is a buffer that can grow and shrink dynamically.sig..end
type t
val create : int -> tval contents : t -> stringval length : t -> intval get : t -> int -> charget nb pos: Get the character at posval nth : t -> int -> chargetval sub : t -> int -> int -> stringsub nb k n: returns the n characters starting at position n from
netbuffer nb as fresh stringval blit_to_string : t -> int -> string -> int -> int -> unitblit_to_string nb srcpos dest destpos len: Copies the len bytes at
position srcpos from nb to the string dest at position destpos.val blit : t -> int -> string -> int -> int -> unitblit_to_string, now deprecatedval add_string : t -> string -> unitadd_string nb s: Adds a copy of the string s to the logical end of
the netbuffer nb. If necessary, nb grows.val add_sub_string : t -> string -> int -> int -> unitadd_sub_string nb s k n: Adds the substring of s starting at position
k with length n to the logical end of the netbuffer nb. If necessary,
nb grows.
This is semantically the same as
add_string nb (String.sub s k n), but the extra copy is avoided.
val add_substring : t -> string -> int -> int -> unitval add_char : t -> char -> unitadd_char nb c: Adds a single char at the end of the bufferval add_inplace : ?len:int -> t -> (string -> int -> int -> int) -> intadd_inplace nb f: Calls the function f to add bytes to the
netbuffer nb. The arguments of f are the buffer, the position
in the buffer, and the maximum length. The function f must return
the actual number of added bytes; this number is also returned by
add_inplace.
Example: let n = add_inplace nb (Pervasives.input ch)
The argument len is the number of bytes to add (second argument of
f). It defaults to the number of free bytes in the buffer after space
for at least one byte has been allocated.
val add_buffer : t -> t -> unitadd_buffer nb1 nb2: Adds the contents of nb2 to the end of nb1val insert_string : t -> int -> string -> unitinsert_string nb p s: Inserts the value of string s at position
p into the netbuffer nbval insert_sub_string : t -> int -> string -> int -> int -> unitinsert_string nb p s k n: Inserts a substring of string s at position
p into the netbuffer nb. The substring is denoted by position k
and has length nval insert_char : t -> int -> char -> unitinsert_char nb p c: Inserts character c at position p into
the netbuffer nbval set : t -> int -> char -> unitset nb pos c: Sets the character at pos to cval put_string : t -> int -> string -> unitput_string nb pos s: Copies the string s to the position pos
of netbuffer nbval blit_from_string : string -> int -> t -> int -> int -> unitblit_from_string src srcpos dest destpos len: Copies the len bytes
at position srcpos from the string src to the netbuffer dest at
position destpos.
It is possible to copy the string beyond the end of the buffer. The
buffer is automatically enlarged in this case.
val delete : t -> int -> int -> unitdelete nb k n: Deletes the n bytes at position k of netbuffer
nb in-place.
The netbuffer does not shrink, however, i.e. the free space is not
given back to the memory manager.
val clear : t -> unitdelete, the netbuffer does
not shrink.val reset : t -> unitn that was allocated by
Netbuffer.create n.val try_shrinking : t -> unittry_shrinking nb: If the length of the buffer is less than half of
the allocated space, the netbuffer is reallocated in order to save
memory.val index_from : t -> int -> char -> intindex_from nb k c: Searches the character c in the netbuffer beginning
at position k. If found, the position of the left-most occurence is
returned. Otherwise, Not_found is raised.val unsafe_buffer : t -> stringval print_buffer : t -> unit