Support HVs.
[perl4caml.git] / perl.mli
index 73270d2..ef8dea0 100644 (file)
--- a/perl.mli
+++ b/perl.mli
@@ -2,7 +2,7 @@
   *
   * Copyright (C) 2003 Merjis Ltd.
   *
-  * $Id: perl.mli,v 1.8 2003-10-16 13:41:06 rich Exp $
+  * $Id: perl.mli,v 1.9 2003-10-18 12:36:09 rich Exp $
   *)
 
 type t
@@ -14,10 +14,8 @@ type sv
 type av
 (** Perl array value. *)
 
-(*
 type hv
 (** Perl hash value. *)
-*)
 
 exception Perl_failure of string
 (** [die] in Perl code is translated automatically into this exception. *)
@@ -148,13 +146,11 @@ val deref_array : sv -> av
   * array [AV]. If the input is not a reference to an array, throws
   * [Invalid_arg].
   *)
-(*
 val deref_hash : sv -> hv
 (** The input is a reference to a hash. This returns the underlying
   * hash [HV]. If the input is not a reference to a hash, throws
   * [Invalid_arg].
   *)
-*)
 
 val av_empty : unit -> av
 (** Create an empty [AV] (array). *)
@@ -187,6 +183,25 @@ val av_extend : av -> int -> unit
 val av_map : (sv -> 'a) -> av -> 'a list
 (** Map a function over the elements in the [AV], return a list of the
   * results. *)
+val list_of_av : av -> sv list
+(** Convert an [AV] into a simple list of [SV]s. *)
+val av_of_string_list : string list -> av
+(** Build an [AV] from a list of strings. *)
+
+val hv_empty : unit -> hv
+(** Create an empty [HV] (hash). *)
+val hv_set : hv -> string -> sv -> unit
+(** Store the given [SV] in the named key in the hash. *)
+val hv_get : hv -> string -> sv
+(** Return the [SV] at the key in the hash. Throws [Not_found] if no key. *)
+val hv_exists : hv -> string -> bool
+(** Return true if the hash contains the given key. Same as Perl [exists]. *)
+val hv_delete : hv -> string -> unit
+(** Delete the given key from the hash. Same as Perl [delete]. *)
+val hv_clear : hv -> unit
+(** Remove all elements from the [HV]. Same as Perl [%av = ()]. *)
+val hv_undef : hv -> unit
+(** Delete the [HV] (and all elements in it). Same as Perl [undef %hv]. *)
 
 val get_sv : ?create:bool -> string -> sv
 (** Return a scalar value by name. For example, if you have a symbol
@@ -200,6 +215,8 @@ val get_sv : ?create:bool -> string -> sv
   *)
 val get_av : ?create:bool -> string -> av
 (** Same as {!Perl.get_sv} except will return and/or create [\@a]. *)
+val get_hv : ?create:bool -> string -> hv
+(** Same as {!Perl.get_sv} except will return and/or create [%a]. *)
 
 val call : ?sv:sv -> ?fn:string -> sv list -> sv
 (** Call a Perl function in a scalar context, either by name (using the [?fn]