当前位置: 首页>>代码示例>>C++>>正文


C++ Iterator_t::next方法代码示例

本文整理汇总了C++中Iterator_t::next方法的典型用法代码示例。如果您正苦于以下问题:C++ Iterator_t::next方法的具体用法?C++ Iterator_t::next怎么用?C++ Iterator_t::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Iterator_t的用法示例。


在下文中一共展示了Iterator_t::next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: evaluate

  ItemSequence_t evaluate(const ExternalFunction::Arguments_t& args) const
  {
    Item item;
    int64_t sum1 = 0;
    int64_t sum2 = 0;

    Iterator_t iter = args[0]->getIterator();
    iter->open();
    while (iter->next(item))
      sum1 += item.getLongValue();
    iter->close();

    //iter = args[0]->getIterator();
    iter->open();
    while (iter->next(item))
      sum2 += item.getLongValue();
    iter->close();

    if (sum1 != sum2)
    {
      std::cerr << "sum1 = " << sum1 << "  sum2 = " << sum2 << std::endl;
      throw std::exception();
    }

    return ItemSequence_t(new EmptySequence());
  }
开发者ID:alyst,项目名称:zorba,代码行数:26,代码来源:external_function.cpp

示例2: while

void
CClientMimeHandler::begin(const Item& aMimeItem)
{
    Iterator_t lChildIter;

    //initialize ENVELOPE
    theEnvelope = mail_newenvelope ();

    //initialize BODY
    theBody = mail_newbody ();
    mail_initbody(theBody);

    //set theMessageItem
    lChildIter = aMimeItem.getChildren();
    lChildIter->open();

    // read envelope and body elements but skip non-element nodes
    while (lChildIter->next(theEnvelopeItem)) {
        if (theEnvelopeItem.getNodeKind() == store::StoreConsts::elementNode) {
            break;
        }
    }
    while (lChildIter->next(theBodyItem)) {
        if (theBodyItem.getNodeKind() == store::StoreConsts::elementNode) {
            break;
        }
    }

    lChildIter->close();
}
开发者ID:28msec,项目名称:zorba-email-module,代码行数:30,代码来源:mime_handler.cpp

示例3: while

void
GraphvizFunction::printTypeAndAttr(
    ItemFactory* aFactory,
    const Item& in,
    std::fstream& os)
{
  Item lItem;
  Item lTypeQName = aFactory->createQName("", "", "type");
  Item lAttrQName = aFactory->createQName("", "", "attr");

  Iterator_t lChildren = in.getChildren();

  lChildren->open();
  while (lChildren->next(lItem)) {

    // needed?
    if (!lItem.isNode())
      continue;

    Item lNodeName;
    lItem.getNodeName(lNodeName);
    
    if (lNodeName.getLocalName() != lAttrQName.getLocalName()) {
      Item lNameAttr;
      if (!getAttribute(aFactory, "name", lItem, lNameAttr)) {
        GraphvizFunction::throwErrorWithQName(aFactory, "IM003", "GXL parse error: attr node does not have a name attribute");
      }

      os << "    \"" << lNameAttr.getStringValue() << "\"=\"";

      // get the values of all bool, string, float, and int elements
      Iterator_t lAttrChildren = lItem.getChildren();
      Item lChild;
      lAttrChildren->open();
      while (lAttrChildren->next(lChild)) {
        if (!lChild.isNode())
          continue;

        Item lNodeName;
        lChild.getNodeName(lNodeName);
        String lChildName = lNodeName.getLocalName();
        if ( (lChildName == "bool") || (lChildName == "string")
             || (lChildName == "float") || (lChildName == "int")) {
          os << lChild.getStringValue();
        }
      }

      os << "\"" << std::endl;
      
    } else if (lNodeName.getStringValue() == lTypeQName.getStringValue()) {
      Item lHRefAttr;
      if (!getAttribute(aFactory, "href", lItem, lHRefAttr)) {
        GraphvizFunction::throwErrorWithQName(aFactory, "IM003", "GXL parse error: type node does not have a href attribute");
      }

      os << "    _gxl_type=\"" << lHRefAttr.getStringValue() << "\"" << std::endl;
    }
  }
}
开发者ID:28msec,项目名称:zorba-graphviz-module,代码行数:59,代码来源:graphviz.cpp

示例4: if

void
CClientMimeHandler::body()
{
    theBody->type = TYPEOTHER;

    Iterator_t lChildIter;
    Item lChild;
    String lNodeName;

    lChildIter = theBodyItem.getChildren();
    lChildIter->open();
    while (lChildIter->next(lChild)) {
        if (lChild.getNodeKind() != store::StoreConsts::elementNode) {
            continue;
        }

        getNodeName(lChild, lNodeName);

        if (lNodeName == "content") {
            parse_content(theBody, lChild);
        }
        else if (lNodeName == "multipart") {
            parse_multipart(theBody, lChild);
        }
    }
    lChildIter->close();
}
开发者ID:28msec,项目名称:zorba-email-module,代码行数:27,代码来源:mime_handler.cpp

示例5: lSequence

// test for bug #3085093 "ZorbaError not caught in SerializerImpl::serialize"
bool
test_serialization_error(Zorba* aZorba)
{
  XQuery_t lQuery = aZorba->compileQuery("<a a='1'/>/@a"); 

  Zorba_SerializerOptions_t lOptions;
  Serializer_t lSerializer = Serializer::createSerializer(lOptions);

  Iterator_t lIterator = lQuery->iterator();

  try {
    lIterator->open();

    Item lItem;
    while ( lIterator->next(lItem) ) {
      // we have to wrap the item in a Serializable object
      SingletonItemSequence lSequence(lItem);
      lSerializer->serialize(&lSequence, std::cout);
    }

    lIterator->close();

  } catch (ZorbaException& e) {
    std::cerr << e << std::endl;
    lIterator->close();
    return true;
  }
	return false;
}
开发者ID:alyst,项目名称:zorba,代码行数:30,代码来源:serializer.cpp

示例6:

/**
 * Test accessing a JSONArray's members
 */
bool
example_1(Zorba* aZorba)
{
  Iterator_t lIterator;
  XQuery_t lQuery = aZorba->compileQuery("[ 1, 2, 3 ]");
  lIterator = lQuery->iterator();
  lIterator->open();
  Item lItem;
  lIterator->next(lItem);

  // Ensure we got a JSON array
  if (!lItem.isJSONItem() ||
      lItem.getJSONItemKind() != store::StoreConsts::jsonArray) {
    std::cerr << "Item is not JSON Array!" << std::endl;
    return false;
  }

  // Ensure array has 3 integer members
  uint64_t lSize = lItem.getArraySize();
  if (lSize != 3) {
    std::cerr << lSize << " array members returned, expecting 3" << std::endl;
    return false;
  }
  for(uint64_t i = 1; i <= lSize; ++i)
  {
    Item lMember = lItem.getArrayValue(i);
    // This will throw an exception if the item isn't an integer
    std::cout << lMember.getLongValue() << std::endl;
  }
  lIterator->close();

  return true;
}
开发者ID:zorba-processor,项目名称:zorba,代码行数:36,代码来源:jsoniq.cpp

示例7: while

bool
xmldatamanager_example_5(Zorba* aZorba, XmlDataManager* aDataManager)
{
  try {
    std::stringstream lStream;
    lStream
    << "<book><title>XQuery From The Experts</title></book>"
    << "<book><title>XQuery Kick Start</title></book>"
    << "<book><title>Querying XML</title></book>";

    XmlDataManager::ParseOptions lOptions;
    lOptions.setExternalEntityProcessing(true);

    ItemSequence_t lSeq = aDataManager->parseXML(lStream, lOptions);
    Iterator_t lIter = lSeq->getIterator();
    lIter->open();
    Item lItem;
    while (lIter->next(lItem)) {
      std::cout << "element " << lItem.getStringValue() << std::endl;
    }

  } catch (ZorbaException& e) {
    std::cerr << e << std::endl;
    return false;
  }
  return true;
}
开发者ID:buchenberg,项目名称:zorba,代码行数:27,代码来源:xmldatamanager.cpp

示例8: lIn

bool 
cxx_api_changes_test4(Zorba* aZorba)
{
  try
  {
    std::ifstream lIn("cxx_api_ch4.xq");
    assert(lIn.good());

    StaticContext_t lStaticContext = aZorba->createStaticContext();
    std::vector<String> lModulePaths;
    lModulePaths.push_back(zorba::CMAKE_BINARY_DIR+"/TEST_URI_PATH/");
    lStaticContext->setModulePaths(lModulePaths);
    
    XQuery_t lQuery = aZorba->compileQuery(lIn, lStaticContext);
    std::vector<Item> lVars;
    Iterator_t varsIte;
    lQuery->getExternalVariables(varsIte);

    varsIte->open();
    Item temp;
    while(varsIte->next(temp))
      lVars.push_back(temp);
    varsIte->close();

    if (lVars.size() != 3)
      return false;

    std::ostringstream lOut;
    std::vector<Item>::const_iterator lIte = lVars.begin();
    std::vector<Item>::const_iterator lEnd = lVars.end();
    
    for (; lIte != lEnd; ++lIte)
    {
      lOut << lIte->getStringValue() << " ";
    }

    std::string out = lOut.str();

    if (out != "testGetExtVarA:ext a testGetExtVarB:ext " &&
        out != "testGetExtVarB:ext a testGetExtVarA:ext " &&
        out != "a testGetExtVarA:ext testGetExtVarB:ext " &&
        out != "a testGetExtVarB:ext testGetExtVarA:ext " &&
        out != "testGetExtVarA:ext testGetExtVarB:ext a " &&
        out != "testGetExtVarB:ext testGetExtVarA:ext a ")
      return false;
  }
  catch (XQueryException& qe)
  {
    std::cerr << qe << std::endl;
    return false;
  }
  catch (ZorbaException& e)
  {
    std::cerr << e << std::endl;
    return false;
  }

  return true;
}
开发者ID:alyst,项目名称:zorba,代码行数:59,代码来源:cxx_api_changes.cpp

示例9: lIn

/**
 * test that declaredIndexes doesn't return temporary indexes and crashes
 * if one tries to create one
 */
bool
staticcollectionmanager6(zorba::Zorba* z)
{
  try {
    std::ifstream lIn("module1.xq");

    zorba::XQuery_t lQuery = z->createQuery();
    Zorba_CompilerHints lHints;
    lQuery->compile(lIn, lHints);

    StaticCollectionManager* lColMgr = lQuery->getStaticCollectionManager();

    ItemFactory* lFac = z->getItemFactory();
    Item lCollName2 = lFac->createQName("http://www.mod2.com/", "coll");
    Item lIdxName   = lFac->createQName("http://www.mod2.com/", "index");
    Item lCollName3 = lFac->createQName("http://www.mod3.com/", "coll");

    ItemSequence_t lSeq = lColMgr->declaredCollections();
    Iterator_t lIter = lSeq->getIterator();
    lIter->open();
    Item lTmp;
    while (lIter->next(lTmp)) {
      std::cout << "name " << lTmp.getStringValue() << std::endl;
      lColMgr->createCollection(lTmp);
    }
    
    lSeq = lColMgr->declaredIndexes();
    lIter = lSeq->getIterator();
    lIter->open();
    while (lIter->next(lTmp)) {
      std::cout << "name " << lTmp.getStringValue() << std::endl;
      lColMgr->createIndex(lTmp);
    }

    return true;
  }
  catch ( std::exception const &e ) {
    std::cerr << e.what() << std::endl;
  }
  catch ( ... ) {
    std::cerr << "caught unexpected exception" << std::endl;
  }
  return false;
}
开发者ID:alyst,项目名称:zorba,代码行数:48,代码来源:staticcollectionmanager.cpp

示例10: while

bool
cxx_api_changes_test5(Zorba* aZorba)
{
  try
  {
    
    std::string lIn = "declare variable $a external; 1+1";
    
    XQuery_t lQuery = aZorba->compileQuery(lIn);

    std::vector<Item> lVars;
    Iterator_t varsIte;
    lQuery->getExternalVariables(varsIte);

    varsIte->open();
    Item temp;
    while(varsIte->next(temp))
      lVars.push_back(temp);
    varsIte->close();

    std::vector<Item>::const_iterator lIte = lVars.begin();
    std::vector<Item>::const_iterator lEnd = lVars.end();

    Item item = aZorba->getItemFactory()->createInt(4);
    

    bool isBound1;
    bool isBound2;

    for(; lIte != lEnd; ++lIte)
    {
      Item qname = *lIte;
      isBound1 = lQuery->getDynamicContext()->isBoundExternalVariable(qname.getNamespace(), qname.getLocalName());
      Item value = aZorba->getItemFactory()->createString("foo");
      lQuery->getDynamicContext()->setVariable(qname.getStringValue(), value);
      isBound2 = lQuery->getDynamicContext()->isBoundExternalVariable(qname.getNamespace(), qname.getLocalName());
    }

    if (!isBound1 && isBound2)
      return true;
     
  }
  catch (XQueryException& qe)
  {
    std::cerr << qe << std::endl;
    return false;
  }
  catch (ZorbaException& e)
  {
    std::cerr << e << std::endl;
    return false;
  }

  return true;
}
开发者ID:alyst,项目名称:zorba,代码行数:55,代码来源:cxx_api_changes.cpp

示例11:

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;
}
开发者ID:28msec,项目名称:zorba-jdbc-module,代码行数:11,代码来源:jdbc.cpp

示例12: allowed

void
GraphvizFunction::gxl2dot(
    ItemFactory* aFactory,
    const Item& in, std::fstream& os)
{
  Item lGXLQName   = aFactory->createQName("", "", "gxl");
  Item lGraphQName = aFactory->createQName("", "", "graph");

  if (!in.isNode()) {
    GraphvizFunction::throwErrorWithQName(aFactory, "IM003", "GXL parse error: item is not a node");
  }

  Item lNodeName;
  in.getNodeName(lNodeName);
  if (lNodeName.getLocalName() != lGXLQName.getLocalName()) {
    Item lNodeName;
    in.getNodeName(lNodeName);

    std::ostringstream lErrorMsg;
    lErrorMsg << "GXL parse error: only element with name "
              << lGXLQName.getStringValue() << " allowed (got " << lNodeName.getStringValue()
              << ").";
    GraphvizFunction::throwErrorWithQName(aFactory, "IM003", lErrorMsg.str());
  }

  Iterator_t lGraphs = in.getChildren();
  lGraphs->open();

  Item lGraph;
  while(lGraphs->next(lGraph)) {
    if (!lGraph.isNode()) {
      GraphvizFunction::throwErrorWithQName(aFactory, "IM003", "GXL parse error: item is not a node");
    }

    lGraph.getNodeName(lNodeName);
    if (lNodeName.getLocalName() != lGraphQName.getLocalName()) {
      std::ostringstream lErrorMsg;
      Item lNodeName;
      lGraph.getNodeName(lNodeName);

      lErrorMsg << "GXL parse error: only elements with name "
                << lGraphQName.getStringValue() << " allowed (got "
                << lNodeName.getLocalName() << ").";
      GraphvizFunction::throwErrorWithQName(aFactory, "IM003", lErrorMsg.str());
    }

    printGraph(aFactory, lGraph, os);

  }

} /* GraphvizFunction::gxl2dot */
开发者ID:28msec,项目名称:zorba-graphviz-module,代码行数:51,代码来源:graphviz.cpp

示例13: ItemSequence_t

 virtual ItemSequence_t 
 evaluate(const ExternalFunction::Arguments_t& args) const
 {
     iv_t vec;
     for(int i = 0; i < 2; ++i) {
         Item lItem;
         Iterator_t iter = args[i]->getIterator();
         iter->open();
         while(iter->next(lItem)) {
             vec.push_back(lItem);
         }
         iter->close();
     }
     // transfer ownership of the IteratorBackedItemSequence to Zorba (using a unique_ptr)
     return ItemSequence_t(new IteratorBackedItemSequence(vec));
 }
开发者ID:cezarfx,项目名称:zorba,代码行数:16,代码来源:execution_plans.cpp

示例14: driverName

    ItemSequence_t
    RegisterFunction::evaluate(
        const ExternalFunction::Arguments_t &args,
        const zorba::StaticContext *aStaticContext,
        const zorba::DynamicContext *aDynamincContext) const {
      JdbcModule::initGlobals(aStaticContext);
      Item result;
      JDBC_MODULE_TRY;
      jstring driverName(NULL);
      Item item = JdbcModule::getItemArg(args, 0);
      bool hasUsername = false;
      if (item.isJSONItem()) {
        Iterator_t lKeys = item.getObjectKeys();
        lKeys->open();
        Item lKey;
        while (lKeys->next(lKey)) {
          zorba::String keystring = lKey.getStringValue();
          zorba::String value = item.getObjectValue(keystring).getStringValue();
          if (keystring == "driver") {
            driverName = env->NewStringUTF(value.c_str());
            CHECK_EXCEPTION;
          }
        }
        lKeys->close();
      }

      jobject oRegister;
      if (driverName) {
        oRegister = env->CallStaticObjectMethod(
            jClass.classID,
            jClass.forName,
            driverName);
        CHECK_EXCEPTION;
      }

      JDBC_MODULE_CATCH;
      return ItemSequence_t(new EmptySequence());
    }
开发者ID:zorba-modules,项目名称:jdbc,代码行数:38,代码来源:register.cpp

示例15: SingletonItemSequence

/*
 * Example to show the usage of the collection manager to
 * (1) create a collection
 * (2) insert a node at the end of the collection,
 * (3) retrieve the annotations of a collection
 * (4) iterate over the contents of the collection,
 * (5) delete the node, and
 * (6) make sure the node was deleted.
 */
bool
xmldatamanager_example_3(Zorba* aZorba, XmlDataManager* aDataManager)
{
  try {
    CollectionManager* lColMgr = aDataManager->getCollectionManager();

    // name of the collection
    Item lColName = aZorba->getItemFactory()->createQName(
        "http://zorba.io/collections", "mybooks");

    // (1) create the collection
    lColMgr->createCollection(lColName);

    // create a document in a temporary stream
    std::stringstream lInStream;
    lInStream
    << "<books>" << std::endl
    << "  <book>Book 1</book>" << std::endl
    << "  <book>Book 2</book>" << std::endl
    << "</books>";

    Item lDoc = aDataManager->parseXML(lInStream);

    Collection_t lColl = lColMgr->getCollection(lColName);

    if (!lColl) {
      return false;
    }

    // (2) get the annotations of a collections
    std::vector<Annotation_t> lAnnotations;
    lColl->getAnnotations(lAnnotations);
    size_t num_annotations = 0;
    for (std::vector<Annotation_t>::const_iterator lIter = lAnnotations.begin();
        lIter != lAnnotations.end(); ++lIter)
    {
      std::cout << "Annotation QName "
          << (*lIter)->getQName().getStringValue() << std::endl;
      ++num_annotations;
    }

    if (num_annotations != 3)
    {
      return false;
    }


    // (3) insert a node at the end of the collection
    lColl->insertNodesLast(new SingletonItemSequence(lDoc));

    // (4) iterate over the contents of the collection 
    ItemSequence_t lContents = lColl->contents();
    Iterator_t lIter = lContents->getIterator();

    lIter->open();

    while (lIter->next(lDoc)) {
      std::cout << "node found at position "
          << lColl->indexOf(lDoc) << std::endl;
    }

    // (5) delete the node
    lColl->deleteNodeLast();

    // (6) make sure the node was deleted
    lIter->close();
    lIter->open();
    while (lIter->next(lDoc)) {
      return false;
    }

    lColMgr->deleteCollection(lColName);

  } catch (ZorbaException& e) {
    std::cerr << e << std::endl;
    return false;
  }

  return true;
}
开发者ID:buchenberg,项目名称:zorba,代码行数:89,代码来源:xmldatamanager.cpp


注:本文中的Iterator_t::next方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。