1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
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. *
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. *
15 ***************************************************************************/
26 * @class FieldNameList
28 * @brief Field name list used to specify composite key while creating index. <br/>
36 FieldNameList() { head
= iter
= NULL
; }
37 ~FieldNameList() { } //TODO::Remove all elements from the list
38 char *nextFieldName();
39 void resetIter(){ iter
= head
; }
42 /** appends field name to the list
43 * @param name field name
46 DbRetVal
append(const char *name
);
48 /** removes field name from the list
49 * @param name field name
52 DbRetVal
remove(const char *name
);
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/>
75 TableDef() { fldCount
= 0; }
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
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
96 int dropField(const char *name
);
98 /** returns the total number of fields in this table definition
99 * @return int no of fields
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(); }
117 char fldName
[IDENTIFIER_LENGTH
];
121 char defaultValueBuf
[DEFAULT_VALUE_BUF_LENGTH
];
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/>
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
168 int bucketSize
; /**<bucket size*/
169 HashIndexInitInfo() { bucketSize
= 1009; }