package dbase4

  1. Overview
  2. Docs

Module Dbase4.BaseSource

Sourcetype dbf_file = {
  1. name : string;
    (*

    name of table (.dbf)

    *)
  2. fin : in_channel;
    (*

    opened i/o stream for dbf file

    *)
  3. memo : in_channel option;
    (*

    optional i/o stream for memo file - if exists

    *)
  4. info : dbf_info;
    (*

    description of DBF table

    *)
  5. cri : int;
    (*

    Current Rider Index - ID of current record in the table

    *)
}

DBF file handle

Sourceand dbf_info = {
  1. version : int;
    (*

    version of the file format

    *)
  2. mdate : date;
    (*

    modification date

    *)
  3. num_records : int;
    (*

    number of records

    *)
  4. hdr_size : int;
    (*

    file header size (in bytes)

    *)
  5. rec_size : int;
    (*

    file record size (in bytes)

    *)
  6. fields : dbf_field_descriptor array;
    (*

    fields descriptors

    *)
}

descriptor of the internal dbf file layout

Sourceand date = {
  1. year : int;
  2. month : int;
  3. day : int;
}

primitive structure to hold date

Sourceand dbf_field_descriptor = {
  1. name : string;
    (*

    name of field

    *)
  2. ftype : dbf_data_type;
    (*

    DBF data type

    *)
  3. faddr : int;
    (*

    address of field - it's using as offset in the raw record

    *)
  4. flen : int;
    (*

    length of field

    *)
  5. fdec : int;
    (*

    number after point for number data type

    *)
  6. work_area_id : int;
    (*

    reserved

    *)
  7. flags : int;
    (*

    some flags (not used)

    *)
}

DBF field descriptor

Sourceand dbf_data_type =
  1. | Character
    (*

    character (flen = 1) or string

    *)
  2. | Number
    (*

    number: integer (fdec = 0) or fixed point real

    *)
  3. | Float
    (*

    32-bits floating point number

    *)
  4. | Date
    (*

    date

    *)
  5. | Logical
    (*

    boolean / logical value

    *)
  6. | Memo
    (*

    Text Large Object or Binary Large Object

    *)
  7. | General of int
    (*

    user-defined

    *)

internal DBF data type

Sourceexception DbfDataInvalid of string

Exception means: internal data representation is invalid

Sourceval dbf_open : string -> dbf_file

open DBF-file

Sourceval dbf_close : dbf_file -> unit

close DBF-file

Sourceval db_goto : dbf_file -> int -> dbf_file

move cursor to the n-th record, absolute

Sourceval db_skip : dbf_file -> int -> dbf_file

move cursor to the record after n-th records from the current, relative

Sourceval db_go_top : dbf_file -> dbf_file

move to the first record

Sourceval db_go_bottom : dbf_file -> dbf_file

move to the last record

Sourceval db_bof : dbf_file -> bool

check the end of file

Sourceval db_has_memo_fields : dbf_file -> bool

check either has MEMO-extention or not

Sourceval db_memo_exists : string -> string option
Sourceval read_record : ?with_deleted:bool -> dbf_file -> bool * bytes

read raw (undecoded) record

Sourceval iterator : dbf_file -> (int * bool * bytes) Seq.t

make an iterartor over all records

Sourceval all_records : dbf_file -> bytes Seq.t

make an iterartor over all existed (not deleted) records

Sourceval string_of_zstring : string -> string

FOR INTERNAL USE ONLY - translate binary ASCIIZ-string

Sourceval read_chunk : In_channel.t -> int -> bytes

FOR INTERNAL USE ONLY - read chunk of data from the file

OCaml

Innovation. Community. Security.