Xbase Class Library
2.0.0
Main Page
Classes
Files
File List
File Members
xbase
ntx.h
Go to the documentation of this file.
1
/* $Id: ntx.h,v 1.5 2000/11/10 19:04:17 dbryson Exp $
2
3
Xbase project source code
4
5
This file contains a header file for the xbNdx object, which is used
6
for handling xbNdx type indices.
7
8
Copyright (C) 1997 StarTech, Gary A. Kunkel
9
10
This library is free software; you can redistribute it and/or
11
modify it under the terms of the GNU Lesser General Public
12
License as published by the Free Software Foundation; either
13
version 2.1 of the License, or (at your option) any later version.
14
15
This library is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
Lesser General Public License for more details.
19
20
You should have received a copy of the GNU Lesser General Public
21
License along with this library; if not, write to the Free Software
22
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
24
Contact:
25
26
Mail:
27
28
Technology Associates, Inc.
29
XBase Project
30
1455 Deming Way #11
31
Sparks, NV 89434
32
USA
33
34
Email:
35
36
xbase@techass.com
37
38
See our website at:
39
40
xdb.sourceforge.net
41
42
43
V 1.0 10/10/97 - Initial release of software
44
*/
45
46
#ifndef __XB_NTX_H__
47
#define __XB_NTX_H__
48
49
#ifdef __GNUG__
50
#pragma interface
51
#endif
52
53
#include <
xbase/xbase.h
>
54
#include <string.h>
55
59
#define XB_NTX_NODE_SIZE 1024
60
62
65
struct
NtxHeadNode
{
/* ntx header on disk */
66
xbUShort
Signature
;
/* Clipper 5.x or Clipper 87 */
67
xbUShort
Version
;
/* Compiler Version */
68
/* Also turns out to be a last modified counter */
69
xbLong
StartNode
;
/* Offset in file for first index */
70
xbULong
UnusedOffset
;
/* First free page offset */
71
xbUShort
KeySize
;
/* Size of items (KeyLen + 8) */
72
xbUShort
KeyLen
;
/* Size of the Key */
73
xbUShort
DecimalCount
;
/* Number of decimal positions */
74
xbUShort
KeysPerNode
;
/* Max number of keys per page */
75
xbUShort
HalfKeysPerNode
;
/* Min number of keys per page */
76
char
KeyExpression
[256];
/* Null terminated key expression */
77
unsigned
Unique
;
/* Unique Flag */
78
char
NotUsed
[745];
79
};
80
82
85
struct
NtxLeafNode
{
/* ndx node on disk */
86
xbUShort
NoOfKeysThisNode
;
87
char
KeyRecs
[
XB_NTX_NODE_SIZE
];
88
};
89
90
92
95
struct
NtxItem
96
{
97
xbULong
Node
;
98
xbULong
RecordNumber
;
99
char
Key
[256];
100
};
101
103
106
struct
xbNodeLink
{
/* ndx node memory */
107
xbNodeLink
*
PrevNode
;
108
xbNodeLink
*
NextNode
;
109
xbUShort
CurKeyNo
;
/* 0 - KeysPerNode-1 */
110
xbLong
NodeNo
;
111
struct
NtxLeafNode
Leaf
;
112
xbUShort
*
offsets
;
113
};
114
116
119
class
XBDLLEXPORT
xbNtx
:
public
xbIndex
{
120
public
:
121
NtxHeadNode
HeadNode
;
122
NtxLeafNode
LeafNode
;
123
xbLong
NodeLinkCtr
;
124
xbLong
ReusedNodeLinks
;
125
126
char
Node[
XB_NTX_NODE_SIZE
];
127
128
xbNodeLink
*
NodeChain
;
/* pointer to node chain of index nodes */
129
xbNodeLink
*
FreeNodeChain
;
/* pointer to chain of free index nodes */
130
xbNodeLink
*
CurNode
;
/* pointer to current node */
131
xbNodeLink
*
DeleteChain
;
/* pointer to chain to delete */
132
xbNodeLink
*
CloneChain
;
/* pointer to node chain copy (add dup) */
133
134
NtxItem
PushItem
;
135
136
/* private functions */
137
xbLong
GetLeftNodeNo(
xbShort
,
xbNodeLink
* );
138
xbShort
CompareKey(
const
char
*,
const
char
*,
xbShort
);
139
xbShort
CompareKey(
const
char
*,
const
char
* );
140
xbLong
GetDbfNo(
xbShort
,
xbNodeLink
* );
141
char
* GetKeyData(
xbShort
,
xbNodeLink
* );
142
xbUShort
GetItemOffset (
xbShort
,
xbNodeLink
*,
xbShort
);
143
xbUShort
InsertKeyOffset (
xbShort
,
xbNodeLink
* );
144
xbUShort
GetKeysPerNode(
void
);
145
xbShort
GetHeadNode(
void
);
146
xbShort
GetLeafNode(
xbLong
,
xbShort
);
147
xbNodeLink
* GetNodeMemory(
void
);
148
xbLong
GetNextNodeNo(
void
);
149
void
ReleaseNodeMemory(
xbNodeLink
* );
150
xbULong
GetLeafFromInteriorNode(
const
char
*,
xbShort
);
151
xbShort
CalcKeyLen(
void
);
152
xbShort
PutKeyData(
xbShort
,
xbNodeLink
* );
153
xbShort
PutLeftNodeNo(
xbShort
,
xbNodeLink
*,
xbLong
);
154
xbShort
PutLeafNode(
xbLong
,
xbNodeLink
* );
155
xbShort
PutHeadNode(
NtxHeadNode
*, FILE *,
xbShort
);
156
xbShort
TouchIndex
(
void
);
157
xbShort
PutDbfNo(
xbShort
,
xbNodeLink
*,
xbLong
);
158
xbShort
PutKeyInNode(
xbNodeLink
*,
xbShort
,
xbLong
,
xbLong
,
xbShort
);
159
xbShort
SplitLeafNode(
xbNodeLink
*,
xbNodeLink
*,
xbShort
,
xbLong
);
160
xbShort
SplitINode(
xbNodeLink
*,
xbNodeLink
*,
xbLong
);
161
xbShort
AddToIxList(
void
);
162
xbShort
RemoveFromIxList(
void
);
163
xbShort
RemoveKeyFromNode(
xbShort
,
xbNodeLink
* );
164
xbShort
DeleteKeyFromNode(
xbShort
,
xbNodeLink
* );
165
xbShort
JoinSiblings(
xbNodeLink
*,
xbShort
,
xbNodeLink
*,
xbNodeLink
*);
166
xbUShort
DeleteKeyOffset(
xbShort
,
xbNodeLink
*);
167
xbShort
FindKey
(
const
char
*,
xbShort
,
xbShort
);
168
xbShort
UpdateParentKey(
xbNodeLink
* );
169
xbShort
GetFirstKey
(
xbShort
);
170
xbShort
GetNextKey
(
xbShort
);
171
xbShort
GetLastKey
(
xbLong
,
xbShort
);
172
xbShort
GetPrevKey
(
xbShort
);
173
void
UpdateDeleteList(
xbNodeLink
* );
174
void
ProcessDeleteList(
void
);
175
// xbNodeLink * LeftSiblingHasSpace( xbNodeLink * );
176
// xbNodeLink * RightSiblingHasSpace( xbNodeLink * );
177
// xbShort DeleteSibling( xbNodeLink * );
178
// xbShort MoveToLeftNode( xbNodeLink *, xbNodeLink * );
179
// xbShort MoveToRightNode( xbNodeLink *, xbNodeLink * );
180
xbShort
FindKey
(
const
char
*,
xbLong
);
/* for a specific dbf no */
181
182
xbShort
CloneNodeChain(
void
);
/* test */
183
xbShort
UncloneNodeChain(
void
);
/* test */
184
185
186
187
xbNtx
() :
xbIndex
() {}
188
xbNtx
(
xbDbf
* );
189
190
/* note to gak - don't uncomment next line - it causes seg faults */
191
// ~NTX() { if( NtxStatus ) CloseIndex(); }
192
193
xbShort
OpenIndex
(
const
char
* );
194
xbShort
CloseIndex
(
void
);
195
void
DumpHdrNode (
void
);
196
void
DumpNodeRec (
xbLong
);
197
xbShort
CreateIndex
(
const
char
*,
const
char
*,
xbShort
,
xbShort
);
198
xbLong
GetTotalNodes
(
void
);
199
xbLong
GetCurDbfRec
(
void
) {
return
CurDbfRec
; }
200
void
DumpNodeChain(
void
);
201
xbShort
CreateKey
(
xbShort
,
xbShort
);
202
xbShort
GetCurrentKey
(
char
*key);
203
xbShort
AddKey
(
xbLong
);
204
xbShort
UniqueIndex
(
void
) {
return
HeadNode.Unique; }
205
xbShort
DeleteKey
(
xbLong
DbfRec );
206
xbShort
KeyWasChanged
(
void
);
207
xbShort
FindKey
(
const
char
* );
208
xbShort
FindKey
(
void
);
209
xbShort
FindKey
(
xbDouble
);
210
#ifdef XBASE_DEBUG
211
xbShort
CheckIndexIntegrity(
const
xbShort
Option );
212
#endif
213
xbShort
GetNextKey
(
void
) {
return
GetNextKey
( 1 ); }
214
xbShort
GetLastKey
(
void
) {
return
GetLastKey
( 0, 1 ); }
215
xbShort
GetFirstKey
(
void
) {
return
GetFirstKey
( 1 ); }
216
xbShort
GetPrevKey
(
void
) {
return
GetPrevKey
( 1 ); }
217
xbShort
ReIndex
(
void
(*statusFunc)(
xbLong
itemNum,
xbLong
numItems) = 0) ;
218
xbShort
KeyExists
(
char
* Key ) {
return
FindKey
( Key, strlen( Key ), 0 ); }
219
xbShort
KeyExists
(
xbDouble
);
220
221
xbShort
AllocKeyBufs(
void
);
222
223
virtual
void
GetExpression
(
char
*buf,
int
len);
224
};
225
#endif
/* __XB_NTX_H__ */
Generated by
1.8.2