Added proper LGPL statements to all files.
[perl4caml.git] / wrappers / pl_URI.ml
1 (** Wrapper around Perl [URI] class. *)
2 (*  Copyright (C) 2003 Merjis Ltd.
3
4     This library is free software; you can redistribute it and/or
5     modify it under the terms of the GNU Library 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     Library General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this library; see the file COPYING.  If not, write to
16     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17     Boston, MA 02111-1307, USA.
18
19     $Id: pl_URI.ml,v 1.6 2008-03-01 13:02:21 rich Exp $
20   *)
21
22 open Perl
23
24 let _ = eval "use URI"
25
26 class uri sv =
27
28 object (self)
29
30   method sv = sv
31
32   method scheme =
33     string_of_sv (call_method sv "scheme" [])
34   method set_scheme scheme =
35     call_method_void sv "scheme" [sv_of_string scheme]
36   method opaque =
37     string_of_sv (call_method sv "opaque" [])
38   method set_opaque opaque =
39     call_method_void sv "opaque" [sv_of_string opaque]
40   method path =
41     string_of_sv (call_method sv "path" [])
42   method set_path path =
43     call_method_void sv "path" [sv_of_string path]
44   method fragment =
45     string_of_sv (call_method sv "fragment" [])
46   method set_fragment fragment =
47     call_method_void sv "fragment" [sv_of_string fragment]
48   method set_no_fragment () =
49     call_method_void sv "fragment" [sv_undef ()]
50   method as_string =
51     string_of_sv (call_method sv "as_string" [])
52   method canonical =
53     string_of_sv (call_method sv "canonical" [])
54   method abs base =
55     string_of_sv (call_method sv "abs" [sv_of_string base])
56   method rel base =
57     string_of_sv (call_method sv "rel" [sv_of_string base])
58
59
60   method host =
61     string_of_sv (call_method sv "host" [])
62   method set_host host =
63     call_method_void sv "host" [sv_of_string host]
64   method port =
65     string_of_sv (call_method sv "port" [])
66   method set_port port =
67     call_method_void sv "port" [sv_of_string port]
68   method host_port =
69     string_of_sv (call_method sv "host_port" [])
70   method set_host_port host_port =
71     call_method_void sv "host_port" [sv_of_string host_port]
72   method default_port =
73     int_of_sv (call_method sv "default_port" [])
74
75 end
76
77 let new_ ?scheme str =
78   let args =
79     [sv_of_string str] @
80     match scheme with
81         None -> []
82       | Some scheme -> [sv_of_string scheme] in
83   let sv = call_class_method "URI" "new" args in
84   new uri sv
85
86 let new_abs str base =
87   let sv = call_class_method "URI" "new_abs" [sv_of_string str;
88                                               sv_of_string base] in
89   new uri sv