コード例 #1
0
ファイル: html.cpp プロジェクト: 28msec/zorba-html-module
ItemSequence_t
ParseFunction::evaluate(
    const ExternalFunction::Arguments_t& aArgs,
    const StaticContext* aSctxCtx,
    const DynamicContext* aDynCtx) const
{
  std::auto_ptr<std::istringstream> iss;
  std::istream *is;
  String docString;
  Item lStringItem, lOptionsItem;

  if (aArgs.size() >= 1)
  {
    Iterator_t lArg0Iter = aArgs[0]->getIterator();
    lArg0Iter->open();
    lArg0Iter->next(lStringItem);
    lArg0Iter->close();
  }

  if ( lStringItem.isStreamable() )
  {
    //
    // The "iss" auto_ptr can NOT be used since it will delete the stream that,
    // in this case, is a data member inside another object and not dynamically
    // allocated.
    //
    // We can't replace "iss" with "is" since we still need the auto_ptr for
    // the case when the result is not streamable.
    //
    is = &lStringItem.getStream();
  }
  else
  {
    docString = lStringItem.getStringValue();
    iss.reset (new std::istringstream(docString.c_str()));
    is = iss.get();
  }
  
  if (aArgs.size() == 2)
  {
    Iterator_t lArg1Iter = aArgs[1]->getIterator();
    lArg1Iter->open();
    lArg1Iter->next(lOptionsItem);
    lArg1Iter->close();
  }
  
  return ItemSequence_t(
  new SingletonItemSequence(createHtmlItem(*is, lOptionsItem)));
}
コード例 #2
0
ファイル: jdbc.cpp プロジェクト: 28msec/zorba-jdbc-module
Item
JdbcModule::getItemArg(const ExternalFunction::Arguments_t& args, int index) {
  Item item;
  if (index < (int)args.size()) {
    Iterator_t lIter = args[index]->getIterator();
    lIter->open();
    lIter->next(item);
    lIter->close();
  }
  return item;
}
コード例 #3
0
String FileFunction::getStringArg( ExternalFunction::Arguments_t const &args,
                                   unsigned pos ) const {
  String s;
  if ( pos < args.size() ) {
    Iterator_t it( args[ pos ]->getIterator() );
    it->open();
    Item item;
    if ( it->next( item ) )
      s = item.getStringValue();
    it->close();
  }
  return s;
}
コード例 #4
0
  ItemSequence_t
  CExternalFunction::evaluate
  (const ExternalFunction::Arguments_t& args) const
  {
    unsigned int lSequencesSize = (unsigned int)args.size();
    XQC_Sequence** lSequences = new XQC_Sequence*[lSequencesSize];

    // Wrap each Argument (which is just an ItemSequence) in a
    // CSequence, and keep an array of each corresponding
    // XQC_Sequence. These ItemSequences are being memory-managed by
    // the Zorba engine, so we request that CSequence NOT free them
    // when the CSequence is deleted.
    for (unsigned int i = 0; i < lSequencesSize; ++i) {
      std::unique_ptr<CSequence> lSeq(new CSequence(args[i], false, NULL));
      lSequences[i] = lSeq.release()->getXQC();
    }

    return ItemSequence_t(new UserItemSequence(lSequences, lSequencesSize, 
        theInitFunction, theNextFunction, theFreeFunction,
        theFunctionUserData, theFactory, theErrorHandler));
  }