123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263(* Copyright (C) 2014--2017 Petter A. Urkedal <paurkedal@gmail.com>
*
* This library 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, either version 3 of the License, or (at your
* option) any later version, with the OCaml static compilation exception.
*
* This library 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 library. If not, see <http://www.gnu.org/licenses/>.
*)typetypedesc=[`Bool|`Int|`Float|`String|`Bytes|`Date|`Utc|`Otherofstring|`Unknown]typequerydesc={querydesc_params:typedescarray;querydesc_fields:(string*typedesc)array;}letstring_of_typedesc=function|`Bool->"bool"|`Int->"int"|`Float->"float"|`String->"string"|`Bytes->"bytes"|`Date->"date"|`Utc->"utc"|`Others->s|`Unknown->"unknown"letstring_of_querydescqd=letbuf=Buffer.create256inifArray.lengthqd.querydesc_params=0thenBuffer.add_stringbuf"unit"elseArray.iteri(funitd->ifi<>0thenBuffer.add_stringbuf" * ";Buffer.add_stringbuf(string_of_typedesctd))qd.querydesc_params;Buffer.add_stringbuf" -> {";Array.iteri(funi(name,td)->ifi<>0thenBuffer.add_stringbuf"; ";Buffer.add_stringbufname;Buffer.add_stringbuf": ";Buffer.add_stringbuf(string_of_typedesctd))qd.querydesc_fields;Buffer.add_charbuf'}';Buffer.contentsbuf