1 (* Wrapper around Perl Net::Google::Search class.
2 * Copyright (C) 2003 Merjis Ltd.
3 * $Id: pl_Net_Google_Search.ml,v 1.2 2003-10-15 16:51:12 rich Exp $
8 open Pl_Net_Google_Response
10 let _ = eval "use Net::Google::Search"
12 class net_google_search sv =
17 string_of_sv (call_method sv "key" [])
19 call_method_void sv "key" [sv_of_string v]
21 string_of_sv (call_method sv "query" [])
23 call_method_void sv "query" [sv_of_string v]
25 int_of_sv (call_method sv "starts_at" [])
26 method set_starts_at v =
27 call_method_void sv "starts_at" [sv_of_int v]
29 int_of_sv (call_method sv "max_results" [])
30 method set_max_results v =
31 call_method_void sv "max_results" [sv_of_int v]
32 method restrict types =
33 string_of_sv (call_method sv "restrict" (List.map sv_of_string types))
35 bool_of_sv (call_method sv "filter" [])
37 call_method_void sv "filter" [sv_of_bool v]
39 bool_of_sv (call_method sv "safe" [])
41 call_method_void sv "safe" [sv_of_bool v]
43 string_of_sv (call_method sv "lr" (List.map sv_of_string langs))
45 string_of_sv (call_method sv "ie" (List.map sv_of_string encs))
47 string_of_sv (call_method sv "oe" (List.map sv_of_string encs))
48 method return_estimatedTotal =
49 bool_of_sv (call_method sv "return_estimatedTotal" [])
50 method set_return_estimatedTotal v =
51 call_method_void sv "return_estimatedTotal" [sv_of_bool v]
53 let sv = call_method sv "response" [] in
54 let av = deref_array sv in
55 av_map (fun sv -> new net_google_response sv) av
57 let sv = call_method sv "results" [] in
58 let av = deref_array sv in
59 av_map (fun sv -> new net_google_response sv) av