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


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

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


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

示例1: 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

示例2: 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

示例3:

bool
JdbcModule::getOptionalStringArg(const ExternalFunction::Arguments_t& args, int index, String& aRes) {
  Iterator_t lIter = args[index]->getIterator();
  lIter->open();
  Item item;
  if( lIter->next(item) )
  {
    aRes = item.getStringValue();
    lIter->close();
    return true;
  }
  lIter->close();
  return false;
}
开发者ID:28msec,项目名称:zorba-jdbc-module,代码行数:14,代码来源:jdbc.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: 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

示例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: 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

示例8: 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

示例9: catch

void
SerializerImpl::serialize(Iterator_t aIterator, std::ostream& aOs) const
{
  try {
    aIterator->open();
    theInternalSerializer.serialize(Unmarshaller::getInternalIterator(aIterator), aOs);
    aIterator->close();
  } catch (ZorbaException const &e) {
    ZorbaImpl::notifyError(theDiagnosticHandler, e);
  }
}
开发者ID:alyst,项目名称:zorba,代码行数:11,代码来源:serializerimpl.cpp

示例10: 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

示例11: 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

示例12: EmailException

void
CClientMimeHandler::envelope()
{
    if (theEnvelopeItem.isNull()) {
        throw EmailException("PARSE_ERROR", "The message could not be parsed.");
    }

    //set the date from the client.
    //If this is not set it defaults to the date of the SMTP server.
    char line[MAILTMPLEN];
    rfc822_date (line);
    theEnvelope->date = (unsigned char *) fs_get (1+strlen (line));
    strcpy((char *)theEnvelope->date,line);


    Iterator_t    lChildIter;
    zorba::Item   lChild;
    String lNodeName, lNodeValue;
    String lName, lMailbox, lHost;

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

        getNodeName(lChild, lNodeName);
        getTextValue(lChild, lNodeValue);

        if (lNodeName == "date") {
            char lDate[MAILTMPLEN];
            parseXmlDateTime(lNodeValue, lDate);
            theEnvelope->date = (unsigned char *) fs_get (1+strlen (lDate));
            strcpy ((char *)theEnvelope->date, lDate);
        } else if (lNodeName == "from") {
            getNameAndEmailAddress(lChild, lName, lMailbox, lHost);
            theEnvelope->from = create_mail_address(lName, lMailbox, lHost);
        } else if (lNodeName == "sender") {
            getNameAndEmailAddress(lChild, lName, lMailbox, lHost);
            theEnvelope->sender = create_mail_address(lName, lMailbox, lHost);
        } else if (lNodeName == "replyto") {
            getNameAndEmailAddress(lChild, lName, lMailbox, lHost);
            theEnvelope->reply_to = create_mail_address(lName, lMailbox, lHost);
        } else if (lNodeName == "subject") {
            encodeStringForEMailHeader(lNodeValue, theEnvelope->subject);
        } else if (lNodeName == "recipient") {
            Iterator_t lRecipentChildren = lChild.getChildren();
            lRecipentChildren->open();
            Item lRecipentChild;
            // read the recipient element but skip comments
            while (lRecipentChildren->next(lRecipentChild)) {
                if (lRecipentChild.getNodeKind() == store::StoreConsts::elementNode) {
                    break;
                }
            }
            getNodeName(lRecipentChild, lNodeName);
            lRecipentChildren->close();

            if (lNodeName == "to") {
                getNameAndEmailAddress(lRecipentChild, lName, lMailbox, lHost);
                // there can be multiple to nodes, iterate to the next free one!
                ADDRESS** lNext = &theEnvelope->to;
                while (*lNext) {
                    lNext = &((*lNext)->next);
                }
                *lNext = create_mail_address(lName, lMailbox, lHost);
            } else if(lNodeName == "cc") {
                getNameAndEmailAddress(lRecipentChild, lName, lMailbox, lHost);
                ADDRESS** lNext = &theEnvelope->cc;
                while (*lNext) {
                    lNext = &((*lNext)->next);
                }
                *lNext = create_mail_address(lName, lMailbox, lHost);
            } else if (lNodeName == "bcc") {
                getNameAndEmailAddress(lRecipentChild, lName, lMailbox, lHost);
                ADDRESS** lNext = &theEnvelope->bcc;
                while (*lNext) {
                    lNext = &((*lNext)->next);
                }
                *lNext = create_mail_address(lName, lMailbox, lHost);
            }
        }
    }
    lChildIter->close();
}
开发者ID:28msec,项目名称:zorba-email-module,代码行数:86,代码来源:mime_handler.cpp

示例13: lSequence

ItemSequence_t
GeneratePDFFunction::evaluate(const ExternalFunction::Arguments_t& args,
                              const zorba::StaticContext* aStaticContext,
                              const zorba::DynamicContext* aDynamincContext) const
{
  Iterator_t lIter = args[0]->getIterator();
  lIter->open();
  Item outputFormat;
  lIter->next(outputFormat);
  lIter->close();
  jthrowable lException = 0;
  static JNIEnv* env;
  try {
    env = zorba::jvm::JavaVMSingleton::getInstance(aStaticContext)->getEnv();
    jstring outFotmatString = env->NewStringUTF(outputFormat.getStringValue().c_str());
    // Local variables
    std::ostringstream os;
    Zorba_SerializerOptions_t lOptions;
    Serializer_t lSerializer = Serializer::createSerializer(lOptions);
    jclass fopFactoryClass;
    jobject fopFactory;
    jmethodID fopFactoryNewInstance;
    jclass byteArrayOutputStreamClass;
    jobject byteArrayOutputStream;
    jobject fop;
    jmethodID newFop;
    jclass transformerFactoryClass;
    jobject transformerFactory;
    jobject transormer;
    jclass stringReaderClass;
    jobject stringReader;
    jstring xmlUTF;
    const char* xml;
    std::string xmlString;
    jclass streamSourceClass;
    jobject streamSource;
    jobject defaultHandler;
    jclass saxResultClass;
    jobject saxResult;
    jboolean isCopy;
    jbyteArray res;
    Item base64;
    String resStore;
    jsize dataSize;
    jbyte* dataElements;

    Item item;
    lIter = args[1]->getIterator();
    lIter->open();
    lIter->next(item);
    lIter->close();
    // Searialize Item
    SingletonItemSequence lSequence(item);
    lSerializer->serialize(&lSequence, os);
    xmlString = os.str();
    xml = xmlString.c_str();

    // Create an OutputStream
    byteArrayOutputStreamClass = env->FindClass("java/io/ByteArrayOutputStream");
    CHECK_EXCEPTION(env);
    byteArrayOutputStream = env->NewObject(byteArrayOutputStreamClass,
        env->GetMethodID(byteArrayOutputStreamClass, "<init>", "()V"));
    CHECK_EXCEPTION(env);

    // Create a FopFactory instance
    fopFactoryClass = env->FindClass("org/apache/fop/apps/FopFactory");
    CHECK_EXCEPTION(env);
    fopFactoryNewInstance = env->GetStaticMethodID(fopFactoryClass, "newInstance", "()Lorg/apache/fop/apps/FopFactory;");
    CHECK_EXCEPTION(env);
    fopFactory = env->CallStaticObjectMethod(fopFactoryClass, fopFactoryNewInstance);
    CHECK_EXCEPTION(env);

    // Create the Fop
    newFop = env->GetMethodID(fopFactoryClass, "newFop", "(Ljava/lang/String;Ljava/io/OutputStream;)Lorg/apache/fop/apps/Fop;");
    CHECK_EXCEPTION(env);
    fop = env->CallObjectMethod(fopFactory,
        newFop,
        outFotmatString, byteArrayOutputStream);
    CHECK_EXCEPTION(env);

    // Create the Transformer
    transformerFactoryClass = env->FindClass("javax/xml/transform/TransformerFactory");
    CHECK_EXCEPTION(env);
    transformerFactory = env->CallStaticObjectMethod(transformerFactoryClass,
        env->GetStaticMethodID(transformerFactoryClass, "newInstance", "()Ljavax/xml/transform/TransformerFactory;"));
    CHECK_EXCEPTION(env);
    transormer = env->CallObjectMethod(transformerFactory,
        env->GetMethodID(transformerFactoryClass, "newTransformer", "()Ljavax/xml/transform/Transformer;"));
    CHECK_EXCEPTION(env);

    // Create Source
    xmlUTF = env->NewStringUTF(xml);
    stringReaderClass = env->FindClass("java/io/StringReader");
    CHECK_EXCEPTION(env);
    stringReader = env->NewObject(stringReaderClass,
        env->GetMethodID(stringReaderClass, "<init>", "(Ljava/lang/String;)V"), xmlUTF);
    CHECK_EXCEPTION(env);
    streamSourceClass = env->FindClass("javax/xml/transform/stream/StreamSource");
    CHECK_EXCEPTION(env);
    streamSource = env->NewObject(streamSourceClass,
//.........这里部分代码省略.........
开发者ID:28msec,项目名称:zorba-data-formatting-module,代码行数:101,代码来源:xslfo.cpp

示例14: lIn

bool
staticcollectionamanger2(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");

    lColMgr->createCollection(lCollName2);

    Collection_t lCollection = lColMgr->getCollection(lCollName2);

    std::vector<Annotation_t> lAnnotations;
    lCollection->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;
    }

    if (lCollection->getType().getKind() != SequenceType::NODE_TYPE)
    {
      return false;
    }

    std::stringstream lInStream;
    lInStream
      << "<books>" << std::endl
      << "  <book>Book 1</book>" << std::endl
      << "  <book>Book 2</book>" << std::endl
      << "</books>";

    Item lDoc = z->getXmlDataManager()->parseXML(lInStream);

    for (size_t i = 0; i < 10; ++i) {
      lCollection->insertNodesLast(new SingletonItemSequence(lDoc));
    }

    lCollection->deleteNodesLast(2);

    ItemSequence_t lContents = lCollection->contents();
    Iterator_t lIter = lContents->getIterator();
    size_t num_nodes = 0;
    lIter->open();
    while (lIter->next(lDoc)) {
      ++num_nodes;
    }
    lIter->close();

    if (num_nodes != 8) {
      return false;
    }

    lDoc = NULL;
    lColMgr->deleteCollection(lCollName2);

    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,代码行数:80,代码来源:staticcollectionmanager.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::close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。