1 /***************************************************************************
2 * Copyright (C) 2007 by Prabakaran Thirumalai *
3 * praba_tuty@yahoo.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 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
42 int paramNo
; // 0 ->not a param. It stores the param position
52 int paramNo
; // 0 ->not a param. It stores the param position
55 char fName
[IDENTIFIER_LENGTH
];
60 char fldName
[IDENTIFIER_LENGTH
];
63 struct UpdateFieldValue
65 char fldName
[IDENTIFIER_LENGTH
];
77 char tblName
[IDENTIFIER_LENGTH
];
78 char idxName
[IDENTIFIER_LENGTH
];
80 StatementType stmtType
;
84 //holds pointer to field names. used in insert to store field name list
85 //and for projection list of select
86 //also used to store primary or unique key fields in create statement
89 //holds pointer to condition values.
90 List conditionValueList
;
92 //holds pointer to field values. used in insert to store field values
93 //used in update to store the current value returned by fetch().This gets replaced
94 //by value in updFldValList and then update() is called.
97 //used to store IN values of SELECT statement
98 //This should be a list of list. so that multiple IN shall be present
99 //in the select statement
102 //update field value list. used to store the values to be updated
103 //value in the SET clause of UPDATE statement is stored here.
106 //stores the where clause condition for SELECT, UPDATE and DELETE
109 //stores field information in CREATE TABLE
112 //stores list of fields for CREATE TABLE
113 FieldList creFldList
;
115 //stores index information
121 ParsedData() { paramCounter
= 0; stmtType
= UnknownStatement
;
122 isUnique
= false; isPrimary
= false; indexType
= hashIndex
;}
123 void setStmtType(StatementType type
) { stmtType
= type
; }
124 void setTableName(char *name
) { strcpy(tblName
, name
); }
125 void setIndexName(char *name
) { strcpy(idxName
, name
); }
127 char* getTableName() { return tblName
; }
128 char* getIndexName() { return idxName
; }
130 void insertValue(char *value
);
131 //void insertInValue(char *value);
132 void** insertCondValueAndGetPtr(char *fName
, char *value
);
133 void insertUpdateValue(char *fldName
, char *value
);
135 void insertField(char *fName
);
136 void clearFieldNameList();
139 Predicate
* insertPredicate(char *fldName
, ComparisionOp op
, void** value
);
140 Predicate
* insertPredicate(char *fldName
, ComparisionOp op
, char *fldName
);
141 Predicate
* insertPredicate(Predicate
*p1
, LogicalOp op
, Predicate
*p2
= NULL
);
142 void setCondition(Predicate
*pred
)
144 //No body is deleting memory allocated during condition::setTerm for PredicateImpl
145 //have list in this pared data and delete it during reset
146 predicate
.setPredicate(pred
);
148 Condition
* getCondition() { return &predicate
; }
150 void insertFieldValue(FieldValue
*newVal
) { fieldValueList
.append(newVal
); }
152 List
getFieldNameList() { return fieldNameList
; }
153 List
getConditionValueList() { return conditionValueList
; }
154 List
getFieldValueList() { return fieldValueList
; }
155 //List getInValueList() { return inValueList; }
156 List
getUpdateFieldValueList() { return updFldValList
; }
158 void setFldName(char *name
);
159 void setFldType(DataType type
);
160 void setFldLength(size_t length
);
161 void setDefaultValue(char * value
);
162 //void setFldDefaultValue -- will need two parametersers, check how u want to pass default value.
163 void setFldNotNull(bool notNull
);
165 void setUnique(bool unique
){ isUnique
= unique
; }
166 void setPrimary(bool primary
) { isPrimary
= primary
; }
167 void setIndexType (IndexType type
) { indexType
= type
; }
168 IndexType
getIndexType(){ return indexType
; }
169 bool getUnique() { return isUnique
; }
170 bool getPrimary() { return isPrimary
; }
172 void insertFldDef(); //check if fldDef needs to be a part of ParsedData
174 FieldList
getCreFldList() { return creFldList
; }
176 StatementType
getStmtType() { return stmtType
; }
185 //variable and function names suck, change if u want to
187 //finding out if fldDef needs to be part of parsedData, or can allocate memory and pass around