a4a773212c0ea9eafaf6394d933bfdb00552e4cc
[perl4caml.git] / wrappers / pl_URI.ml
1 (** Wrapper around Perl [URI] class.
2   *
3   * Copyright (C) 2003 Merjis Ltd.
4   *
5   * $Id: pl_URI.ml,v 1.4 2005-02-13 16:33:28 rich Exp $
6   *)
7
8 open Perl
9
10 let _ = eval "use URI"
11
12 class uri sv =
13
14 object (self)
15
16   method sv = sv
17
18   method scheme =
19     string_of_sv (call_method sv "scheme" [])
20   method set_scheme scheme =
21     call_method_void sv "scheme" [sv_of_string scheme]
22   method opaque =
23     string_of_sv (call_method sv "opaque" [])
24   method set_opaque opaque =
25     call_method_void sv "opaque" [sv_of_string opaque]
26   method path =
27     string_of_sv (call_method sv "path" [])
28   method set_path path =
29     call_method_void sv "path" [sv_of_string path]
30   method fragment =
31     string_of_sv (call_method sv "fragment" [])
32   method set_fragment fragment =
33     call_method_void sv "fragment" [sv_of_string fragment]
34   method as_string =
35     string_of_sv (call_method sv "as_string" [])
36   method canonical =
37     string_of_sv (call_method sv "canonical" [])
38   method abs base =
39     string_of_sv (call_method sv "abs" [sv_of_string base])
40   method rel base =
41     string_of_sv (call_method sv "rel" [sv_of_string base])
42
43
44   method host =
45     string_of_sv (call_method sv "host" [])
46   method set_host host =
47     call_method_void sv "host" [sv_of_string host]
48   method port =
49     string_of_sv (call_method sv "port" [])
50   method set_port port =
51     call_method_void sv "port" [sv_of_string port]
52   method host_port =
53     string_of_sv (call_method sv "host_port" [])
54   method set_host_port host_port =
55     call_method_void sv "host_port" [sv_of_string host_port]
56   method default_port =
57     int_of_sv (call_method sv "default_port" [])
58
59 end
60
61 let new_ ?scheme str =
62   let args =
63     [sv_of_string str] @
64     match scheme with
65         None -> []
66       | Some scheme -> [sv_of_string scheme] in
67   let sv = call_class_method "URI" "new" args in
68   new uri sv
69
70 let new_abs str base =
71   let sv = call_class_method "URI" "new_abs" [sv_of_string str;
72                                               sv_of_string base] in
73   new uri sv