1 (* Wrapper around Perl Net::Google class.
2 * Copyright (C) 2003 Merjis Ltd.
3 * $Id: pl_Net_Google.ml,v 1.1 2003-10-14 16:05:22 rich Exp $
8 open Pl_Net_Google_Cache
9 open Pl_Net_Google_Search
10 open Pl_Net_Google_Spelling
12 let may f = function None -> () | Some v -> f v
18 method search ?key ?starts_at ?max_results ?lr ?ie ?oe ?safe ?filter () =
21 args := sv_of_string "key" :: sv_of_string v :: !args) key;
23 args := sv_of_string "starts_at" :: sv_of_int v :: !args) starts_at;
25 args := sv_of_string "max_results" :: sv_of_int v :: !args)
28 args := sv_of_string "lr" :: sv_of_string v :: !args) lr;
30 args := sv_of_string "ie" :: sv_of_string v :: !args) ie;
32 args := sv_of_string "oe" :: sv_of_string v :: !args) oe;
34 args := sv_of_string "safe" :: sv_of_bool v :: !args) safe;
36 args := sv_of_string "filter" :: sv_of_bool v :: !args) filter;
37 let sv = call_method sv "search" !args in
38 new net_google_search sv
40 method spelling ?key ?phrase ?debug () =
43 args := sv_of_string "key" :: sv_of_string v :: !args) key;
45 args := sv_of_string "phrase" :: sv_of_string v :: !args) phrase;
47 args := sv_of_string "debug" :: sv_of_int v :: !args) debug;
48 let sv = call_method sv "spelling" !args in
49 new net_google_spelling sv
51 method cache ?key ?url ?debug () =
54 args := sv_of_string "key" :: sv_of_string v :: !args) key;
56 args := sv_of_string "url" :: sv_of_string v :: !args) url;
58 args := sv_of_string "debug" :: sv_of_int v :: !args) debug;
59 let sv = call_method sv "cache" !args in
60 new net_google_cache sv
64 let new_ ?key ?debug () =
67 args := sv_of_string "key" :: sv_of_string v :: !args) key;
69 args := sv_of_string "debug" :: sv_of_int v :: !args) debug;
70 let sv = call_class_method "Net::Google" "new" !args in