void SimpleLazyTempSeq::purgeUpTo(xs_integer position) { xs_long pos; try { pos = to_xs_long(position); } catch (std::range_error const&) { throw ZORBA_EXCEPTION(zerr::ZSTR0060_RANGE_EXCEPTION, ERROR_PARAMS(position,ZED(ZSTR0060_ForSequence))); } ZORBA_ASSERT(pos >= thePurgedUpTo); ZORBA_ASSERT(static_cast<std::vector<store::Item*>::size_type>(pos - thePurgedUpTo) <= theItems.size()); std::vector<store::Item*>::iterator ite = theItems.begin(); std::vector<store::Item*>::iterator end = theItems.begin() + static_cast<std::vector<store::Item*>::size_type>(pos - thePurgedUpTo); for (; ite != end; ++ite) { (*ite)->removeReference(); } theItems.erase(theItems.begin(), end); thePurgedUpTo = pos; }
SequenceType SequenceType::createSchemaAttributeType( const StaticContext_t& sctx, const String& uri, const String& localName, Quantifier quant) { ZORBA_ASSERT(sctx != NULL); static_context* sctx2 = Unmarshaller::getInternalStaticContext(sctx); TypeManager* tm = sctx2->get_typemanager(); zstring& ns = Unmarshaller::getInternalString(uri); zstring& local = Unmarshaller::getInternalString(localName); store::Item_t qname; ZORBA_ASSERT(!local.empty()); GENV_ITEMFACTORY->createQName(qname, ns, "", local); try { xqtref_t res = tm->create_schema_attribute_type(qname, quant, QueryLoc::null); return Unmarshaller::createSequenceType(res.getp()); } catch (...) { return Unmarshaller::createSequenceType(NULL); } }
bool JSONtoXMLInternal::nextImpl( store::Item_t& result, PlanState &planState ) const { store::Item_t item; options_type options; PlanIteratorState *state; DEFAULT_STACK_INIT( PlanIteratorState, state, planState ); ZORBA_ASSERT( theChildren.size() == 2 ); consumeNext( item, theChildren[1], planState ); get_options( item, &options ); consumeNext( item, theChildren[0], planState ); result = nullptr; { // local scope options_type::mapped_type const &format_opt = options[ "json-format" ]; ZORBA_ASSERT( !format_opt.empty() ); if ( format_opt == "Snelson" ) snelson::json_to_xml( item, &result ); else if ( format_opt == "JsonML" || format_opt == "JsonML-array" ) jsonml_array::json_to_xml( item, &result ); else if ( format_opt == "JsonML-object" ) jsonml_object::json_to_xml( item, &result ); else ZORBA_ASSERT( false ); } // local scope STACK_PUSH( !!result, state ); STACK_END( state ); }
/******************************************************************************* Constructor for user-defined Atomic and Complex types ********************************************************************************/ UserDefinedXQType::UserDefinedXQType( const TypeManager* manager, bool isAnonymous, store::Item_t qname, const xqtref_t& baseType, SequenceType::Quantifier quantifier, UDTKind udtKind, content_kind_t contentKind, bool builtin) : XQType(manager, USER_DEFINED_KIND, quantifier, builtin), theIsAnonymous(isAnonymous), theQName(qname), theBaseType(baseType), theUDTKind(udtKind), theContentKind(contentKind) { assert(udtKind == ATOMIC_UDT || udtKind == COMPLEX_UDT); ZORBA_ASSERT(baseType != NULL); ZORBA_ASSERT(udtKind == ATOMIC_UDT || quantifier == SequenceType::QUANT_ONE); TRACE("UserDefinedXQType c2: " << theQName->getLocalName() << "@" << theQName->getNamespace() << " " << decodeUDTKind(theUDTKind) << " " << contentKindStr(theContentKind)); }
void json_to_xml( store::Item_t const &json_item, store::Item_t *xml_item ) { ZORBA_ASSERT( xml_item ); switch ( json_item->getKind() ) { case store::Item::ARRAY: *xml_item = j2x_array( json_item, nullptr ); break; case store::Item::OBJECT: throw XQUERY_EXCEPTION( zerr::ZJ2X0001_JSONML_ARRAY_BAD_JSON, ERROR_PARAMS( ZED( ZJ2X0001_ArrayRequired ) ) ); default: ZORBA_ASSERT( false ); } }
bool FunctionNameIterator::nextImpl( store::Item_t& r, PlanState& planState) const { store::Item_t lFItem; FunctionItem* lFunctionItem = 0; PlanIteratorState* state; DEFAULT_STACK_INIT(PlanIteratorState, state, planState); consumeNext(lFItem, theChildren[0], planState); // function signature guarantees that ZORBA_ASSERT(lFItem->isFunction()); lFunctionItem = static_cast<FunctionItem*>(lFItem.getp()); if ((!lFunctionItem->isInline() || lFunctionItem->isCoercion()) && lFunctionItem->getFunctionName() && (lFunctionItem->getArity() == lFunctionItem->getStartArity())) { // non-inline function r = lFunctionItem->getFunctionName(); STACK_PUSH(true, state); } STACK_END(state); }
store::IndexCondition_t IndexImpl::createCondition(store::IndexCondition::Kind k) { if (!isSorted() && (k == store::IndexCondition::BOX_VALUE || k == store::IndexCondition::BOX_GENERAL)) { RAISE_ERROR_NO_LOC(zerr::ZSTR0007_INDEX_UNSUPPORTED_PROBE_CONDITION, ERROR_PARAMS(IndexConditionImpl::getKindString(k), getName()->getStringValue())); } if (isGeneral()) { return new GeneralIndexCondition(this, k); } else if (k == store::IndexCondition::POINT_VALUE) { return new IndexPointCondition(this, k); } else if (k == store::IndexCondition::BOX_VALUE) { return new IndexBoxValueCondition(this, k); } else { RAISE_ERROR_NO_LOC(zerr::ZSTR0007_INDEX_UNSUPPORTED_PROBE_CONDITION, ERROR_PARAMS(IndexConditionImpl::getKindString(k), getName()->getStringValue())); ZORBA_ASSERT(false); } }
bool IndexBoxValueCondition::test(const store::IndexKey& key) const { csize numCols = theLowerBounds.size(); ZORBA_ASSERT(numCols <= theIndex->getNumColumns()); long timezone = theIndex->getSpecification().theTimezone; for (csize i = 0; i < numCols; i++) { const XQPCollator* collator = theIndex->getCollator(i); if (theRangeFlags[i].theHaveLowerBound) { long comp = key[i]->compare(theLowerBounds[i], timezone, collator); if (comp < 0 || (comp == 0 && !theRangeFlags[i].theLowerBoundIncl)) return false; } if (theRangeFlags[i].theHaveUpperBound) { long comp = key[i]->compare(theUpperBounds[i], timezone, collator); if (comp > 0 || (comp == 0 && !theRangeFlags[i].theUpperBoundIncl)) return false; } } return true; }
void IndexConditionImpl::pushBound( store::Item_t& bound, bool isLower, bool boundIncl) { ZORBA_ASSERT(false); }
store::Item_t XQType::getQName() const { switch (type_kind()) { case ATOMIC_TYPE_KIND: { store::SchemaTypeCode type = static_cast<const AtomicXQType*>(this)->theAtomicCode; return GENV_TYPESYSTEM.m_atomic_typecode_qname_map[type]; } case USER_DEFINED_KIND: { return static_cast<const UserDefinedXQType*>(this)->theQName; } case ANY_TYPE_KIND: { return GENV_TYPESYSTEM.XS_ANY_TYPE_QNAME; } case UNTYPED_KIND: { return GENV_TYPESYSTEM.XS_UNTYPED_QNAME; } case ANY_SIMPLE_TYPE_KIND: { return GENV_TYPESYSTEM.XS_ANY_SIMPLE_TYPE_QNAME; } default: ZORBA_ASSERT(false); } }
store::StoreConsts::NodeKind match_expr::getNodeKind() const { switch (theTestKind) { case match_name_test: return store::StoreConsts::elementNode; case match_doc_test: return store::StoreConsts::documentNode; case match_elem_test: return store::StoreConsts::elementNode; case match_xs_elem_test: return store::StoreConsts::elementNode; case match_attr_test: return store::StoreConsts::attributeNode; case match_xs_attr_test: return store::StoreConsts::attributeNode; case match_pi_test: return store::StoreConsts::piNode; case match_text_test: return store::StoreConsts::textNode; case match_namespace_test: return store::StoreConsts::namespaceNode; case match_comment_test: return store::StoreConsts::commentNode; case match_anykind_test: return store::StoreConsts::anyNode; default: ZORBA_ASSERT (false && "Unknown node test kind"); } return store::StoreConsts::anyNode; }
void SimpleRCObject::serialize(::zorba::serialization::Archiver& ar) { ZORBA_ASSERT(false); if (!ar.is_serializing_out()) theRefCount = 0; }
void VectorItemSequence::InternalIterator::open() { ZORBA_ASSERT(!theIsOpen); theIsOpen = true; theIterator = theItemSequence->theSequence.begin(); theEnd = theItemSequence->theSequence.end(); }
void cacheable_function::computeCacheSettings(XQueryDiagnostics* aDiag) { if (theAreCacheSettingsComputed) return; if (!theTypeManager) theTypeManager = getTypeManager(); ZORBA_ASSERT(theTypeManager); if (!theAnnotationList) useDefaultCachingSettings(); else if (theAnnotationList->contains(AnnotationInternal::zann_cache)) useLegacyCache(aDiag); else if (theAnnotationList->contains(AnnotationInternal::zann_strictlydeterministic)) useStrictlyDeterministicCache(aDiag); else if (theAnnotationList->contains(AnnotationInternal::zann_deterministic)) theHasCache = false; else useDefaultCachingSettings(); theAreCacheSettingsComputed = true; theCache.reset(new FunctionCache( theModuleSctx, theExcludeFromCacheKey, theCompareWithDeepEqual, theCacheAcrossSnapshots)); }
static void x2j_children( store::Item_t const &parent, vector<store::Item_t> *children ) { ZORBA_ASSERT( children ); store::Iterator_t i( parent->getChildren() ); i->open(); store::Item_t child_item, temp_item; while ( i->next( child_item ) ) { if ( !x2j_map_atomic( child_item, &temp_item ) ) { if ( !child_item->isNode() ) throw XQUERY_EXCEPTION( zerr::ZJ2X0001_JSONML_ARRAY_BAD_JSON, ERROR_PARAMS( ZED( ZJ2X0001_BadElement ), child_item->getKind() ) ); switch ( child_item->getNodeKind() ) { case store::StoreConsts::elementNode: x2j_element( child_item, &temp_item ); break; case store::StoreConsts::textNode: { zstring s( child_item->getStringValue() ); GENV_ITEMFACTORY->createString( temp_item, s ); break; } default: continue; } // switch } // if children->push_back( temp_item ); } // while i->close(); }
dynamic_context::VarValue::VarValue(const VarValue& other) { switch (other.theState) { case VarValue::undeclared: case VarValue::declared: assert(other.theValue.item == NULL); theValue.item = NULL; break; case VarValue::item: assert(other.theValue.item != NULL); theValue.item = other.theValue.item; theValue.item->addReference(); break; case VarValue::temp_seq: assert(other.theValue.temp_seq != NULL); theValue.temp_seq = other.theValue.temp_seq; RCHelper::addReference(theValue.temp_seq); break; default: ZORBA_ASSERT(false); } theState = other.theState; theIsExternalOrLocal = other.theIsExternalOrLocal; }
void SimpleLazyTempSeq::getItem(xs_integer position, store::Item_t& result) { xs_long pos; try { pos = to_xs_long(position); } catch (std::range_error const&) { RAISE_ERROR_NO_LOC(zerr::ZSTR0060_RANGE_EXCEPTION, ERROR_PARAMS(position,ZED(ZSTR0060_ForSequence))); } ZORBA_ASSERT(pos > thePurgedUpTo); std::vector<store::Item*>::size_type numItemsToBuffer = pos - thePurgedUpTo; while (!theMatFinished && theItems.size() < numItemsToBuffer) { matNextItem(); } if (theItems.size() >= numItemsToBuffer) { std::vector<store::Item*>::size_type sPos = static_cast<std::vector<store::Item*>::size_type>(pos - thePurgedUpTo - 1); result = theItems[sPos]; } else { result = NULL; } }
void SchemaValidatorImpl::validateAttributes( EventSchemaValidator& schemaValidator, store::Iterator_t attributes) { store::Item_t attribute; while ( attributes->next(attribute) ) { ZORBA_ASSERT(attribute->isNode()); ZORBA_ASSERT(attribute->getNodeKind() == store::StoreConsts::attributeNode); //cout << " vup - attr: " << attribute->getNodeName()->getLocalName()-> // c_str() << "\n"; cout.flush(); store::Item_t attName = attribute->getNodeName(); schemaValidator.attr(attName, attribute->getStringValue()); } }
PlanIter_t fn_data_3_0::codegen( CompilerCB*, static_context* sctx, const QueryLoc& loc, std::vector<PlanIter_t>& argv, expr& ann) const { ZORBA_ASSERT(false); }
bool XMLtoJSONInternal::nextImpl( store::Item_t& result, PlanState &planState ) const { store::Item_t xml_item; options_type options; PlanIteratorState *state; DEFAULT_STACK_INIT( PlanIteratorState, state, planState ); ZORBA_ASSERT( theChildren.size() == 2 ); consumeNext( xml_item, theChildren[1], planState ); get_options( xml_item, &options ); consumeNext( xml_item, theChildren[0], planState ); try { options_type::mapped_type const &format_opt = options[ "json-format" ]; ZORBA_ASSERT( !format_opt.empty() ); switch ( xml_item->getNodeKind() ) { case store::StoreConsts::elementNode: if ( format_opt == "Snelson" ) snelson::xml_to_json( xml_item, &result ); else if ( format_opt == "JsonML" || format_opt == "JsonML-array" ) jsonml_array::xml_to_json( xml_item, &result ); else if ( format_opt == "JsonML-object" ) jsonml_object::xml_to_json( xml_item, &result ); else ZORBA_ASSERT( false ); break; default: throw XQUERY_EXCEPTION( zerr::ZJSE0001_NOT_ELEMENT_NODE, ERROR_LOC( loc ) ); } // switch } catch ( ZorbaException &e ) { set_source( e, loc ); throw; } STACK_PUSH( !!result, state ); STACK_END( state ); }
PlanIter_t fn_head::codegen( CompilerCB* /*cb*/, static_context* aSctx, const QueryLoc& aLoc, std::vector<PlanIter_t>& aArgs, expr& /*aAnn*/) const { ZORBA_ASSERT(false); return NULL; }
void xml_to_json( store::Item_t const &xml_item, store::Item_t *json_item ) { ZORBA_ASSERT( json_item ); switch ( xml_item->getNodeKind() ) { case store::StoreConsts::elementNode: x2j_element( xml_item, json_item ); break; default: throw XQUERY_EXCEPTION( zerr::ZJSE0001_NOT_ELEMENT_NODE ); } }
void IndexConditionImpl::pushRange( store::Item_t& lower, store::Item_t& upper, bool haveLower, bool haveUpper, bool lowerIncl, bool upperIncl) { ZORBA_ASSERT(false); }
std::ostream& UserDefinedXQType::serialize_ostream(std::ostream& os) const { std::ostringstream info; switch (theUDTKind) { case ATOMIC_UDT: { info << "isAtomic"; break; } case COMPLEX_UDT: { info << "isComplex"; break; } case LIST_UDT: { info << " isList itemType:" << m_listItemType->toString(); break; } case UNION_UDT: { csize numMembers = m_unionItemTypes.size(); info << " Union (" ; if (numMembers > 0) { for (csize i = 0; i < numMembers-1; ++i) { info << m_unionItemTypes[i]->toString() << ", "; } info << m_unionItemTypes[numMembers-1]->toString(); } info << ")"; break; } default: ZORBA_ASSERT(false); } info << " " << contentKindStr(theContentKind); return os << "[UserDefinedXQType " << TypeOps::decode_quantifier(get_quantifier()) << " " << theQName->getLocalName() << "@" << theQName->getNamespace() << " " << info.str() << " base:" << ( theBaseType ? theBaseType->toString() : "NULL" ) << "]"; }
void dynamic_context::destroy_dctx_value(dctx_value_t* val) { switch (val->type) { case dynamic_context::dctx_value_t::no_val: break; default: ZORBA_ASSERT (false); } val->type = dynamic_context::dctx_value_t::no_val; }
void dynamic_context::bindMap( store::Item* qname, store::Index_t& map) { if (theAvailableMaps == NULL) theAvailableMaps = new IndexMap(HashMapItemPointerCmp(0, NULL), 8, false); if (!theAvailableMaps->insert(qname, map)) { ZORBA_ASSERT(false); } }
NodeXQType::NodeXQType( const TypeManager* manager, store::StoreConsts::NodeKind nodeKind, const store::Item_t& nodeName, const xqtref_t& contentType, SequenceType::Quantifier quantifier, bool nillable, bool schematest, bool builtin) : XQType(manager, NODE_TYPE_KIND, quantifier, builtin), theNodeKind(nodeKind), theNodeName(nodeName), theContentType(contentType), theNillable(nillable), theIsSchemaTest(schematest) { assert(contentType == NULL || (nodeKind == store::StoreConsts::documentNode && contentType->type_kind() == NODE_TYPE_KIND) || contentType->type_kind() == ATOMIC_TYPE_KIND || contentType->type_kind() == ANY_TYPE_KIND || contentType->type_kind() == ANY_SIMPLE_TYPE_KIND || contentType->type_kind() == UNTYPED_KIND || contentType->type_kind() == USER_DEFINED_KIND); assert(contentType == NULL || contentType->get_quantifier() == SequenceType::QUANT_ONE || contentType->type_kind() == ANY_TYPE_KIND || contentType->type_kind() == ANY_SIMPLE_TYPE_KIND || contentType->type_kind() == UNTYPED_KIND); assert(nodeKind != store::StoreConsts::anyNode || (contentType == NULL || contentType->type_kind() == XQType::UNTYPED_KIND || contentType->type_kind() == XQType::ANY_TYPE_KIND)); #if 0 if (theIsBuiltin == false && nodeKind == store::StoreConsts::elementNode && contentType == NULL && nodeName == NULL) { ZORBA_ASSERT(false); } if (!theIsBuiltin) { std::cout << "allocated type " << this << " : " << toSchemaString() << std::endl; } #endif }
static void get_options( store::Item_t const &options_object, options_type *options ) { ZORBA_ASSERT( options_object->getKind() == store::Item::OBJECT ); store::Iterator_t i( options_object->getObjectKeys() ); i->open(); store::Item_t opt_key; while ( i->next( opt_key ) ) { zstring const opt_name( opt_key->getStringValue() ); store::Item_t const opt_value( options_object->getObjectValue( opt_key ) ); (*options)[ opt_name ] = opt_value->getStringValue(); } i->close(); }
static void x2j_element( store::Item_t const &element, store::Item_t *json_item ) { ZORBA_ASSERT( json_item ); store::Item_t attributes_item; vector<store::Item_t> elements; push_back( &elements, name_of( element ) ); x2j_attributes( element, &attributes_item ); if ( !!attributes_item ) elements.push_back( attributes_item ); x2j_children( element, &elements ); GENV_ITEMFACTORY->createJSONArray( *json_item, elements ); }
store::Item_t SchemaValidatorImpl::findAttributeItem(const store::Item *parent, store::Item_t &attQName) { store::Iterator_t attributes = parent->getAttributes(); store::Item_t attribute; while ( attributes->next(attribute) ) { ZORBA_ASSERT(attribute->isNode()); ZORBA_ASSERT(attribute->getNodeKind() == store::StoreConsts::attributeNode); store::Item_t currentAttName = attribute->getNodeName(); if (attQName->equals(currentAttName)) { return attribute.getp(); } } //ZORBA_ASSERT(false); return NULL; }