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/>
76 TableDef() { fldCount
= 0; }
79 /** adds a field to the schema definition.
80 * @param name field name
81 * @param type data type of the field
82 * @param length size of the field. used in case of char and binary data types.
83 * @param defaultValue default value for the field. It is currently limited to 32 bytes.
84 * @param isPrimary whether the field is primary key( not null + unique)
85 * @param notNull whether the field can be null
86 * @param unique whether the field values are unique
89 int addField(const char *name
, DataType type
= typeUnknown
, size_t
90 length
= 0, const void *defaultValue
= 0,
91 bool notNull
= false);
93 /** removes a field from the schema definition
94 * @param name field name
97 int dropField(const char *name
);
99 /** returns the total number of fields in this table definition
100 * @return int no of fields
104 /** returns the total tuple size in bytes.
105 * @return size_t tuple size
107 size_t getTupleSize();
109 //Internal method used to iterate and get information stored
110 //in this table definition.
111 FieldIterator
getFieldIterator(){ return fldList
.getIterator(); }
118 char fldName
[IDENTIFIER_LENGTH
];
122 char defaultValueBuf
[DEFAULT_VALUE_BUF_LENGTH
];
134 hashIndex
= 0, /**<hash index*/
135 treeIndex
/**<tree index*/
139 * @class IndexInitInfo
141 * @brief Represents index definition used to create index.
142 * Encapsulates the information or definition of an index.<br/>
148 char tableName
[IDENTIFIER_LENGTH
]; /**<tablename*/
149 FieldNameList list
; /**<field name list*/
150 IndexType indType
; /**<index type*/
151 bool isUnique
; /**<unique values*/
152 bool isPrimary
; /**<primary key*/
153 IndexInitInfo() { indType
= hashIndex
; isUnique
= false; isPrimary
= false;}
154 ~IndexInitInfo() {list
.removeAll();}
158 * @class HashIndexInitInfo
160 * @brief Represents hash index definition used to create index.
161 * Encapsulates the information or definition of hash index.<br/>
164 class HashIndexInitInfo
: public IndexInitInfo
167 int bucketSize
; /**<bucket size*/
168 HashIndexInitInfo() { bucketSize
= 1009; }