mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
function Bencode.reset to clear a decoder's state
This commit is contained in:
parent
4dd3c63ba5
commit
97451b48a9
2 changed files with 14 additions and 0 deletions
|
|
@ -264,6 +264,15 @@ let parse dec s i len =
|
|||
(* state machine *)
|
||||
parse_rec dec
|
||||
|
||||
let reset dec =
|
||||
dec.l <- 0;
|
||||
dec.c <- 0;
|
||||
dec.i <- 0;
|
||||
dec.len <- 0;
|
||||
dec.state <- ParsePartial;
|
||||
dec.stack <- [];
|
||||
()
|
||||
|
||||
let state dec = dec.state
|
||||
|
||||
let rest dec =
|
||||
|
|
|
|||
|
|
@ -79,6 +79,11 @@ val parse : decoder -> string -> int -> int -> parse_result
|
|||
It can return an error, a value or just [ParsePartial] if
|
||||
more input is needed *)
|
||||
|
||||
val reset : decoder -> unit
|
||||
(** Reset the decoder to its pristine state, ready to parse something
|
||||
different. Before that, {! rest} and {! rest_size} can be used
|
||||
to recover the part of the input that has not been consumed yet. *)
|
||||
|
||||
val state : decoder -> parse_result
|
||||
(** Current state of the decoder *)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue