Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file caqti_type.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153(* Copyright (C) 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/>.
*)type_field=..type_field+=|Bool:boolfield|Int:intfield|Int32:int32field|Int64:int64field|Float:floatfield|String:stringfield|Octets:stringfield|Pdate:Ptime.tfield|Ptime:Ptime.tfieldmoduleField=structtype'at='afieldtypeex=Ex:'at->extype_coding=Coding:{rep:'bt;encode:'a->('b,string)result;decode:'b->('a,string)result;}->'acodingtypeget_coding={get_coding:'a.Caqti_driver_info.t->'at->'acoding}letcoding_ht:(extension_constructor,get_coding)Hashtbl.t=Hashtbl.create11letdefine_codingftget=letec=Obj.extension_constructorftinHashtbl.addcoding_htecgetletcodingdift=letec=Obj.extension_constructorftintrySome((Hashtbl.findcoding_htec).get_codingdift)withNot_found->Noneletto_string:typea.afield->string=function|Bool->"bool"|Int->"int"|Int32->"int32"|Int64->"int64"|Float->"float"|String->"string"|Octets->"octets"|Pdate->"pdate"|Ptime->"ptime"|ft->Obj.extension_name(Obj.extension_constructorft)endtype_t=|Unit:unitt|Field:'afield->'at|Option:'at->'aoptiont|Tup2:'a0t*'a1t->('a0*'a1)t|Tup3:'a0t*'a1t*'a2t->('a0*'a1*'a2)t|Tup4:'a0t*'a1t*'a2t*'a3t->('a0*'a1*'a2*'a3)t|Custom:{rep:'bt;encode:'a->('b,string)result;decode:'b->('a,string)result;}->'attypeex=Ex:'at->exletreclength:typea.at->int=function|Unit->0|Field_->1|Optiont->lengtht|Tup2(t0,t1)->lengtht0+lengtht1|Tup3(t0,t1,t2)->lengtht0+lengtht1+lengtht2|Tup4(t0,t1,t2,t3)->lengtht0+lengtht1+lengtht2+lengtht3|Custom{rep;_}->lengthrepletrecpp_at:typea.int->Format.formatter->at->unit=funprecppf->function|Unit->Format.pp_print_stringppf"unit"|Fieldft->Format.pp_print_stringppf(Field.to_stringft)|Optiont->pp_at1ppft;Format.pp_print_stringppf" option"|Tup2(t0,t1)->ifprec>0thenFormat.pp_print_charppf'(';pp_at1ppft0;Format.pp_print_stringppf" × ";pp_at1ppft1;ifprec>0thenFormat.pp_print_charppf')'|Tup3(t0,t1,t2)->ifprec>0thenFormat.pp_print_charppf'(';pp_at1ppft0;Format.pp_print_stringppf" × ";pp_at1ppft1;Format.pp_print_stringppf" × ";pp_at1ppft2;ifprec>0thenFormat.pp_print_charppf')'|Tup4(t0,t1,t2,t3)->ifprec>0thenFormat.pp_print_charppf'(';pp_at1ppft0;Format.pp_print_stringppf" × ";pp_at1ppft1;Format.pp_print_stringppf" × ";pp_at1ppft2;Format.pp_print_stringppf" × ";pp_at1ppft3;ifprec>0thenFormat.pp_print_charppf')'|Custom{rep;_}->Format.pp_print_stringppf"</";pp_at0ppfrep;Format.pp_print_stringppf"/>"letppppf=pp_at1ppfletpp_exppf(Ext)=pp_at1ppftletshowt=letbuf=Buffer.create64inletppf=Format.formatter_of_bufferbufinppppft;Format.pp_print_flushppf();Buffer.contentsbufletunit=Unitletfieldft=Fieldftletoptiont=Optiontlettup2t0t1=Tup2(t0,t1)lettup3t0t1t2=Tup3(t0,t1,t2)lettup4t0t1t2t3=Tup4(t0,t1,t2,t3)letcustom~encode~decoderep=Custom{rep;encode;decode}letbool=FieldBoolletint=FieldIntletint32=FieldInt32letint64=FieldInt64letfloat=FieldFloatletstring=FieldStringletoctets=FieldOctetsletpdate=FieldPdateletptime=FieldPtime