bool NumArithIterator<Operation>::compute( store::Item_t& result, dynamic_context* dctx, const TypeManager* tm, const QueryLoc& aLoc, store::Item_t& n0, store::Item_t& n1) { assert(n0->isAtomic()); assert(n1->isAtomic()); store::SchemaTypeCode type0 = n0->getTypeCode(); store::SchemaTypeCode type1 = n1->getTypeCode(); return computeAtomic(result, dctx, tm, aLoc, n0, type0, n1, type1); }
void IndexDelta::addGeneralPair(store::Item_t& node, store::Item_t& key) { assert(node->isNode() && key->isAtomic()); theGeneralDelta.resize(theGeneralDelta.size() + 1); theGeneralDelta.back().first.transfer(node); theGeneralDelta.back().second.transfer(key); }
void GeneralIndexCondition::pushRange( store::Item_t& lower, store::Item_t& upper, bool haveLower, bool haveUpper, bool lowerIncl, bool upperIncl) { assert(theKind == BOX_VALUE); assert(!theIsSet); assert(!haveLower || (lower && lower->isAtomic())); assert(!haveUpper || (upper && upper->isAtomic())); theRangeFlags.theHaveLowerBound = haveLower; theRangeFlags.theHaveUpperBound = haveUpper; theRangeFlags.theLowerBoundIncl = lowerIncl; theRangeFlags.theUpperBoundIncl = upperIncl; if (haveLower) { theLowerBound.transfer(lower); store::Item* baseItem = theLowerBound->getBaseItem(); if (baseItem != NULL) theLowerBound = baseItem; } if (haveUpper) { theUpperBound.transfer(upper); store::Item* baseItem = theUpperBound->getBaseItem(); if (baseItem != NULL) theUpperBound = baseItem; } theIsSet = true; }
void GeneralIndexCondition::pushItem(store::Item_t& item) { assert(theKind == POINT_VALUE || theKind == POINT_GENERAL); assert(!theIsSet); assert(item && item->isAtomic()); theKey.transfer(item); store::Item* baseItem = theKey->getBaseItem(); if (baseItem != NULL) theKey = baseItem; theIsSet = true; }
bool x2j_map_atomic( store::Item_t const &xml_item, store::Item_t *json_item ) { if ( xml_item->isAtomic() ) { switch ( xml_item->getTypeCode() ) { case store::JS_NULL: case store::XS_BOOLEAN: case store::XS_BYTE: case store::XS_DECIMAL: case store::XS_DOUBLE: case store::XS_ENTITY: case store::XS_FLOAT: case store::XS_ID: case store::XS_IDREF: case store::XS_INT: case store::XS_INTEGER: case store::XS_LONG: case store::XS_NAME: case store::XS_NCNAME: case store::XS_NEGATIVE_INTEGER: case store::XS_NMTOKEN: case store::XS_NON_NEGATIVE_INTEGER: case store::XS_NON_POSITIVE_INTEGER: case store::XS_NORMALIZED_STRING: case store::XS_POSITIVE_INTEGER: case store::XS_SHORT: case store::XS_STRING: case store::XS_TOKEN: case store::XS_UNSIGNED_BYTE: case store::XS_UNSIGNED_INT: case store::XS_UNSIGNED_LONG: case store::XS_UNSIGNED_SHORT: *json_item = xml_item; break; default: zstring s( xml_item->getStringValue() ); GENV_ITEMFACTORY->createString( *json_item, s ); break; } // switch return true; } // if return false; }
bool GenericArithIterator<Operation>::compute( store::Item_t& result, dynamic_context* dctx, const TypeManager* tm, const QueryLoc& aLoc, store::Item_t& n0, store::Item_t& n1) { RootTypeManager& rtm = GENV_TYPESYSTEM; assert(n0->isAtomic()); assert(n1->isAtomic()); store::SchemaTypeCode type0 = n0->getTypeCode(); store::SchemaTypeCode type1 = n1->getTypeCode(); if (TypeOps::is_numeric(type0) && (TypeOps::is_subtype(type1, store::XS_YM_DURATION) || TypeOps::is_subtype(type1, store::XS_DT_DURATION))) { GenericCast::castToAtomic(n0, n0, &*rtm.DOUBLE_TYPE_ONE, tm, NULL, aLoc); if (TypeOps::is_subtype(type1, store::XS_YM_DURATION)) { return Operation::template compute<store::XS_DOUBLE, store::XS_YM_DURATION> (result, dctx, tm, &aLoc, n0, n1); } else { return Operation::template compute<store::XS_DOUBLE,store::XS_DT_DURATION> (result, dctx, tm, &aLoc, n0, n1); } } else if (TypeOps::is_subtype(type0, store::XS_DT_DURATION) && TypeOps::is_subtype(type1, store::XS_TIME)) { return Operation::template compute<store::XS_DURATION,store::XS_TIME> (result, dctx, tm, &aLoc, n0, n1); } else if (TypeOps::is_subtype(type0, store::XS_YM_DURATION)) { if (TypeOps::is_numeric(type1)) { GenericCast::castToAtomic(n1, n1, &*rtm.DOUBLE_TYPE_ONE, tm, NULL, aLoc); return Operation::template compute<store::XS_YM_DURATION,store::XS_DOUBLE> (result, dctx, tm, &aLoc, n0, n1); } else if (TypeOps::is_subtype(type1, store::XS_DATETIME)) { return Operation::template compute<store::XS_DURATION,store::XS_DATETIME> (result, dctx, tm, &aLoc, n0, n1); } else if (TypeOps::is_subtype(type1, store::XS_DATE)) { return Operation::template compute<store::XS_DURATION,store::XS_DATE> (result, dctx, tm, &aLoc, n0, n1); } else if (type0 == type1) { return Operation::template computeSingleType<store::XS_YM_DURATION> (result, dctx, tm, &aLoc, n0, n1); } } else if (TypeOps::is_subtype(type0, store::XS_DT_DURATION)) { if (TypeOps::is_numeric(type1)) { GenericCast::castToAtomic(n1, n1, &*rtm.DOUBLE_TYPE_ONE, tm, NULL, aLoc); return Operation::template compute<store::XS_DT_DURATION,store::XS_DOUBLE> (result, dctx, tm, &aLoc, n0, n1); } else if (TypeOps::is_subtype(type1, store::XS_DATETIME)) { return Operation::template compute<store::XS_DURATION,store::XS_DATETIME> (result, dctx, tm, &aLoc, n0, n1); } else if (TypeOps::is_subtype(type1, store::XS_DATE)) { return Operation::template compute<store::XS_DURATION,store::XS_DATE> (result, dctx, tm, &aLoc, n0, n1); } else if (type0 == type1) { return Operation::template computeSingleType<store::XS_DT_DURATION> (result, dctx, tm, &aLoc, n0, n1); } } else if (TypeOps::is_subtype(type0, store::XS_DATETIME)) { if (TypeOps::is_subtype(type1, store::XS_DATETIME)) { return Operation::template compute<store::XS_DATETIME,store::XS_DATETIME> (result, dctx, tm, &aLoc, n0, n1); } else if (TypeOps::is_subtype(type1, store::XS_YM_DURATION)) { return Operation::template compute<store::XS_DATETIME,store::XS_DURATION> (result, dctx, tm, &aLoc, n0, n1); } else if (TypeOps::is_subtype(type1, store::XS_DT_DURATION)) { return Operation::template compute<store::XS_DATETIME,store::XS_DURATION> (result, dctx, tm, &aLoc, n0, n1); } } else if (TypeOps::is_subtype(type0, store::XS_DATE)) { if (TypeOps::is_subtype(type1, store::XS_DATE)) { return Operation::template compute<store::XS_DATE,store::XS_DATE> (result, dctx, tm, &aLoc, n0, n1); } else if (TypeOps::is_subtype(type1, store::XS_YM_DURATION)) { return Operation::template compute<store::XS_DATE,store::XS_DURATION> (result, dctx, tm, &aLoc, n0, n1); } else if (TypeOps::is_subtype(type1, store::XS_DT_DURATION)) { return Operation::template compute<store::XS_DATE,store::XS_DURATION> (result, dctx, tm, &aLoc, n0, n1); } } else if (TypeOps::is_subtype(type0, store::XS_TIME)) { if (TypeOps::is_subtype(type1, store::XS_TIME)) { return Operation::template compute<store::XS_TIME,store::XS_TIME> (result, dctx, tm, &aLoc, n0, n1); } else if (TypeOps::is_subtype(type1, store::XS_DT_DURATION)) { return Operation::template compute<store::XS_TIME,store::XS_DURATION> (result, dctx, tm, &aLoc, n0, n1); } } else if ((TypeOps::is_numeric(type0) || type0 == store::XS_UNTYPED_ATOMIC) && (TypeOps::is_numeric(type1) || type1 == store::XS_UNTYPED_ATOMIC)) { return NumArithIterator<Operation>:: computeAtomic(result, dctx, tm, aLoc, n0, type0, n1, type1); } { xqtref_t type0 = tm->create_value_type(n0); xqtref_t type1 = tm->create_value_type(n1); RAISE_ERROR(err::XPTY0004, aLoc, ERROR_PARAMS(ZED(ArithOpNotDefinedBetween_23), *type0, *type1)); } return false; // suppresses wanring }
bool TreatIterator::nextImpl(store::Item_t& result, PlanState& planState) const { store::Item_t temp; bool res; const TypeManager* tm = theSctx->get_typemanager(); PlanIteratorState* state; DEFAULT_STACK_INIT(PlanIteratorState, state, planState); if (!consumeNext(result, theChild.getp(), planState)) { if (theQuantifier == SequenceType::QUANT_PLUS || theQuantifier == SequenceType::QUANT_ONE) { raiseError("empty-sequence()"); } } else if (theQuantifier == SequenceType::QUANT_QUESTION || theQuantifier == SequenceType::QUANT_ONE) { if (consumeNext(temp, theChild.getp(), planState)) { raiseError("sequence of more than one item"); } if (theCheckPrime) { if (theTreatType->type_kind() == XQType::ATOMIC_TYPE_KIND && result->isAtomic()) { store::SchemaTypeCode targetType = static_cast<const AtomicXQType*>(theTreatType.getp())->get_type_code(); store::SchemaTypeCode itemType = result->getTypeCode(); res = TypeOps::is_subtype(itemType, targetType); } else { res = TypeOps::is_subtype(tm, result, *theTreatType, loc); } if (!res) { zstring valueType = tm->create_value_type(result)->toSchemaString(); raiseError(valueType); } } STACK_PUSH(true, state); } else { do { if (theCheckPrime) { if (theTreatType->type_kind() == XQType::ATOMIC_TYPE_KIND && result->isAtomic()) { store::SchemaTypeCode targetType = static_cast<const AtomicXQType*>(theTreatType.getp())->get_type_code(); store::SchemaTypeCode itemType = result->getTypeCode(); res = TypeOps::is_subtype(itemType, targetType); } else { res = TypeOps::is_subtype(tm, result, *theTreatType, loc); } if (!res) { zstring valueType = tm->create_value_type(result)->toSchemaString(); raiseError(valueType); } } STACK_PUSH(true, state); } while (consumeNext(result, theChild.getp(), planState)); } STACK_END(state); }
bool deepEqual( const QueryLoc& loc, static_context* sctx, store::Item_t& item1, store::Item_t& item2, XQPCollator* collator, int timezone, bool raiseError) { if (item1->isFunction() || item2->isFunction()) { if (raiseError) { RAISE_ERROR(err::FOTY0015, loc, ERROR_PARAMS((item1->isFunction() ? item1 : item2)->getFunctionName()->getStringValue())); } else return false; } if (item1->getKind() != item2->getKind()) return false; switch (item1->getKind()) { case store::Item::ATOMIC: { assert(item2->isAtomic()); store::SchemaTypeCode type1 = item1->getTypeCode(); store::SchemaTypeCode type2 = item2->getTypeCode(); // check if both items are NaN if (((type1 == store::XS_FLOAT && item1->getFloatValue().isNaN()) || (type1 == store::XS_DOUBLE && item1->getDoubleValue().isNaN())) && ((type2 == store::XS_FLOAT && item2->getFloatValue().isNaN()) || (type2 == store::XS_DOUBLE && item2->getDoubleValue().isNaN()))) { return true; } if (raiseError) { try { TypeManager* tm = sctx->get_typemanager(); return CompareIterator::valueEqual(loc, item1, item2, tm, timezone, collator, raiseError); } catch (ZorbaException const& e) { if (e.diagnostic() == err::XPTY0004) return false; throw; } } else { TypeManager* tm = sctx->get_typemanager(); return CompareIterator::valueEqual(loc, item1, item2, tm, timezone, collator, raiseError); } break; } case store::Item::NODE: { return deepEqualNodes(loc, sctx, item1, item2, collator, timezone, raiseError); } case store::Item::OBJECT: { return deepEqualObjects(loc, sctx, item1, item2, collator, timezone, raiseError); } case store::Item::ARRAY: { return deepEqualArrays(loc, sctx, item1, item2, collator, timezone, raiseError); } default: { ZORBA_ASSERT(false); // should never reach here } } return false; }