2 * ----------------------------------------------------------------------
7 (* A Netbuffer.t is a buffer that can grow and shrink dynamically. *)
12 (* Creates a netbuffer which allocates initially this number of bytes.
13 * The logical length is zero.
16 val contents : t -> string
17 (* Returns the contents of the buffer as fresh string. *)
19 val sub : t -> pos:int -> len:int -> string
20 (* sub nb k n: returns the n characters starting at position n from
21 * netbuffer nb as fresh string
25 (* Returns the logical length of the buffer *)
27 val add_string : t -> string -> unit
28 (* add_string nb s: Adds a copy of the string s to the logical end of
29 * the netbuffer nb. If necessary, the nb grows.
32 val add_sub_string : t -> string -> pos:int -> len:int -> unit
33 (* add_sub_string nb s k n: Adds the substring of s starting at position
34 * k with length n to the logical end of the netbuffer nb. If necessary,
36 * This is semantically the same as
37 * add_string nb (String.sub s k n), but the extra copy is avoided.
40 val delete : t -> pos:int -> len:int -> unit
41 (* delete nb k n: Deletes the n bytes at position k of netbuffer nb
43 * The netbuffer does not shrink!
47 (* deletes all contents from the buffer. As 'delete', the netbuffer does
51 val try_shrinking : t -> unit
52 (* try_shrinking nb: If the length of the buffer is less than half of
53 * the allocated space, the netbuffer is reallocated in order to save
57 val index_from : t -> int -> char -> int
58 (* index_from nb k c: Searches the character c in the netbuffer beginning
59 * at position k. If found, the position of the left-most occurence is
60 * returned. Otherwise, Not_found is raised.
63 val unsafe_buffer : t -> string
64 (* WARNING! This is a low-level function!
65 * Returns the current string that internally holds the buffer.
66 * The byte positions 0 to length - 1 actually store the contents of
67 * the buffer. You can directly read and modify the buffer. Note that
68 * there is no protection if you read or write positions beyond the
69 * length of the buffer.
72 val print_buffer : t -> unit
76 (* ======================================================================
80 * Revision 1.1 2000/11/17 09:57:27 lpadovan
83 * Revision 1.3 2000/06/25 22:34:43 gerd
84 * Added labels to arguments.
86 * Revision 1.2 2000/06/24 20:20:33 gerd
87 * Added the toploop printer.
89 * Revision 1.1 2000/04/15 13:07:48 gerd