X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fmathql_interpreter%2Futility.ml;fp=helm%2Focaml%2Fmathql_interpreter%2Futility.ml;h=0000000000000000000000000000000000000000;hb=869549224eef6278a48c16ae27dd786376082b38;hp=5ea9b7e672f2be2a3c783f4fcf90fd01222d1df2;hpb=89262281b6e83bd2321150f81f1a0583645eb0c8;p=helm.git diff --git a/helm/ocaml/mathql_interpreter/utility.ml b/helm/ocaml/mathql_interpreter/utility.ml deleted file mode 100644 index 5ea9b7e67..000000000 --- a/helm/ocaml/mathql_interpreter/utility.ml +++ /dev/null @@ -1,119 +0,0 @@ -(* Copyright (C) 2000, HELM Team. - * - * This file is part of HELM, an Hypertextual, Electronic - * Library of Mathematics, developed at the Computer Science - * Department, University of Bologna, Italy. - * - * HELM is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * HELM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with HELM; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - * - * For details, see the HELM World-Wide-Web page, - * http://www.cs.unibo.it/helm/. - *) - -(* - * funzioni di utilita' generale - *) - -open Dbconn;; - -(* - * converte il risultato di una query in una lista di stringhe - * - * parametri: - * l: Postgres.result; risultato della query - * - * output: string list; lista di stringhe (una per tupla) - * - * assumo che il risultato della query sia - * costituito da un solo valore per tupla - * - * TODO - * verificare che l sia effettivamente costruita come richiesto - *) -let pgresult_to_string_list l = List.map (List.hd) l#get_list;; - -(* - * converte il risultato di una query in una stringa - * - * paramteri: - * l: Postgres.result; risultato della query - * - * output: string; valore dell'unica tupla del risultato - * - * mi aspetto che il risultato contenga una sola tupla - * formata da un solo valore - * - * TODO - * verificare che l sia costruita come richiesto - *) -let pgresult_to_string l = - match l#get_list with - [] -> "" - | t -> List.hd (List.hd t) -;; - -(* - * parametri: - * x: 'a; chiave di cui settare il valore - * v: 'b; valore da assegnare alla chiave - * l: ('a * 'b) list; lista di coppie in cui effettuare - * l'assegnamento - * - * output: ('a * 'b) list; lista di coppie contenente (x, v) - * - * TODO - * gestire i casi in cui in l compaiono piu' coppie (x, _) - * si sostituiscono tutte? se ne sostituisce una e si eliminano - * le altre? - *) -let set_assoc x v l = - let rec spila testa key value lista = - match lista with - [] -> testa @ [(key, value)] - | (j, _)::tl when j = key -> testa @ [(key, value)] @ tl - | hd::tl -> spila (testa @ [hd]) key value tl - in - spila [] x v l -;; - -(* - * parametri: - * p: string; nome della proprieta' - * - * output: string; id interno associato alla proprieta' - *) -let helm_property_id p = - let c = pgc () in - let q1 = "select att0 from namespace where att1='http://www.cs.unibo.it/helm/schemas/mattone.rdf#'" in - let ns = pgresult_to_string (c#exec q1) in - let q2 = ("select att0 from property where att2='" ^ p ^ "' and att1=" ^ ns) in - let retval = pgresult_to_string (c#exec q2) in - (*let _ = print_endline ("utility:q2: " ^ q2 ^ " : " ^ retval) in*) - retval -;; - -(* - * parametri: - * c: string; nome della classe - * - * output: string; id interno associato alla classe - *) -let helm_class_id cl = - let c = pgc () in - let ns = pgresult_to_string (c#exec ("select att0 from namespace where att1='http://www.cs.unibo.it/helm/schemas/mattone.rdf#'")) in - pgresult_to_string (c#exec ("select att0 from class where att2='" ^ cl ^ "' and att1=" ^ ns)) -;; -