Outline of documentation.
[ocaml-bitstring.git] / bitmatch.mli
1 (** Bitmatch library. *)
2 (* Copyright (C) 2008 Red Hat Inc., Richard W.M. Jones
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * $Id: bitmatch.mli,v 1.8 2008-04-02 08:14:40 rjones Exp $
19  *)
20
21 (**
22    {2 Introduction and examples}
23
24
25    {2 Reference}
26
27    {3 Types}
28 *)
29
30 type bitstring = string * int * int
31
32 (** {3 Exceptions} *)
33
34 exception Construct_failure of string * string * int * int
35
36 (** {3 Bitstrings} *)
37
38 val empty_bitstring : bitstring
39
40 val create_bitstring : int -> bitstring
41
42 val make_bitstring : int -> char -> bitstring
43
44 val bitstring_of_chan : in_channel -> bitstring
45
46 val bitstring_of_file : string -> bitstring
47
48 val hexdump_bitstring : out_channel -> bitstring -> unit
49
50 val bitstring_length : bitstring -> int
51
52 (** {3 Bitstring buffer} *)
53
54 module Buffer : sig
55   type t
56   val create : unit -> t
57   val contents : t -> bitstring
58   val add_bits : t -> string -> int -> unit
59   val add_bit : t -> bool -> unit
60   val add_byte : t -> int -> unit
61 end
62
63 (** {3 Miscellaneous} *)
64
65 val debug : bool ref
66
67 (**/**)
68 (* Private functions, called from generated code.  Do not use
69  * these directly - they are not safe.
70  *)
71
72 val extract_bitstring : string -> int -> int -> int -> bitstring * int * int
73
74 val extract_remainder : string -> int -> int -> bitstring * int * int
75
76 val extract_bit : string -> int -> int -> int -> bool * int * int
77
78 val extract_char_unsigned : string -> int -> int -> int -> int * int * int
79
80 val extract_int_be_unsigned : string -> int -> int -> int -> int * int * int
81
82 val extract_int_le_unsigned : string -> int -> int -> int -> int * int * int
83
84 val extract_int32_be_unsigned : string -> int -> int -> int -> int32 * int * int
85
86 val extract_int32_le_unsigned : string -> int -> int -> int -> int32 * int * int
87
88 val extract_int64_be_unsigned : string -> int -> int -> int -> int64 * int * int
89
90 val construct_bit : Buffer.t -> bool -> int -> unit
91
92 val construct_char_unsigned : Buffer.t -> int -> int -> exn -> unit
93
94 val construct_int64_be_unsigned : Buffer.t -> int64 -> int -> exn -> unit