File: xbcdx.h

package info (click to toggle)
xbase64 3.1.2-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,844 kB
  • ctags: 2,180
  • sloc: cpp: 14,547; sh: 8,678; makefile: 112
file content (150 lines) | stat: -rwxr-xr-x 4,183 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#ifndef cdx_h
#define cdx_h

#include "xbmindex.h"

struct CdxHeader
{
  xbLong rootNode;
  xbLong freeNode;
  xbLong reserved;
  xbShort keyLen;
  union cdxFeatures
  {
    struct Features
    {
      bool unique:1;
      int:2;
      bool hasFor:1;
      bool:1;
      bool cdxHeader:1;
      bool cdxFmt:1;
      bool cdxTagHeader:1;
    } features;
    char feature;
  } features;
  char signature;
  xbLong reserved1[5];
  char reserved2[466];
  xbShort descending;
  xbShort totalExprLen;
  xbShort forExprLen;
  xbShort reserved4;
  xbShort keyExprLen;
  char keyforBuffer[512];
};

struct CdxNode
{
  xbShort attr;
  xbShort keyCount;
  xbLong leftSibling;
  xbLong rightSibling;
}
#ifdef __GNU_LesserC__
	__attribute__((packed))
#endif
;

struct CdxInnerNode: public CdxNode
{
  char keys[500];
}
#ifdef __GNU_LesserC__
	__attribute__((packed))
#endif
;

struct CdxLeafNode: public CdxNode
{
  xbShort freeSpace;
  xbLong recNumberMask;
  char dupByteCounterMask;
  char tailByteCounterMask;
  char recBitUsing;
  char dupBitUsing;
  char tailBitUsing;
  char byteCount;
  char keys[488];
} 
#ifdef __GNU_LesserC__
	__attribute__((packed))
#endif
;

class XBDLLEXPORT xbCdx: public xbMultiIndex
{
  public:
//    xbCdx() {} I don't like to make empty object with no protection 
// to method method call. And I don't see any need of it.
    xbCdx(xbDbf* dbf): xbMultiIndex(dbf) 
    {
      memset(&indexHeader_, 0, sizeof(indexHeader_));
      memset(&tagHeader_, 0, sizeof(tagHeader_));
    }

    virtual ~xbCdx() {CloseIndex();}

    virtual xbShort CreateIndex(const char *filename, const char *expr, 
         xbShort unique, xbShort overwrite);
    virtual xbShort CreateIndex(const char *filename, const char* tagname, 
         const char *expr, xbShort unique, xbShort overwrite);

    virtual xbShort AddTag(const char* tagname, const char *expr, 
         xbShort unique, xbShort overwrite) {return 0;}

    virtual xbLong   GetTotalNodes() {return 0;}
    virtual xbULong  GetCurDbfRec() {return 0;}
    virtual xbShort  CreateKey( xbShort, xbShort ) {return 0;}
    virtual xbShort  GetCurrentKey(char *key) {return 0;}
    virtual xbShort  AddKey( xbLong ) {return 0;}
    virtual xbShort  UniqueIndex() {return 0;}
    virtual xbShort  DeleteKey( xbLong ) {return 0;}
    virtual xbShort  KeyWasChanged() {return 0;}
    virtual xbShort  FindKey( const char * ) {return 0;}
    virtual xbShort  FindKey() {return 0;}
    virtual xbShort  FindKey( xbDouble ) {return 0;}
    virtual xbShort  GetNextKey() {return 0;}
    virtual xbShort  GetLastKey() {return 0;}
    virtual xbShort  GetFirstKey() {return 0;}
    virtual xbShort  GetPrevKey() {return 0;}
    virtual xbShort  ReIndex(void (*statusFunc)(xbLong itemNum, xbLong numItems) = 0) {return 0;}
    virtual xbShort  KeyExists( xbDouble ) {return 0;}
    virtual void     GetExpression(char *buf, int len) {}
#ifdef XBASE_DEBUG
    virtual void     DumpHdrNode( xbShort Option ) {};
    virtual void     DumpNodeRec( xbLong ) {};
    virtual void     DumpNodeChain() {};
    virtual xbShort  CheckIndexIntegrity( xbShort ) {return 0;};
#endif
    
//    static xbString CreateIndexName(const xbString& dbfName);
    virtual const char* GetExtWithDot(bool lower);
    const CdxHeader& GetIndexHeader() {return indexHeader_;}
    const CdxHeader& GetTagHeader() {return tagHeader_;}
  
  protected:
    virtual xbShort GetHeadNode();
    virtual xbUShort GetKeyLen() {return 0;}
    virtual const char* GetKeyExpression() {return "";}
    virtual void FreeNodesMemory() {}
    void ReadTagHeader();
    xbLong GetIndexTagOffset() {return 0;}
    void ReadIndexHeader(xbLong) {}

  private:
    xbCdx(const xbCdx&);
    xbCdx& operator=(const xbCdx&);
    void WriteTagHeader(const char* tagName);
    void WriteTagRoot(const char* tagName);
    void WriteIndexHeader(const char* expr);
    void WriteIndexRoot();
  
  private:
    CdxHeader tagHeader_;
    CdxLeafNode tagRootNode_;
    CdxHeader indexHeader_;
    CdxLeafNode indexRootNode_;
};

#endif