00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef INFO_H
00017 #define INFO_H
00018 #include<ErrorType.h>
00019 #include<DataType.h>
00020 #include<Field.h>
00021
00022
00023 class FieldNameNode;
00024
00031 class FieldNameList
00032 {
00033 FieldNameNode *head;
00034 FieldNameNode *iter;
00035 public:
00036 FieldNameList() { head = iter = NULL; }
00037 ~FieldNameList() { }
00038 char *nextFieldName();
00039 void resetIter(){ iter = head; }
00040 int size();
00041
00046 DbRetVal append(const char *name);
00047
00052 DbRetVal remove(const char *name);
00053 DbRetVal removeAll();
00054 };
00055
00056 class FieldList;
00057 class FieldIterator;
00058
00059
00069 class TableDef
00070 {
00071 private:
00072 FieldList fldList;
00073 int fldCount;
00074
00075 public:
00076 TableDef() { fldCount = 0; }
00077 ~TableDef();
00078 void reset();
00089 int addField(const char *name, DataType type = typeUnknown, size_t
00090 length = 0, const void *defaultValue = 0,
00091 bool notNull = false);
00092
00097 int dropField(const char *name);
00098
00102 int getFieldCount();
00103
00107 size_t getTupleSize();
00108
00109
00110
00111 FieldIterator getFieldIterator(){ return fldList.getIterator(); }
00112
00113 };
00114
00115 class FieldInfo
00116 {
00117 public:
00118 char fldName[IDENTIFIER_LENGTH];
00119 DataType type;
00120 size_t length;
00121 int offset;
00122 char defaultValueBuf[DEFAULT_VALUE_BUF_LENGTH];
00123 bool isNull;
00124 bool isPrimary;
00125 bool isDefault;
00126 };
00127
00128
00129
00132 enum IndexType
00133 {
00134 hashIndex = 0,
00135 treeIndex
00136 };
00137
00145 class IndexInitInfo
00146 {
00147 public:
00148 char tableName[IDENTIFIER_LENGTH];
00149 FieldNameList list;
00150 IndexType indType;
00151 bool isUnique;
00152 bool isPrimary;
00153 IndexInitInfo() { indType = hashIndex; isUnique = false; isPrimary= false;}
00154 ~IndexInitInfo() {list.removeAll();}
00155 };
00156
00164 class HashIndexInitInfo : public IndexInitInfo
00165 {
00166 public:
00167 int bucketSize;
00168 HashIndexInitInfo() { bucketSize = 1009; }
00169 };
00170 #endif