1 (* Copyright (C) 2004, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://helm.cs.unibo.it/
28 let pp_position = function
29 | `MainConclusion -> "MainConclusion"
30 | `MainHypothesis -> "MainHypothesis"
31 | `InConclusion -> "InConclusion"
32 | `InHypothesis -> "InHypothesis"
35 let metadata_ns = "http://www.cs.unibo.it/helm/schemas/schema-helm"
36 let uri_of_pos pos = String.concat "#" [metadata_ns; pp_position pos]
38 let pp_sort = function
41 | Cic.Type _ -> "Type"
42 | Cic.CProp -> "CProp"
44 type t = [ `Int of int | `String of string | `Null ]
46 let columns_of_metadata ~about metadatas =
47 let position p = `String (pp_position p) in
48 let sort s = `String (pp_sort s) in
49 let source = `String about in
50 let depth d = `Int d in
51 let depth_opt = function None -> `Null | Some d -> `Int d in
52 let occurrence u = `String u in
54 (fun (sort_cols, rel_cols, obj_cols) metadata ->
57 [source; position p; depth d; sort s] :: sort_cols, rel_cols, obj_cols
59 sort_cols, [source; position p; depth d] :: rel_cols, obj_cols
62 [source; occurrence o; position p; depth_opt d] :: obj_cols)
63 ([], [], []) metadatas
65 let columns_of_ind_metadata ind_metadata =
67 (fun (sort_cols, rel_cols, obj_cols) (uri, _, metadatas) ->
68 let (s, r, o) = columns_of_metadata ~about:uri metadatas in
69 (List.append sort_cols s, List.append rel_cols r, List.append obj_cols o))
70 ([], [], []) ind_metadata
72 let pp_columns ?(sep = "\n") (sort_cols, rel_cols, obj_cols) =
74 ([ "Sort" ] @ List.map Dbi.sdebug (sort_cols :> Dbi.sql_t list list) @
75 [ "Rel" ] @ List.map Dbi.sdebug (rel_cols :> Dbi.sql_t list list) @
76 [ "Obj" ] @ List.map Dbi.sdebug (obj_cols :> Dbi.sql_t list list))