13 if (!m_keepChildren) {
14 while (m_operands.size() ) {
16 m_operands.pop_back();
24 : m_op(0), m_myTable(orig->m_myTable), m_keepOp(
false), m_name(
""),
32 if (!m_keepOp)
delete m_op;
40 const std::string& rightArg,
52 m_compareArgs[0] = leftArg;
53 m_compareArgs[1] = rightArg;
54 m_compareType[0] = leftLiteral;
55 m_compareType[1] = rightLiteral;
58 m_compareArgs[1] =
"";
69 m_tableName(tableName),
77 m_operands.push_back(child);
82 const std::vector<Operator*>& children,
84 m_opType(type), m_keepChildren(keepChildren) {
90 unsigned int nChild = children.size();
95 for (
unsigned int iChild = 0; iChild < nChild; iChild++) {
96 m_toBe |= (children[iChild]->m_toBe);
97 m_old |= (children[iChild]->m_old);
98 m_operands.push_back(children[iChild]);
107 : m_opType(op->m_opType), m_tableName(op->m_tableName),
108 m_keepChildren(
false), m_toBe(
false), m_old(op->m_old) {
118 unsigned nChild = op->m_operands.size();
119 for (
unsigned iChild = 0; iChild < nChild; iChild++) {
133 for (
unsigned i = 0; i < 2; i++) {
140 (
"Assertion::Operator constructor can't resolve field");
142 m_compareArgs[i] = f->
m_val;
146 m_compareArgs[i] = op->m_compareArgs[i];
147 m_compareType[i] =op->m_compareType[i];
153 throw RdbException(
"Assertion::Operator constructor - Unknown OP type");
159 m_toBe |= child->m_toBe;
160 m_old |= child->m_old;
162 m_operands.push_back(child);
165 else if ((m_opType ==
OPTYPEnot) && (m_operands.size() == 0) ) {
166 m_operands.push_back(child);
169 throw RdbException(
"Assertion::Operator::appendChild: wrong parent operator type");
182 return col0->
okValue(m_compareArgs[1],
false);
187 return col1->
okValue(m_compareArgs[0],
false);
195 throw RdbException(
"Assertion::Operator::getCompareArgs: wrong type");
196 return &m_compareArgs[0];
203 throw RdbException(
"Assertion::Operator::getLiteralness: wrong type");
204 return &m_compareType[0];
210 throw RdbException(
"Assertion::Operator::getTableName: wrong type");
218 unsigned nChild = m_operands.size();
219 for (
unsigned i = 0; i < nChild; i++) {
220 if (m_operands[i]->
verify(old, toBe,
t))
return true;
226 unsigned nChild = m_operands.size();
227 for (
unsigned i = 0; i < nChild; i++) {
228 if (!(m_operands[i]->
verify(old, toBe,
t)))
return false;
233 return (!(m_operands[0]->
verify(old, toBe,
t)));
248 return ((f->
m_val).size() == 0);
251 throw RdbException(
"Assertion::Operator::verify missing isNull field");
261 return verifyCompare(old, toBe,
t);
269 bool Assertion::Operator::verifyCompare(
Row& old,
Row& toBe,
Table*
t)
const
274 std::string values[2];
278 for (
unsigned i = 0; i < 2; i++) {
279 switch (m_compareType[i]) {
282 values[i] = m_compareArgs[i];
289 std::string(
"Assertion::Operator::verifyCompare missing field ")
294 values[i] = f->
m_val;
300 FieldVal* f = toBe.
find(m_compareArgs[i]);
303 RdbException(
"Assertion::Operator::verifyCompare missing field");
305 values[i] = f->m_val;
306 colname = f->m_colname;
311 RdbException(
"Assertion::Operator::verifyCompare bad arg type");
314 if (colname.size() > 0) {
315 Column* c =
t->getColumnByName(colname);
316 Datatype* d = c->getDatatype();
318 switch (d->getType()) {
321 return compareTs(&values[0], m_opType);
325 return compareInt(&values[0], m_opType);
328 return compareFloat(&values[0], m_opType);
334 return compareString(&values[0], m_opType);
337 const std::vector<Assertion::Operator* >&
340 throw RdbException(
"Assertion::Operator::getChildren: wrong type");
358 return m_op->
verify(old, toBe, m_myTable);
361 bool Assertion::Operator::compareTs(
const std::string* vals,
364 Timestamp left, right;
366 left = Timestamp(*vals);
367 right = Timestamp(*(vals + 1));
371 RdbException(
"Assertion::Operator::CompareTs illegal input");
376 return left == right;
378 return left != right;
384 return left <= right;
386 return right >= right;
388 throw RdbException(
"Assertion::Operator::compareTs bad OPTYPE");
395 bool Assertion::Operator::compareInt(
const std::string* vals,
400 int i= Util::stringToInt(*vals);
401 i = Util::stringToInt(*(vals + 1));
405 RdbException(
"Assertion::Operator::compareInt illegal input");
407 return compareFloat(vals, type);
411 bool Assertion::Operator::compareFloat(
const std::string* vals,
416 left = Util::stringToDouble(*vals);
417 right = Util::stringToDouble(*(vals + 1));
421 RdbException(
"Assertion::Operator::compareFloat illegal input");
425 return left == right;
427 return left != right;
433 return left <= right;
435 return right >= right;
437 throw RdbException(
"Assertion::Operator::compareFloat bad OPTYPE");
444 bool Assertion::Operator::compareString(
const std::string* vals,
448 return ( (*vals).compare(*(vals+1)) == 0 );
450 return ( (*vals).compare(*(vals+1)) != 0 );
453 RdbException(
"Assertion::Operator::compareString Unsupported OPTYPE");
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Exception class used when converting from string to numeric type.
bool appendChild(Operator *child)
Add another child to a conjunction-style operator.
const std::vector< Operator * > & getChildren() const
Throw exception if Operator is a comparison operator.
const std::string & getTableName() const
Throw exception if Operaotr is not EXISTS.
const std::string * getCompareArgs() const
Throw exception if Operator is not a comparison operator.
bool validCompareOp(Table *table) const
const FIELDTYPE * getCompareArgTypes() const
Get types of comparison args.
bool verify(Row &old, Row &toBe, Table *t) const
Evaluate operator on argument Rows.
Visitor::VisitorState accept(Visitor *v)
bool verify(Row &old, Row &toBe) const
Assertion(Operator *op=0, Table *myTable=0, bool keepOp=false)
bool isCompatible(const Column *otherCol) const
Return true if otherCol and this have compatible datatypes.
bool okValue(const std::string &val, bool set=true) const
FieldVal * find(std::string colname)
Column * getColumnByName(const std::string &name) const