Module Bi_outbuf
Output buffer
type t={mutable o_s : bytes;Buffer string
mutable o_max_len : int;Same as
String.length smutable o_len : int;Length of the data present in the buffer = current position in the buffer
mutable o_offs : int;Length of data written and flushed out of the buffer. The total number of bytes written to the buffer is therefore
o_offs + o_len.o_init_len : int;Initial length of the buffer
o_make_room : t -> int -> unit;make_room buf nmust provide space for at least the requested number of bytesn, typically by reallocating a larger buffer string or by flushing the data to a channel. This function is only called when there is not enough space fornbytes.mutable o_shared : Bi_share.Wr.tbl;Hash table used to map shared objects to positions in the input stream.
o_shared_init_len : int;Initial length of the
o_sharedtable.}
val really_extend : t -> int -> unitDefault make_room function: reallocate a larger buffer string.
val flush_to_channel : Stdlib.out_channel -> t -> int -> unitAlternate make_room function: write to an out_channel.
val create : ?make_room:(t -> int -> unit) -> ?shrlen:int -> int -> tCreate a buffer. The default
make_roomfunction isreally_extend.- parameter shrlen
initial size of the table used to store shared values.
val contents : t -> stringReturns the data currently in the buffer.
val create_channel_writer : ?len:int -> ?shrlen:int -> Stdlib.out_channel -> tval flush_channel_writer : t -> unitPair of convenience functions for creating a buffer that flushes data to an out_channel when it is full.
val create_output_writer : ?len:int -> ?shrlen:int -> < output : string -> int -> int -> int; .. > -> tval flush_output_writer : t -> unitPair of convenience functions for creating a buffer that flushes data to an object when it is full.
val extend : t -> int -> unitGuarantee that the buffer string has enough room for n additional bytes.
val alloc : t -> int -> intalloc buf nmakes room fornbytes and returns the position of the first byte in the buffer stringbuf.s. It behaves as ifnarbitrary bytes were added and it is the user's responsibility to set them to some meaningful values by accessingbuf.sdirectly.
val add_bytes : t -> bytes -> unitAdd bytes to the buffer.
- since
- 1.2.0
val add_subbytes : t -> bytes -> int -> int -> unitadd_subbytes dst src srcpos lencopieslenbytes from bytessrcto bufferdststarting from positionsrcpos.- since
- 1.2.0
val add_string : t -> string -> unitAdd a string to the buffer.
val add_substring : t -> string -> int -> int -> unitadd_substring dst src srcpos lencopieslenbytes from stringsrcto bufferdststarting from positionsrcpos.
val add_char : t -> char -> unitAdd a byte to the buffer.
val add_char2 : t -> char -> char -> unitAdd two bytes to the buffer.
val add_char4 : t -> char -> char -> char -> char -> unitAdd four bytes to the buffer.
val unsafe_add_char : t -> char -> unitAdd a byte to the buffer without checking that there is enough room for it.
val clear : t -> unitRemove any data present in the buffer and in the table holding shared objects.
val reset : t -> unitRemove any data present in the buffer and reset it to its original size. Remove any data present in the table holding shared objects and reset it to its original size.