Added wrappers around some common libraries.
[perl4caml.git] / wrappers / pl_URI.ml
1 (* Wrapper around Perl URI class.
2  * Copyright (C) 2003 Merjis Ltd.
3  * $Id: pl_URI.ml,v 1.1 2003-10-12 17:33:15 rich Exp $
4  *)
5
6 open Perl
7
8 class uri sv =
9
10 object (self)
11
12   method sv = sv
13
14   method scheme =
15     string_of_sv (call_method sv "scheme" [])
16   method set_scheme scheme =
17     call_method_void sv "scheme" [sv_of_string scheme]
18   method opaque =
19     string_of_sv (call_method sv "opaque" [])
20   method set_opaque opaque =
21     call_method_void sv "opaque" [sv_of_string opaque]
22   method path =
23     string_of_sv (call_method sv "path" [])
24   method set_path path =
25     call_method_void sv "path" [sv_of_string path]
26   method fragment =
27     string_of_sv (call_method sv "fragment" [])
28   method set_fragment fragment =
29     call_method_void sv "fragment" [sv_of_string fragment]
30   method as_string =
31     string_of_sv (call_method sv "as_string" [])
32   method canonical =
33     string_of_sv (call_method sv "canonical" [])
34   method abs base =
35     string_of_sv (call_method sv "abs" [sv_of_string base])
36   method rel base =
37     string_of_sv (call_method sv "rel" [sv_of_string base])
38
39 end
40
41 let new_ ?scheme str =
42   let args =
43     [sv_of_string str] @
44     match scheme with
45         None -> []
46       | Some scheme -> [sv_of_string scheme] in
47   let sv = call_class_method "URI" "new" args in
48   new uri sv