1 (* Copyright (C) 2000, 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://cs.unibo.it/helm/.
29 | Fix of int * int (* fixno, recparamno *)
32 | IConstr of int * int (* indtyno, constrno *)
34 type uri = Uri of int * string * spec
38 let string_of_uri (Uri (_,s,_)) = s ;;
40 module OrderedStrings =
43 let compare (s1 : t) (s2 : t) = compare s1 s2
47 module MapStringsToUri = Map.Make(OrderedStrings);;
49 let set_of_uri = ref MapStringsToUri.empty;;
51 (* '.' not allowed in path and foo
53 * Decl cic:/path/foo.decl
54 * Def cic:/path/foo.def
55 * Fix of int * int cic:/path/foo.fix(i,j)
56 * CoFix of int cic:/path/foo.cofix(i)
57 * Ind of int cic:/path/foo.ind(i)
58 * Constr of int * int cic:/path/foo.constr(i,j)
61 let uri_of_string_aux =
62 let counter = ref 0 in fun s ->
65 let sharp = String.rindex s '#' in
66 let pre = String.sub s 0 sharp in
67 let ind = String.sub s (sharp+12) (String.length s - (sharp+13)) in
69 let slash = String.rindex ind '/' in
70 let indno = String.sub ind 0 slash in
71 let constr = String.sub ind (slash+1) (String.length ind - (slash+1)) in
72 Uri(!counter,pre,Some(int_of_string indno-1,Some(int_of_string constr-1)))
73 with Not_found -> Uri (!counter,pre,Some (int_of_string ind-1, None))
74 with Not_found -> Uri (!counter,s,None)
79 MapStringsToUri.find s !set_of_uri
81 let new_uri = uri_of_string_aux s in
82 set_of_uri := MapStringsToUri.add s new_uri !set_of_uri;
86 let nuri_of_ouri u indinfo =
87 uri_of_string (string_of_uri (Uri(0,UriManager.string_of_uri u,indinfo)))
91 UriManager.uri_of_string (string_of_uri u)