Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / lib / tt / lib / db / tt_client_isam_key_descriptor.C
1 //%%  (c) Copyright 1993, 1994 Hewlett-Packard Company                  
2 //%%  (c) Copyright 1993, 1994 International Business Machines Corp.    
3 //%%  (c) Copyright 1993, 1994 Sun Microsystems, Inc.                   
4 //%%  (c) Copyright 1993, 1994 Novell, Inc.                             
5 //%%  $XConsortium: tt_client_isam_key_descriptor.C /main/3 1995/10/23 09:59:42 rswiston $                                                      
6 /*
7  * tt_client_isam_key_descriptor.cc - Defines the TT ISAM key descriptor class.
8  *                  This class is used to hold the information required
9  *                  to create a NetISAM key descriptor.  It also makes
10  *                  it very easy to construct the descriptor.
11  *
12  * Copyright (c) 1992 by Sun Microsystems, Inc.
13  */
14
15 #include "db/tt_client_isam_key_descriptor.h"
16
17 _Tt_client_isam_key_descriptor::_Tt_client_isam_key_descriptor ()
18 {
19   keyDescriptor.k_flags = 0;
20   keyDescriptor.k_nparts = 0;
21 }
22
23 _Tt_client_isam_key_descriptor::~_Tt_client_isam_key_descriptor ()
24 {
25 }
26
27 short _Tt_client_isam_key_descriptor::addKeyPart (short start, short length, short type)
28 {
29   int index = -1;
30
31   if (keyDescriptor.k_nparts < NPARTS-1) {
32     index = keyDescriptor.k_nparts;
33
34     (&keyDescriptor.k_part_0 + index)->kp_start = start;
35     (&keyDescriptor.k_part_0 + index)->kp_leng = length;
36     (&keyDescriptor.k_part_0 + index)->kp_type = type;
37
38     keyDescriptor.k_nparts++;
39   }
40
41   return index;
42 }
43
44 short _Tt_client_isam_key_descriptor::setKeyPart (short index,
45                                            short start,
46                                            short length,
47                                            short type)
48 {
49   short error = 0;
50
51   if ((index > -1) && (index < keyDescriptor.k_nparts)) {
52     (&keyDescriptor.k_part_0 + index)->kp_start = start;
53     (&keyDescriptor.k_part_0 + index)->kp_leng = length;
54     (&keyDescriptor.k_part_0 + index)->kp_type = type;
55   }
56   else {
57     error = -1;
58   }
59
60   return error;
61 }
62
63 short _Tt_client_isam_key_descriptor::getKeyPart (short  index,
64                                            short &start,
65                                            short &length,
66                                            short &type) const
67 {
68   short error = 0;
69
70   if ((index > -1) && (index < keyDescriptor.k_nparts)) {
71     
72
73     start = (&keyDescriptor.k_part_0 + index)->kp_start;
74     length = (&keyDescriptor.k_part_0 + index)->kp_leng;
75     type = (&keyDescriptor.k_part_0 + index)->kp_type;
76   }
77   else {
78     start = -1;
79     length = -1;
80     type = -1;
81     error = -1;
82   }
83
84   return error;
85 }