2 * (C) Copyright 2008-2011 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program 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
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 (** Utility functions. *)
24 type 'a t = 'a Map.Make (String).t
26 val is_empty : 'a t -> bool
27 val add : key -> 'a -> 'a t -> 'a t
28 val find : key -> 'a t -> 'a
29 val remove : key -> 'a t -> 'a t
30 val mem : key -> 'a t -> bool
31 val iter : (key -> 'a -> unit) -> 'a t -> unit
32 val map : ('a -> 'b) -> 'a t -> 'b t
33 val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t
34 val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
35 val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
36 val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
38 (** Map strings -> any type. Used for symbol tables. *)
40 type symbol_table = int64 StringMap.t
41 (** A symbol table is a map from strings (symbols) to virtual addresses. *)
43 val ( +^ ) : int64 -> int64 -> int64
44 val ( -^ ) : int64 -> int64 -> int64
45 val ( *^ ) : int64 -> int64 -> int64
46 val ( /^ ) : int64 -> int64 -> int64
47 val ( &^ ) : int64 -> int64 -> int64
48 (** 64 bit operators. *)
50 val frequency : 'a list -> (int * 'a) list
51 (** Take a list of items, and return the list (count, item)
52 in order from most frequent to least frequent occurring
53 in the original list. *)
55 val filter_map : ('a -> 'b option) -> 'a list -> 'b list
56 (** [filter_map f as] maps each 'a' to 'b', but if the function
57 returns [None] then the element is removed from the output. *)
59 val replace_chars : (char -> string) -> string -> string
60 (** [replace_chars f s] returns a string where all chars [c] of [s]
61 have been replaced by the string returned by [f c]. *)
63 val set_debug : unit -> unit
64 (** If called, enables debugging. *)
66 val debug : ('a, unit, string, unit) format4 -> 'a
67 (** If debugging is enabled, this prints the string to stdout
68 followed by a newline character. *)
70 val error : ('a, unit, string, unit) format4 -> 'a
71 (** Print the name of the program and the error message to stderr
72 followed by a newline character. Note this function doesn't
73 exit the program. If you want to do that, call [exit 1]
76 val set_program_name : string -> unit
77 (** Set the program name. *)
79 val get_program_name : unit -> string
80 (** Get the program name. *)