Пример #1
0
bool PromoteIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
  store::Item_t item;
  store::Item_t temp;

  const TypeManager* tm = theSctx->get_typemanager();

  PlanIteratorState* state;
  DEFAULT_STACK_INIT(PlanIteratorState, state, planState);

  if (!consumeNext(item, 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");
    }

    // catch exceptions to add/change the error location
    if (! GenericCast::promote(result, item, thePromoteType, &theNsCtx, tm, loc))
    {
      zstring valueType = tm->create_value_type(item)->toSchemaString();
      raiseError(valueType);
    }

    STACK_PUSH(true, state);
  }
  else
  {
    do
    {
      if (! GenericCast::promote(result, item, thePromoteType, &theNsCtx, tm, loc))
      {
        zstring valueType = tm->create_value_type(item)->toSchemaString();
        raiseError(valueType);
      }
      else
      {
        STACK_PUSH(true, state);
      }
    }
    while (consumeNext(item, theChild.getp(), planState));
  }

  STACK_END(state);
}
Пример #2
0
static void op_not(void)
{
	int val;

	if (stack.sp < 1)
		return;

	STACK_POP(val);

	if (val)
		STACK_PUSH(0);
	else
		STACK_PUSH(1);
}
Пример #3
0
void Row_mvcc::buffer_req(TsType type, TxnManager * txn)
{
	MVReqEntry * req_entry = get_req_entry();
	assert(req_entry != NULL);
	req_entry->txn = txn;
	req_entry->ts = txn->get_timestamp();
	req_entry->starttime = get_sys_clock();
	if (type == R_REQ) {
		rreq_len ++;
		STACK_PUSH(readreq_mvcc, req_entry);
	} else if (type == P_REQ) {
		preq_len ++;
		STACK_PUSH(prereq_mvcc, req_entry);
	}
}
Пример #4
0
bool CastableIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
  bool res;
  store::Item_t item;

  TypeManager* tm = theSctx->get_typemanager();

  PlanIteratorState* state;
  DEFAULT_STACK_INIT(PlanIteratorState, state, planState);

  if (!consumeNext(item, theChild.getp(), planState))
  {
    res = theAllowEmpty;
  }
  else
  {
    res = GenericCast::isCastable(item, theCastType, tm);

    if (consumeNext(item, theChild.getp(), planState))
    {
      res = false;
    }
  }

  STACK_PUSH(GENV_ITEMFACTORY->createBoolean(result, res), state);
  STACK_END(state);
}
Пример #5
0
bool
DeleteIterator::nextImpl(store::Item_t& result, PlanState& aPlanState) const
{ 
  store::Item_t target;
  std::unique_ptr<store::PUL> pul;

  PlanIteratorState* state;
  DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);

  pul.reset(GENV_ITEMFACTORY->createPendingUpdateList());

  while (consumeNext(target, theChild, aPlanState))
  {
    if (!target->isNode())
      throw XQUERY_EXCEPTION( err::XUTY0007, ERROR_LOC( loc ) );

    areNodeModifiersViolated(theSctx, target, loc);

    pul->addDelete(&loc, target);

  }
  result = pul.release();
  STACK_PUSH(true, state);
  STACK_END(state);
}
Пример #6
0
/*******************************************************************************
  declare function
  is-available-document($uri as xs:string) as xs:boolean
********************************************************************************/
bool IsAvailableDocumentIterator::nextImpl(
    store::Item_t& result,
    PlanState& aPlanState) const
{
  zstring       lRetrievedUriString;
  zstring       lResolvedUriString;
  store::Item_t lUri;

  PlanIteratorState* state;
  DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);

  consumeNext(lUri, theChildren[0].getp(), aPlanState);

  // absolutize retrieved uri
  try
  {
    lUri->getStringValue2(lRetrievedUriString);
    lResolvedUriString = theSctx->resolve_relative_uri(lRetrievedUriString, true);
  }
  catch (ZorbaException const&)
  {
    RAISE_ERROR(err::FODC0004, loc,
    ERROR_PARAMS(lResolvedUriString, ZED(NoResolveRelativeURI)));
  }

  // check if document exists in the store
  GENV_ITEMFACTORY->
  createBoolean(result, GENV_STORE.getDocument(lResolvedUriString) != NULL);

  STACK_PUSH(true, state);

  STACK_END(state);
}
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);
}
Пример #8
0
bool JSoundValidateIterator::nextImpl( store::Item_t &result,
                                       PlanState &plan_state ) const {
  bool cast = cast_default;
  store::Item_t jsd_item, type_item, json_item, options_item;

  PlanIteratorState *state;
  DEFAULT_STACK_INIT( PlanIteratorState, state, plan_state );

  consumeNext( jsd_item, theChildren[0], plan_state );
  consumeNext( type_item, theChildren[1], plan_state );
  consumeNext( json_item, theChildren[2], plan_state );
  consumeNext( options_item, theChildren[3], plan_state );

  try {
    get_bool_opt( options_item, "cast-atomic-values", &cast );
    jsound::schema const schema( jsd_item );
    GENV_ITEMFACTORY->createBoolean(
      result, schema.validate( json_item, type_item->getStringValue(), cast )
    );
  }
  catch ( ZorbaException &e ) {
    set_source( e, loc, false );
    throw;
  }

  STACK_PUSH( true, state );
  STACK_END( state );
}
Пример #9
0
bool OpNumericUnaryIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
  store::Item_t item;
  store::SchemaTypeCode type;

  const TypeManager* tm = theSctx->get_typemanager();

  PlanIteratorState* state;
  DEFAULT_STACK_INIT(PlanIteratorState, state, planState);

  if (consumeNext(item, theChild.getp(), planState ))
  {
    assert(item->isAtomic());

    type = item->getTypeCode();

    if (type == store::XS_UNTYPED_ATOMIC)
    {
      GenericCast::castToBuiltinAtomic(item, item, store::XS_DOUBLE, NULL, loc);
      type = store::XS_DOUBLE;
    }
    
    // TODO Optimizations (e.g. if item has already the correct type and value,
    // it does not have to be created newly)
    if (TypeOps::is_subtype(type, store::XS_DOUBLE))
    {
      GENV_ITEMFACTORY->
      createDouble(result,
                   (thePlus ? item->getDoubleValue() : -item->getDoubleValue()));
    }
    else if (TypeOps::is_subtype(type, store::XS_FLOAT))
    {
      GENV_ITEMFACTORY->
      createFloat(result,
                  (thePlus ? item->getFloatValue() : -item->getFloatValue()));
    }
    else if (TypeOps::is_subtype(type, store::XS_INTEGER))
    {
      GENV_ITEMFACTORY->
      createInteger(result,
                    (thePlus ? item->getIntegerValue() : -item->getIntegerValue()));
    }
    else if (TypeOps::is_subtype(type, store::XS_DECIMAL))
    {
      GENV_ITEMFACTORY->
      createDecimal(result,
                   (thePlus ? item->getDecimalValue() : -item->getDecimalValue()));
    }
    else
    {
      xqtref_t type = tm->create_value_type(item);
      RAISE_ERROR(err::XPTY0004, loc,
      ERROR_PARAMS(ZED(BadTypeFor_23), type->toSchemaString(), ZED(UnaryArithOp)));
    }
    
    STACK_PUSH(true, state);
  }

  STACK_END(state);
}
Пример #10
0
bool
IndexKeysIterator::nextImpl(
    store::Item_t& result,
    PlanState& aPlanState) const
{
  store::Item_t    lQName;
  IndexDecl_t      indexDecl;
  store::IndexKey  lKey;

  store::Item_t lKeyNodeName;
  GENV_ITEMFACTORY->createQName(lKeyNodeName,
      static_context::ZORBA_STORE_UNORDERED_MAPS_FN_NS,
      "", "key");

  IndexKeysIteratorState* state;
  DEFAULT_STACK_INIT(IndexKeysIteratorState, state, aPlanState);

  consumeNext(lQName, theChildren[0].getp(), aPlanState);

  if ((indexDecl = theSctx->lookup_index(lQName)) == NULL)
  {
    throw XQUERY_EXCEPTION(
      zerr::ZDDY0021_INDEX_NOT_DECLARED,
      ERROR_PARAMS( lQName->getStringValue() ),
      ERROR_LOC( loc )
    );
  }

  state->theIndex = GENV_STORE.getIndex(lQName);

  if (!state->theIndex)
  {
    throw XQUERY_EXCEPTION(
      zerr::ZDDY0023_INDEX_DOES_NOT_EXIST,
      ERROR_PARAMS( lQName->getStringValue() ),
      ERROR_LOC( loc )
    );
  }

  state->theIter = state->theIndex->keys();

  state->theIter->open();

  // generate result elements of the form
  // <key>
  //   <attribute value="key1_value"/>
  //   <attribute value="key2_value"/>
  //   <attribute value="key3_value"/>
  // </key>
  while (state->theIter->next(lKey))
  {
    IndexUtil::createIndexKeyElement(
        state->theIndex->getSpecification().theIsGeneral,
        result, lKey, static_context::ZORBA_STORE_STATIC_INDEXES_DML_FN_NS
      );
    STACK_PUSH(true, state);
  }

  STACK_END(state);
}
Пример #11
0
bool SpecificNumArithIterator<Operation, Type>::nextImpl(
    store::Item_t& result,
    PlanState& planState) const
{
  bool res;
  store::Item_t n0;
  store::Item_t n1;
  
  PlanIteratorState* state;
  DEFAULT_STACK_INIT(PlanIteratorState, state, planState);

  if (this->consumeNext(n0, this->theChild0.getp(), planState))
  {
    if (this->consumeNext(n1, this->theChild1.getp(), planState))
    {
      assert(n0->isAtomic());
      assert(n1->isAtomic());

      res = Operation::template 
      computeSingleType<Type>(result, NULL, NULL, &this->loc, n0.getp(), n1.getp());

      STACK_PUSH(res, state);
    }
  }
  STACK_END(state);
}
Пример #12
0
bool NumArithIterator<Operation>::nextImpl(
    store::Item_t& result,
    PlanState& planState) const
{
  bool res;
  store::Item_t n0;
  store::Item_t n1;
  
  PlanIteratorState* state;
  DEFAULT_STACK_INIT(PlanIteratorState, state, planState);

  if (this->consumeNext(n0, this->theChild0.getp(), planState))
  {
    if (this->consumeNext(n1, this->theChild1.getp(), planState))
    {
      res = compute(result,
                    planState.theLocalDynCtx,
                    this->theSctx->get_typemanager(),
                    this->loc,
                    n0,
                    n1);

      STACK_PUSH(res, state);
    }
  }

  STACK_END(state);
}
Пример #13
0
bool
ZorbaValidateInPlaceIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
  store::Item_t node;

  PlanIteratorState* state;
  store::PUL_t pul;

  DEFAULT_STACK_INIT(PlanIteratorState, state, planState);

  if (consumeNext(node, theChild.getp(), planState))
  {
    // verify that if the element being revalidated is an element it is the root
    if (node->getNodeKind()==store::StoreConsts::elementNode &&
        node->getParent() &&
        node->getParent()->getNodeKind()!=store::StoreConsts::documentNode)
      throw XQUERY_EXCEPTION( zerr::ZAPI0090_CANNOT_VALIDATE_NON_ROOT, ERROR_LOC( loc ) );

    pul = GENV_ITEMFACTORY->createPendingUpdateList();

    pul->addRevalidate(&loc,node);

    result.transfer(pul);
    STACK_PUSH(true, state);
  }

  STACK_END(state);
}
Пример #14
0
static void
push(void **block)
{
	void *obj = *block;
	struct segment *seg;
	size_t index;
	bitptr_t b;

	if (!IS_IN_HEAP(obj)) {
		DBG(("%p at %p outside", obj, block));
		if (obj != NULL)
			sml_trace_ptr(obj);
		return;
	}

	seg = OBJ_TO_SEGMENT(obj);
	index = OBJ_TO_INDEX(seg, obj);
	BITPTR_INIT(b, BITMAP0_BASE(seg), index);
	if (BITPTR_TEST(b)) {
		DBG(("already marked: %p", obj));
		return;
	}
	MARKBIT(b, index, seg);
	DBG(("MARK: %p", obj));

	if (OBJ_HAS_NO_POINTER(obj)) {
		DBG(("EARLYMARK: %p", obj));
		return;
	}

	STACK_PUSH(obj, seg, index);
	DBG(("PUSH: %p", obj));
}
Пример #15
0
static void
push_object (SCHEME_OBJECT object)
{
  stack_pointer = ((SCHEME_OBJECT *) (WREG_REF (SVM1_REG_STACK_POINTER)));
  STACK_PUSH (object);
  WREG_SET (SVM1_REG_STACK_POINTER, ((SCHEME_OBJECT) stack_pointer));
}
Пример #16
0
bool ForIterator::nextImpl(store::Item_t& aResult, PlanState& aPlanState) const 
{
  ForState* lState;
  store::Item_t lItem;
      
  DEFAULT_STACK_INIT(ForState, lState, aPlanState);

  while (consumeNext(aResult, theChild0, aPlanState)) 
  {
    while (consumeNext(lItem, theChild1, aPlanState)) 
    {
      bindVariables(lItem, theVarRefs, aPlanState);

      if (theHasPosVars) 
      {
        store::Item_t lPosItem;
        GENV_ITEMFACTORY->createInteger(lPosItem,
                                        xs_integer(lState->incReturnPosition()));
        bindVariables(lPosItem, thePosVarRefs, aPlanState);
      }
      STACK_PUSH(true, lState);
    }

    lState->resetPosition();

    theChild1->reset(aPlanState);
  }

  STACK_END(lState);
}
Пример #17
0
bool
IsFollowingSiblingPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
  store::Item_t lUriA;
  store::Item_t lUriB;

  PlanIteratorState* state;
  DEFAULT_STACK_INIT(PlanIteratorState, state, planState);

  consumeNext(lUriA, theChildren[0].getp(), planState);
  consumeNext(lUriB, theChildren[1].getp(), planState);

  try
  {
    GENV_ITEMFACTORY->createBoolean(result, lUriA->isFollowingSibling(lUriB));
  }
  catch (ZorbaException& e)
  {
    set_source(e, loc);
    throw;
  }

  STACK_PUSH(true,state);

  STACK_END (state);
}
Пример #18
0
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 );
}
Пример #19
0
static void op_greater(void)
{
	int val1;
	int val2;

	if (stack.sp < 2)
		return;

	STACK_POP(val1);
	STACK_POP(val2);

	if (val2 > val1)
		STACK_PUSH(1);
	else
		STACK_PUSH(0);
}
Пример #20
0
static void op_duplicate(void)
{
	if (stack.sp < 1)
		return;

	STACK_PUSH(stack.array[stack.sp-1]);
}
Пример #21
0
int fn_read(_kforth_context *context)
{
    platform_printf("Reading From 0x%08X\r\n", STACK(0));
    STACK_POP();
    STACK_PUSH(0);
    return 0;
}
Пример #22
0
bool IfThenElseIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
  IfThenElseIteratorState* state;
  DEFAULT_STACK_INIT(IfThenElseIteratorState, state, planState);

  if (theIsBooleanIter) 
  {
    store::Item_t condResult;
    consumeNext ( condResult, theCondIter.getp(), planState );
    state->theThenUsed = condResult->getBooleanValue();
  }
  else
  {
    state->theThenUsed = FnBooleanIterator::effectiveBooleanValue(this->loc,
                                                                  planState,
                                                                  theCondIter);
  }

  while (true)
  {
    STACK_PUSH(consumeNext(result,
                           (state->theThenUsed ? theThenIter.getp() : theElseIter.getp()),
                           planState), 
               state);
  }

  STACK_END(state);
}
static void initSystem(LaplacianDeformModifierData *lmd, Object *ob, DerivedMesh *dm,
                       float (*vertexCos)[3], int numVerts)
{
	int i;
	int defgrp_index;
	int total_anchors;
	float wpaint;
	MDeformVert *dvert = NULL;
	MDeformVert *dv = NULL;
	LaplacianSystem *sys;

	if (isValidVertexGroup(lmd, ob, dm)) {
		int *index_anchors = MEM_mallocN(sizeof(int) * numVerts, __func__);  /* over-alloc */
		const MLoopTri *mlooptri;
		const MLoop *mloop;

		STACK_DECLARE(index_anchors);

		STACK_INIT(index_anchors, numVerts);

		modifier_get_vgroup(ob, dm, lmd->anchor_grp_name, &dvert, &defgrp_index);
		BLI_assert(dvert != NULL);
		dv = dvert;
		for (i = 0; i < numVerts; i++) {
			wpaint = defvert_find_weight(dv, defgrp_index);
			dv++;
			if (wpaint > 0.0f) {
				STACK_PUSH(index_anchors, i);
			}
		}
		DM_ensure_looptri(dm);
		total_anchors = STACK_SIZE(index_anchors);
		lmd->cache_system = initLaplacianSystem(numVerts, dm->getNumEdges(dm), dm->getNumLoopTri(dm),
		                                       total_anchors, lmd->anchor_grp_name, lmd->repeat);
		sys = (LaplacianSystem *)lmd->cache_system;
		memcpy(sys->index_anchors, index_anchors, sizeof(int) * total_anchors);
		memcpy(sys->co, vertexCos, sizeof(float[3]) * numVerts);
		MEM_freeN(index_anchors);
		lmd->vertexco = MEM_mallocN(sizeof(float[3]) * numVerts, "ModDeformCoordinates");
		memcpy(lmd->vertexco, vertexCos, sizeof(float[3]) * numVerts);
		lmd->total_verts = numVerts;

		createFaceRingMap(
		            dm->getNumVerts(dm), dm->getLoopTriArray(dm), dm->getNumLoopTri(dm),
		            dm->getLoopArray(dm), &sys->ringf_map, &sys->ringf_indices);
		createVertRingMap(
		            dm->getNumVerts(dm), dm->getEdgeArray(dm), dm->getNumEdges(dm),
		            &sys->ringv_map, &sys->ringv_indices);


		mlooptri = dm->getLoopTriArray(dm);
		mloop = dm->getLoopArray(dm);

		for (i = 0; i < sys->total_tris; i++) {
			sys->tris[i][0] = mloop[mlooptri[i].tri[0]].v;
			sys->tris[i][1] = mloop[mlooptri[i].tri[1]].v;
			sys->tris[i][2] = mloop[mlooptri[i].tri[2]].v;
		}
	}
}
Пример #24
0
bool SeqValueIntersectIterator::nextImpl( store::Item_t &result,
                                          PlanState &plan_state ) const {
  XQPCollator *const coll = theSctx->get_default_collator( loc );
  store::Item_t item;
  TypeManager *const tm = getTypeManager();
  long tz;

  SeqValueIntersectIteratorState *state;
  DEFAULT_STACK_INIT( SeqValueIntersectIteratorState, state, plan_state );

  tz = plan_state.theLocalDynCtx->get_implicit_timezone();

  state->set_[0] = new_Item_set( tm, tz, coll, loc );
  state->set_[1] = new_Item_set( tm, tz, coll, loc );

  while ( consumeNext( item, theChildren[0], plan_state ) )
    if ( state->set_[0]->insert( item.getp() ).second )
      item->addReference();

  while ( consumeNext( item, theChildren[1], plan_state ) )
    if ( ztd::contains( *state->set_[0], item.getp() ) &&
         state->set_[1]->insert( item.getp() ).second ) {
      item->addReference();
      result = item;
      STACK_PUSH( true, state );
    }

  delete_Item_set( state->set_[0] );
  delete_Item_set( state->set_[1] );
  STACK_END( state );
}
Пример #25
0
int StartElement(void *UserData, const XMLCH *uri, const XMLCH *localName, const XMLCH *qName, LPXMLVECTOR atts)
{	
	XMLCONFPARSER *xcp = (XMLCONFPARSER*)UserData;
	LPXMLRUNTIMEATT att;
	int *pstate = STACK_PEEK(xcp->stateStack);
	xcp->state = (pstate) ? *pstate : NONE;
	
	if (xcp->inMixedContent || xcp->state == TEST) { 
		/* + other tags that allow mixed content tested here */
		/* if we're in mixed content, we don't bother to use stack, just
		   incrementing (and decrementing in EndElement) the counter: */
		xcp->inMixedContent++;	
		/* could call mixed content legal tag check routine here e.g.
		if (!isvalidmixedcontent(state, qName)) return sin(); */
		fprintf(PFOUT, "<%s>", qName);
		return 0;
	}
	
	if (xcp->state == NONE && !strcmp(qName, "TESTSUITE")) { 
		
		if (att = XMLParser_GetNamedItem(xcp->parser, "PROFILE"))
			fprintf(PFOUT, "<h1><b>%s</b></h1><br><h3>Parsifal XML Parser %s</h3>", 
				att->value, XMLParser_GetVersionString());		
		xcp->state = TESTSUITE;
	}
	else if (xcp->state == TESTSUITE && !strcmp(qName, "TESTCASES")) {
		
		if (att = XMLParser_GetNamedItem(xcp->parser, "PROFILE")) {
			/* new testcase, spit out the profile header: */
			fprintf(PFOUT, "<br><br><h2>Testcase profile: <b>%s</b></h2><br>", att->value);
			fputs("<table cellspacing='0'>", PFOUT); /* open table for results */
		}
		xcp->state = TESTCASES;
	}
	else if (xcp->state == TESTCASES) {
		
		if (!strcmp(qName, "TEST")) {			
			if (att = XMLParser_GetNamedItem(xcp->parser, "URI")) {
				/* new test, run it: */
				if (!RunTest(xcp, att->value))
					fprintf(PFERR, "Fatal Error running test: %s\n", att->value);
			}
			xcp->state = TEST;
		}
		else if (!strcmp(qName, "TESTCASES")) { /* for some reason

			there's TESTCASES inside TESTCASES in ibm tests,
			so it must ust be handled here: */
			xcp->state = TESTCASES;
		}
	}
	else {
		fprintf(PFERR, "Unexpected tag: %s\n", qName);
		return XML_ABORT;
	}

	STACK_PUSH(xcp->stateStack, &xcp->state);
	return 0;
}
Пример #26
0
/*******************************************************************************
  14.9.2 fn:parse-xml-fragment
********************************************************************************/
bool FnParseXmlFragmentIterator::nextImpl(
    store::Item_t& result,
    PlanState& planState) const
{
  zstring docString;

  FnParseXmlFragmentIteratorState* state;
  DEFAULT_STACK_INIT(FnParseXmlFragmentIteratorState, state, planState);

  if (consumeNext(result, theChildren[0].getp(), planState))
  {
    if (result->isStreamable())
    {
      state->theFragmentStream.theStream = &result->getStream();
    }
    else
    {
      result->getStringValue2(docString);
      state->theFragmentStream.theIss = new std::istringstream(docString.c_str());
      state->theFragmentStream.theStream = state->theFragmentStream.theIss;
    }

    state->theProperties.setBaseUri(theSctx->get_base_uri());
    state->theProperties.setParseExternalParsedEntity(true);
    state->theProperties.setStoreDocument(false);

    state->baseUri = state->theProperties.getBaseUri();    

    // create only one document node holding all fragment nodes
    state->theFragmentStream.only_one_doc_node = 1;
       
    try
    {
      result = GENV.getStore().loadDocument(state->baseUri,
                                            state->docUri,
                                            state->theFragmentStream,
                                            state->theProperties);
    }
    catch ( ZorbaException const &e )
    {
      if ( !state->theProperties.getNoError() )
      {
        XQueryException xe(
          XQUERY_EXCEPTION(err::FODC0006,
          ERROR_PARAMS( "fn:parse-xml-fragment()", e.what() ),
          ERROR_LOC( loc )));

        set_data( xe, e );
        throw xe;
      }
      result = nullptr;
    }

    if (result != NULL)
      STACK_PUSH(true, state);
  } // if 

  STACK_END(state);
}
Пример #27
0
bool AvailableDocumentsIterator::nextImpl(
    store::Item_t& result,
    PlanState& aPlanState) const
{
  AvailableDocumentsIteratorState* state;
  DEFAULT_STACK_INIT(AvailableDocumentsIteratorState, state, aPlanState);

  state->theNameIterator = GENV_STORE.getDocumentNames();
  state->theNameIterator->open();
  while (state->theNameIterator->next(result)) 
  {
    STACK_PUSH( true, state);
  }

  STACK_PUSH(false, state);

  STACK_END(state);
}
Пример #28
0
bool SingletonIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
  PlanIteratorState* state;
  DEFAULT_STACK_INIT(PlanIteratorState, state, planState);

  result = theValue;
  STACK_PUSH ( result != NULL, state );
  STACK_END (state);
}
Пример #29
0
void TreeHarnessTest ( enum TreeType treetype ) {
	int push_code = 0 ; 
	int nodeID = 0 ;

	for ( i = 0; i< LEAVES; i++ ) {
		thisTree = rootTree = PTRTREE_NODE_CREATE ( ) ;
		sret = sprintf ( ST_BUFFER, "\'%d (root)\'" , nodeID ) ;
		PTRTREE_SET ( rootTree, NULL , NULL, NULL, nodeID++, ST_BUFFER ) ; 
						if ( DEBUG ) {
					printf ( "\n**New tree for i=%d is: %p \n" , i , rootTree) ;
					PTRTREE_DUMP ( rootTree ) ; 
					} ;
		for ( j = 0; j <= i; j++ ) {	
			// build trees of depth j to put in ith slot
			sret = sprintf ( ST_BUFFER, "\'%d,%d\'" , 
				PTRTREE_NODE_ID ( rootTree ) , 
				nodeID
				) ;
			switch ( treetype ) {
				case WIDETREE : { 
						if ( DEBUG ) { printf ( "in WideTree\n" ) ; }
					PTRTREE_NODE_ADD_THISTREE ( rootTree , nodeID++ , ST_BUFFER ) ;
						if ( DEBUG ) { PTRTREE_DUMP ( rootTree ) ; } ; 
					break ; 
					}
				case LONGTREE : { 
						if ( DEBUG ) { printf ( "in LONGTREE\n" ) ; }
					PTRTREE_NODE_ADD_THISTREE ( thisTree , nodeID++ , ST_BUFFER ) ;
					PTRTREE_NODE_ADD_THISTREE ( thisTree , nodeID++ , ST_BUFFER ) ;
					thisTree = thisTree -> _PTRTREE_NODE_CHILD ; 
						if ( DEBUG ) { PTRTREE_DUMP ( rootTree ) ; } ; 
					break ;
					}
				case FULLTREE : { 
						if ( DEBUG ) { printf ( "in FULLTREE\n" ) ; }
					int k = 0;
					for ( k=0 ; k<=j ; k++ ) {	
						PTRTREE_NODE_ADD_THISTREE ( thisTree , nodeID++ , ST_BUFFER ) ;	
						}
					thisTree = thisTree -> _PTRTREE_NODE_CHILD ; 
					if ( DEBUG ) { PTRTREE_DUMP ( rootTree ) ; } ; 
					break ; 
					}
				}  // end of switch
			} ; // inner, j loop
					if ( DEBUG ) { STACK_DUMP ( &randomForest ) ; }
			push_code = STACK_PUSH ( &randomForest , rootTree ) ; 		
			if ( push_code ) {
				printf ( "\nERROR STACK_PUSH failed (%d)\n" , MaxErrCode ) ;
				exit ( MaxErrCode ) ;  
				} ; 
		} ; // outer, i loop
	} ; // end of tree harness
Пример #30
0
static void op_in_char(void)
{
	char val;
	int rc;

	rc = fscanf(stdin, "%c", &val);
	if (rc != 1) {
		printf("user input error\n");
		exit(1);
	}
	STACK_PUSH(val);
}