Fixing Build failure.
[csql.git] / include / Info.h
blobe8557562c5323f543d509dbc518f2dc70aad63cf
1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 ***************************************************************************/
16 #ifndef INFO_H
17 #define INFO_H
18 #include<ErrorType.h>
19 #include<DataType.h>
20 #include<Field.h>
23 class FieldNameNode;
25 /**
26 * @class FieldNameList
28 * @brief Field name list used to specify composite key while creating index. <br/>
31 class FieldNameList
33 FieldNameNode *head;
34 FieldNameNode *iter;
35 public:
36 FieldNameList() { head = iter = NULL; }
37 ~FieldNameList() { } //TODO::Remove all elements from the list
38 char *nextFieldName();
39 void resetIter(){ iter = head; }
40 int size();
42 /** appends field name to the list
43 * @param name field name
44 * @return int
46 DbRetVal append(const char *name);
48 /** removes field name from the list
49 * @param name field name
50 * @return int
52 DbRetVal remove(const char *name);
53 DbRetVal removeAll();
56 class FieldList;
57 class FieldIterator;
60 /**
61 * @class TableDef
63 * @brief Represents table definition used to create the table.
64 * Encapsulates the information or schema definition of a table.For Example say if <br/>
65 * we need to create table with two fields, call addField method with necessary parameters<br/>
66 * twice. Passed as argument to createTable method of DatabaseManager to create table.<br/>
69 class TableDef
71 private:
72 FieldList fldList;
73 int fldCount;
74 public:
75 TableDef() { fldCount = 0; }
76 ~TableDef();
77 void reset();
78 /** adds a field to the schema definition.
79 * @param name field name
80 * @param type data type of the field
81 * @param length size of the field. used in case of char and binary data types.
82 * @param defaultValue default value for the field. It is currently limited to 32 bytes.
83 * @param isPrimary whether the field is primary key( not null + unique)
84 * @param notNull whether the field can be null
85 * @param unique whether the field values are unique
86 * @return int
88 int addField(const char *name, DataType type = typeUnknown, size_t
89 length = 0, const void *defaultValue = 0,
90 bool notNull = false);
92 /** removes a field from the schema definition
93 * @param name field name
94 * @return int
96 int dropField(const char *name);
98 /** returns the total number of fields in this table definition
99 * @return int no of fields
101 int getFieldCount();
103 /** returns the total tuple size in bytes.
104 * @return size_t tuple size
106 size_t getTupleSize();
108 //Internal method used to iterate and get information stored
109 //in this table definition.
110 FieldIterator getFieldIterator(){ return fldList.getIterator(); }
114 class FieldInfo
116 public:
117 char fldName[IDENTIFIER_LENGTH];
118 DataType type;
119 size_t length;
120 size_t offset;
121 char defaultValueBuf[DEFAULT_VALUE_BUF_LENGTH];
122 bool isNull;
123 bool isPrimary;
124 bool isDefault;
125 bool isUnique;
130 /** A Enum value
132 enum IndexType
134 hashIndex = 0, /**<hash index*/
135 treeIndex, /**<tree index*/
136 unknownIndex /**<no index*/
140 * @class IndexInitInfo
142 * @brief Represents index definition used to create index.
143 * Encapsulates the information or definition of an index.<br/>
146 class IndexInitInfo
148 public:
149 char tableName[IDENTIFIER_LENGTH]; /**<tablename*/
150 FieldNameList list; /**<field name list*/
151 IndexType indType; /**<index type*/
152 bool isUnique; /**<unique values*/
153 bool isPrimary; /**<primary key*/
154 IndexInitInfo() { indType = hashIndex; isUnique = false; isPrimary= false;}
155 ~IndexInitInfo() {list.removeAll();}
159 * @class HashIndexInitInfo
161 * @brief Represents hash index definition used to create index.
162 * Encapsulates the information or definition of hash index.<br/>
165 class HashIndexInitInfo : public IndexInitInfo
167 public:
168 int bucketSize; /**<bucket size*/
169 HashIndexInitInfo() { bucketSize = 1009; }
171 #endif