dbfwork: 'to_number(x)' is treated as simply 'x'
[ocaml-dbf.git] / mlxbase.mli
blobaa68e5158f670d9fee82aa4dbadfcaa3a499a03d
1 (** OCaml xBase *)
3 (** type of column in dbf file *)
4 type col_type =
5 [ CT_Character | CT_Number | CT_Logical | CT_Date | CT_Memo | CT_Float
6 | CT_Binary | CT_General | CT_Picture | CT_Currency | CT_Datetime
7 | CT_Integer | CT_Varifield | CT_VariantX | CT_Timestamp | CT_Double
8 | CT_Autoincrement | CT_NullFlags
13 (** column specification *)
14 type col_spec =
15 { col_name : string
16 ; col_type : col_type
17 ; field_size : int
18 ; field_decim : int
23 exception Bad_format of string;
25 (** abstract type for reading dbf files *)
26 type dbf_reader
29 type xbase_hint =
30 [ IgnoreDeletedFlag
32 (** Ignore the "deleted record" flag, which specifies whether
33 each particular data record is deleted or not.
35 Try it if you get "bad deleted_flag" exceptions.
39 (** [open_reader ~decode filename] opens dbf file [filename] for reading.
40 Every field's value will be decoded with [decode] function (default
41 [decode] doesn't modify the values).
43 value open_reader : ?decode:(string -> string) -> ?hints:list xbase_hint -> string -> dbf_reader
47 value get_reader_codepage : dbf_reader -> string
51 (** [reader_with_decoder new_decoder dbf_reader] returns [dbf_reader] with
52 new decoder.
54 value reader_with_decoder : (string -> string) -> dbf_reader -> dbf_reader
58 (** reads one record from dbf.
59 @raise End_of_file on end of file
60 @raise Bad_format on bad format
62 may raise other input exceptions.
64 value read_record : dbf_reader -> list string
67 value close_reader : dbf_reader -> unit
70 value colspecs_of_reader : dbf_reader -> list col_spec
73 (** @return codepage in textual representation.
74 warning: for unknown codepages the return value looks like
75 "language_driver_0x%02x", which is not acceptable for
76 [open_writer].
78 todo: represent codepage as sum type like
79 [ CP_866 | CP_1251 | ... | Unknown of int ]
81 value codepage_of_reader : dbf_reader -> string
85 (** abstract type for writing dbf files *)
86 type dbf_writer
89 (** [open_writer ~encode filename col_specs codepage]
90 For now, only these codepages can be written into dbf header:
91 "437", "850", "1252", "852", "865", "866", "437G", "1250", "1251".
92 Every field's value will be encoded with [encode] function (default
93 [encode] doesn't modify the values).
95 value open_writer :
96 ?encode:(string -> string)
97 -> string -> list col_spec -> string ->
98 dbf_writer
101 value write_record : dbf_writer -> list string -> unit
104 value close_writer : dbf_writer -> unit
107 value char_of_coltype : col_type -> char
111 (** tries to fix broken dbf *)
112 value dbf_fix : string -> unit