12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364(* Ocsigen
* Copyright (C) 2010 Vincent Balat
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)moduleMap_path=Map.Make(structtypet=stringlistletcompare=compareend)moduleMap_inner=Map.Make(String)typecookie=|OSetoffloatoption*string*bool|OUnsettypet=cookieMap_inner.tMap_path.tletempty=Map_path.emptyletadd~pathnvm=letm'=tryMap_path.findpathmwithNot_found->Map_inner.emptyin(* We replace the old value if it exists *)Map_path.addpath(Map_inner.addnvm')m(* [add_multi new old] adds the cookies from [new] to [old]. If
cookies are already bound in oldcookies, the previous binding
disappear. *)letadd_multi=Map_path.fold@@funpath->Map_inner.fold@@funnvbeg->matchvwith|OSet(expo,v,secure)->add~pathn(OSet(expo,v,secure))beg|OUnset->add~pathnOUnsetbegletremove~pathnm=tryletm'=Map_path.findpathminletm'=Map_inner.removenm'inifMap_inner.is_emptym'thenMap_path.removepathmelse(* We replace the old value *)Map_path.addpathm'mwithNot_found->mmodulePoly=structletadd=addletremove=removeend