File: dbf\db_file_io.ads
1 --::::::::::
2 --dbfileio.ads
3 --::::::::::
4 -- Developed by (C) Wasiliy W. Molostoff 1994, 1995.
5 -- Moscow, Russia,
6 -- Voice: 7 (095) 398-23-38
7 -- e-mail: edv@edv.msk.ru
8 -- This is free software; you can freely redistribute it and/or
9 -- modify it without any restrictions. Please report any errors.
10 -- All corrections will be made as soon as possible.
11 with unsigned, unsigned_io, calendar, io_exceptions;
12 use unsigned, calendar, unsigned_io;
13
14 package db_file_io is
15
16 type file_type is limited private;
17 type file_mode is new unsigned_io.file_mode range in_file..inout_file;
18
19 type count is new unsigned_io.count;
20 subtype positive_count is count range 1..count'last;
21
22 type row_attribute is new byte;
23 type col_attribute is new byte;
24 type tab_attribute is new byte;
25
26 type col_stat is
27 record
28 attrib : col_attribute; -- attribute (tag)
29 length : natural; -- length of the column
30 align : natural; -- abstract alignment of column data
31 end record;
32
33 type table is array (positive range <>) of col_stat;
34
35 procedure get_table (file: in file_type; tab: in out table);
36
37 procedure create (file : in out file_type;
38 cols : in table;
39 attr : in tab_attribute;
40 name : in string := "";
41 form : in string := "");
42
43 procedure open (file: in out file_type;
44 mode: in file_mode;
45 name: in string;
46 form: in string := "");
47
48 procedure close (file: in out file_type);
49 procedure reset (file: in out file_type; mode: in file_mode);
50 procedure reset (file: in out file_type);
51
52 function mode (file: in file_type) return file_mode;
53 function name (file: in file_type) return string;
54 function form (file: in file_type) return string;
55 function is_open (file: in file_type) return boolean;
56
57 procedure tab_attrib (file: in out file_type; new_attr: in tab_attribute);
58 function tab_attrib (file: in file_type) return tab_attribute;
59 function tab_length (file: in file_type) return count;
60 function tab_updated (file: in file_type) return time;
61
62
63 procedure row_attrib (file: in out file_type; new_attr: in row_attribute);
64 function row_attrib (file: in file_type) return row_attribute;
65 function row_length (file: in file_type) return natural;
66 procedure row_index (file: in out file_type; to: in positive_count);
67 function row_index (file: in file_type) return positive_count;
68
69 procedure write (file: in out file_type;
70 buff: in byte_string;
71 attr: in row_attribute);
72
73 procedure read (file: in out file_type;
74 buff: out byte_string;
75 attr: out row_attribute);
76
77 procedure col_align (file: in out file_type;
78 col: in positive;
79 new_align: in natural);
80
81 procedure col_attrib (file: in out file_type;
82 col: in positive;
83 new_attr: in col_attribute);
84
85 procedure col_name (file: in out file_type;
86 col: in positive;
87 new_name: in string);
88
89 function col_align (file: in file_type; from: in positive) return natural;
90 function col_attrib (file: in file_type; from: in positive) return col_attribute;
91 function col_name (file: in file_type; from: in positive) return string;
92
93 function col_index (file: in file_type; from: in string) return natural;
94 function col_count (file: in file_type) return positive;
95 function col_length (file: in file_type; from: in positive) return natural;
96
97 procedure get (file: in out file_type;
98 col: in positive;
99 buf: out byte_string);
100
101 procedure put (file: in out file_type;
102 col: in positive;
103 buf: in byte_string);
104
105 status_error : exception renames io_exceptions.status_error;
106 mode_error : exception renames io_exceptions.mode_error;
107 name_error : exception renames io_exceptions.name_error;
108 use_error : exception renames io_exceptions.use_error;
109 device_error : exception renames io_exceptions.device_error;
110 end_error : exception renames io_exceptions.end_error;
111 data_error : exception renames io_exceptions.data_error;
112
113 private
114
115 type file_object;
116 type file_type is access file_object;
117
118 end db_file_io;
119