Xbase64 Class Library
3.1.2
Main Page
Classes
Files
File List
File Members
xbase64
xbntx.h
Go to the documentation of this file.
1
/* xbntx.h
2
3
Xbase64 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,2003 Bob Cotton
9
10
This program is free software; you can redistribute it and/or modify
11
it under the terms of the GNU Lesser General Public License as published by
12
the Free Software Foundation; either version 2 of the License, or
13
(at your option) any later version.
14
15
This program 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
18
GNU Lesser General Public License for more details.
19
20
You should have received a copy of the GNU Lesser General Public License
21
along with this program; if not, write to the Free Software
22
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
24
25
Contact:
26
27
Email:
28
29
xdb-devel@lists.sourceforge.net
30
xdb-users@lists.sourceforge.net
31
32
33
Regular Mail:
34
35
XBase Support
36
149C South Main St
37
Keller Texas, 76248
38
USA
39
40
*/
41
42
#ifndef __XB_NTX_H__
43
#define __XB_NTX_H__
44
45
#ifdef __GNU_LesserG__
46
#pragma interface
47
#endif
48
49
#include <
xbase64/xbase64.h
>
50
#include <string.h>
51
55
#define XB_NTX_NODE_SIZE 1024
56
58
61
struct
NtxHeadNode
{
/* ntx header on disk */
62
xbUShort
Signature
;
/* Clipper 5.x or Clipper 87 */
63
xbUShort
Version
;
/* Compiler Version */
64
/* Also turns out to be a last modified counter */
65
xbLong
StartNode
;
/* Offset in file for first index */
66
xbULong
UnusedOffset
;
/* First free page offset */
67
xbUShort
KeySize
;
/* Size of items (KeyLen + 8) */
68
xbUShort
KeyLen
;
/* Size of the Key */
69
xbUShort
DecimalCount
;
/* Number of decimal positions */
70
xbUShort
KeysPerNode
;
/* Max number of keys per page */
71
xbUShort
HalfKeysPerNode
;
/* Min number of keys per page */
72
char
KeyExpression
[256];
/* Null terminated key expression */
73
unsigned
Unique
;
/* Unique Flag */
74
char
NotUsed
[745];
75
};
76
78
81
struct
NtxLeafNode
{
/* ndx node on disk */
82
xbUShort
NoOfKeysThisNode
;
83
char
KeyRecs
[
XB_NTX_NODE_SIZE
];
84
};
85
86
88
91
struct
NtxItem
92
{
93
xbULong
Node
;
94
xbULong
RecordNumber
;
95
char
Key
[256];
96
};
97
99
102
struct
xbNodeLink
{
/* ndx node memory */
103
xbNodeLink
*
PrevNode
;
104
xbNodeLink
*
NextNode
;
105
xbUShort
CurKeyNo
;
/* 0 - KeysPerNode-1 */
106
xbLong
NodeNo
;
107
struct
NtxLeafNode
Leaf
;
108
xbUShort
*
offsets
;
109
};
110
112
115
class
XBDLLEXPORT
xbNtx
:
public
xbIndex
116
{
117
protected
:
118
NtxHeadNode
HeadNode
;
119
NtxLeafNode
LeafNode
;
120
xbLong
NodeLinkCtr
;
121
xbLong
ReusedNodeLinks
;
122
char
Node[
XB_NTX_NODE_SIZE
];
123
xbNodeLink
*
NodeChain
;
/* pointer to node chain of index nodes */
124
xbNodeLink
*
FreeNodeChain
;
/* pointer to chain of free index nodes */
125
xbNodeLink
*
CurNode
;
/* pointer to current node */
126
xbNodeLink
*
DeleteChain
;
/* pointer to chain to delete */
127
// xbNodeLink * CloneChain; /* pointer to node chain copy (add dup) */
128
NtxItem
PushItem
;
129
130
/* private functions */
131
xbLong
GetLeftNodeNo(
xbShort
,
xbNodeLink
* );
132
xbShort
CompareKey(
const
char
*,
const
char
*,
xbShort
);
133
xbShort
CompareKey(
const
char
*,
const
char
* );
134
xbLong
GetDbfNo(
xbShort
,
xbNodeLink
* );
135
char
* GetKeyData(
xbShort
,
xbNodeLink
* );
136
xbUShort
GetItemOffset (
xbShort
,
xbNodeLink
*,
xbShort
);
137
xbUShort
InsertKeyOffset (
xbShort
,
xbNodeLink
* );
138
xbUShort
GetKeysPerNode();
139
virtual
xbShort
GetHeadNode
();
140
xbShort
GetLeafNode(
xbLong
,
xbShort
);
141
xbNodeLink
* GetNodeMemory();
142
xbLong
GetNextNodeNo();
143
void
ReleaseNodeMemory(
xbNodeLink
*n,
xbBool
doFree =
false
);
144
xbULong
GetLeafFromInteriorNode(
const
char
*,
xbShort
);
145
xbShort
CalcKeyLen();
146
xbShort
PutKeyData(
xbShort
,
xbNodeLink
* );
147
xbShort
PutLeftNodeNo(
xbShort
,
xbNodeLink
*,
xbLong
);
148
xbShort
PutLeafNode(
xbLong
,
xbNodeLink
* );
149
xbShort
PutHeadNode(
NtxHeadNode
*, FILE *,
xbShort
);
150
xbShort
TouchIndex
();
151
xbShort
PutDbfNo(
xbShort
,
xbNodeLink
*,
xbLong
);
152
xbShort
PutKeyInNode(
xbNodeLink
*,
xbShort
,
xbLong
,
xbLong
,
xbShort
);
153
xbShort
SplitLeafNode(
xbNodeLink
*,
xbNodeLink
*,
xbShort
,
xbLong
);
154
xbShort
SplitINode(
xbNodeLink
*,
xbNodeLink
*,
xbLong
);
155
xbShort
AddToIxList();
156
xbShort
RemoveFromIxList();
157
xbShort
RemoveKeyFromNode(
xbShort
,
xbNodeLink
* );
158
xbShort
DeleteKeyFromNode(
xbShort
,
xbNodeLink
* );
159
xbShort
JoinSiblings(
xbNodeLink
*,
xbShort
,
xbNodeLink
*,
xbNodeLink
*);
160
xbUShort
DeleteKeyOffset(
xbShort
,
xbNodeLink
*);
161
xbShort
FindKey
(
const
char
*,
xbShort
,
xbShort
);
162
xbShort
UpdateParentKey(
xbNodeLink
* );
163
xbShort
GetFirstKey
(
xbShort
);
164
xbShort
GetNextKey
(
xbShort
);
165
xbShort
GetLastKey
(
xbLong
,
xbShort
);
166
xbShort
GetPrevKey
(
xbShort
);
167
void
UpdateDeleteList(
xbNodeLink
* );
168
void
ProcessDeleteList();
169
xbShort
FindKey
(
const
char
*,
xbLong
);
/* for a specific dbf no */
170
171
public
:
172
xbNtx
();
173
xbNtx
(
xbDbf
*);
174
virtual
~
xbNtx
();
175
176
/* note to gak - don't uncomment next line - it causes seg faults */
177
// ~NTX() { if( NtxStatus ) CloseIndex(); }
178
179
void
DumpHdrNode (
xbShort
Option );
180
void
DumpNodeRec (
xbLong
);
181
xbShort
CreateIndex
(
const
char
*,
const
char
*,
xbShort
,
xbShort
);
182
xbLong
GetTotalNodes
();
183
xbULong
GetCurDbfRec
() {
return
CurDbfRec
; }
184
void
DumpNodeChain();
185
xbShort
CreateKey
(
xbShort
,
xbShort
);
186
xbShort
GetCurrentKey
(
char
*key);
187
xbShort
AddKey
(
xbLong
);
188
xbShort
UniqueIndex
() {
return
HeadNode.Unique; }
189
xbShort
DeleteKey
(
xbLong
DbfRec );
190
xbShort
KeyWasChanged
();
191
xbShort
FindKey
(
const
char
* );
192
xbShort
FindKey
();
193
xbShort
FindKey
(
xbDouble
);
194
xbShort
GetNextKey
() {
return
GetNextKey
( 1 ); }
195
xbShort
GetLastKey
() {
return
GetLastKey
( 0, 1 ); }
196
xbShort
GetFirstKey
() {
return
GetFirstKey
( 1 ); }
197
xbShort
GetPrevKey
() {
return
GetPrevKey
( 1 ); }
198
xbShort
ReIndex
(
void
(*statusFunc)(
xbLong
itemNum,
xbLong
numItems) = 0) ;
199
xbShort
KeyExists
(
char
* Key ) {
return
FindKey
( Key, strlen( Key ), 0 ); }
200
xbShort
KeyExists
(
xbDouble
);
201
virtual
void
GetExpression
(
char
*buf,
int
len);
202
#ifdef XBASE_DEBUG
203
xbShort
CheckIndexIntegrity(
xbShort
Option );
204
#endif
205
206
virtual
const
char
*
GetExtWithDot
(
bool
lower);
207
208
protected
:
209
virtual
xbUShort
GetKeyLen
();
210
virtual
const
char
*
GetKeyExpression
();
211
virtual
void
FreeNodesMemory
();
212
};
213
#endif
/* __XB_NTX_H__ */
Generated by
1.8.3.1