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 ***************************************************************************/
20 void ParsedData::insertValue(char *val
)
22 FieldValue
*newVal
= new FieldValue();
24 newVal
->parsedString
= NULL
;
26 newVal
->parsedString
= strdup(val
);
29 newVal
->type
= typeUnknown
;
31 fieldValueList
.append(newVal
);
34 void** ParsedData::insertCondValueAndGetPtr(char *fldName
, char *val
)
36 ConditionValue
*newVal
= new ConditionValue();
38 newVal
->parsedString
= NULL
;
40 newVal
->parsedString
= strdup(val
);
43 newVal
->type
= typeUnknown
;
45 strcpy(newVal
->fName
, fldName
);
46 conditionValueList
.append(newVal
);
47 return &(newVal
->value
);
51 void ParsedData::insertField(char *fName
)
53 FieldName
*newVal
= new FieldName();
54 strcpy(newVal
->fldName
, fName
);
55 fieldNameList
.append(newVal
);
58 void ParsedData::insertUpdateValue(char *fName
, char *val
)
60 UpdateFieldValue
*newVal
= new UpdateFieldValue();
61 strcpy(newVal
->fldName
, fName
);
63 newVal
->parsedString
= NULL
;
65 newVal
->parsedString
= strdup(val
);
68 updFldValList
.append(newVal
);
71 Predicate
* ParsedData::insertPredicate(char *fName
, ComparisionOp op
, void **val
)
74 cond
.setTerm(fName
, op
, val
);
75 return cond
.getPredicate();
77 Predicate
* ParsedData::insertPredicate(char *fName1
, ComparisionOp op
, char *fName2
)
80 cond
.setTerm(fName1
, op
, fName2
);
81 return cond
.getPredicate();
84 Predicate
* ParsedData::insertPredicate(Predicate
*p1
, LogicalOp op
, Predicate
*p2
)
87 cond
.setTerm(p1
, op
, p2
);
88 return cond
.getPredicate();
91 void ParsedData::reset()
93 fieldNameList
.reset();
94 ListIterator iter
= fieldValueList
.getIterator();
96 while (iter
.hasElement())
98 value
= (FieldValue
*)iter
.nextElement();
99 free(value
->parsedString
);
102 fieldValueList
.reset();
105 iter
= conditionValueList
.getIterator();
106 ConditionValue
*condVal
;
107 while (iter
.hasElement())
109 condVal
= (ConditionValue
*)iter
.nextElement();
110 free(condVal
->parsedString
);
111 free(condVal
->value
);
113 conditionValueList
.reset();
115 iter
= updFldValList
.getIterator();
116 UpdateFieldValue
*updFldVal
;
117 while (iter
.hasElement())
119 updFldVal
= (UpdateFieldValue
*)iter
.nextElement();
120 free(updFldVal
->parsedString
);
121 free(updFldVal
->value
);
123 updFldValList
.reset();
125 creFldList
.removeAll();
128 indexType
= hashIndex
;
130 void ParsedData::clearFieldNameList()
132 fieldNameList
.reset();
135 void ParsedData::setFldName(char *name
)
137 strcpy(fldDef
.fldName_
, name
);
138 fldDef
.fldName_
[IDENTIFIER_LENGTH
] = '\0';
141 void ParsedData::setFldType(DataType type
)
146 void ParsedData::setFldLength(size_t length
)
148 fldDef
.length_
= length
;
151 void ParsedData::setFldNotNull(bool notNull
)
153 fldDef
.isNull_
= notNull
;
155 void ParsedData::setDefaultValue(char *value
)
157 fldDef
.isDefault_
= true;
158 if (strlen(value
) > DEFAULT_VALUE_BUF_LENGTH
-1)
160 strncpy(fldDef
.defaultValueBuf_
, value
, DEFAULT_VALUE_BUF_LENGTH
-1);
161 fldDef
.defaultValueBuf_
[DEFAULT_VALUE_BUF_LENGTH
] ='\0';
163 strcpy(fldDef
.defaultValueBuf_
, value
);
168 void ParsedData::insertFldDef()
170 DbRetVal rv
= creFldList
.append(fldDef
);