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


C++ ListKey::getElement方法代码示例

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


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

示例1:

TreeKey &SWGenBook::getTreeKey(const SWKey *k) const {
	const SWKey* thiskey = k?k:this->key;

	TreeKey *key = 0;

	SWTRY {
		key = SWDYNAMIC_CAST(TreeKey, (thiskey));
	}
	SWCATCH ( ... ) {}

	if (!key) {
		ListKey *lkTest = 0;
		SWTRY {
			lkTest = SWDYNAMIC_CAST(ListKey, thiskey);
		}
		SWCATCH ( ... ) {	}
		if (lkTest) {
			SWTRY {
				key = SWDYNAMIC_CAST(TreeKey, lkTest->getElement());
				if (!key) {
					VerseTreeKey *tkey = 0;
					SWTRY {
						tkey = SWDYNAMIC_CAST(VerseTreeKey, lkTest->getElement());
					}
					SWCATCH ( ... ) {}
					if (tkey) key = tkey->getTreeKey();
				}
			}
			SWCATCH ( ... ) {	}
		}
开发者ID:bluehavana,项目名称:sword,代码行数:30,代码来源:swgenbook.cpp

示例2: search

void SearchThread::search()  {
	
	if (!module) {
		std::cout << "Return." << std::endl;
		return;
	}

	ListKey scopeList = VerseKey().parseVerseList("Luke;John;Revelation","", true);
	for (int i=0; i < scopeList.getCount(); ++i) {
		std::cout << (const char*)*scopeList.getElement(i) << std::endl;
	}
	SWKey* scope = &scopeList;

	searchResult = module->search(searchedText, -2, REG_ICASE, scope, 0, &percentUpdate);

	if (!scope)
		std::cout << "bad scope!" << std::endl;
	isSearching = false;
}
开发者ID:bluehavana,项目名称:sword,代码行数:19,代码来源:threaded_search.cpp

示例3:

VerseKey &SWCom::getVerseKey(const SWKey *keyToConvert) const {
	const SWKey *thisKey = keyToConvert ? keyToConvert : this->key;

	VerseKey *key = 0;
	// see if we have a VerseKey * or decendant
	SWTRY {
		key = SWDYNAMIC_CAST(VerseKey, thisKey);
	}
	SWCATCH ( ... ) {	}
	if (!key) {
		ListKey *lkTest = 0;
		SWTRY {
			lkTest = SWDYNAMIC_CAST(ListKey, thisKey);
		}
		SWCATCH ( ... ) {	}
		if (lkTest) {
			SWTRY {
				key = SWDYNAMIC_CAST(VerseKey, lkTest->getElement());
			}
			SWCATCH ( ... ) {	}
		}
	}
开发者ID:bluehavana,项目名称:sword,代码行数:22,代码来源:swcom.cpp

示例4: main

int main(int argc, char **argv)
{
//    SWMgr manager(0, 0, true, new MarkupFilterMgr(FMT_RTF, ENC_RTF));
    SWMgr manager;
    SWModule *target;
    ListKey listkey;
    ListKey scope;
    ModMap::iterator it;

    if ((argc < 3) || (argc > 5)) {
        fprintf(stderr, "\nusage: %s <modname> <\"search string\"> [\"search_scope\"] [\"search again for string in previous result set\"]\n"
                             "\tExample: search KJV \"swift hear slow speak\"\n\n", argv[0]);

        exit(-1);
    }


    std::string searchTerm = argv[2];
    manager.setGlobalOption("Greek Accents", "Off");
    manager.setGlobalOption("Strong's Numbers", "On");
    manager.setGlobalOption("Hebrew Vowel Points", "Off");
    manager.filterText("Greek Accents", searchTerm);

    it = manager.Modules.find(argv[1]);
    if (it == manager.Modules.end()) {
        fprintf(stderr, "Could not find module [%s].  Available modules:\n", argv[1]);
        for (it = manager.Modules.begin(); it != manager.Modules.end(); ++it) {
            fprintf(stderr, "[%s]\t - %s\n", (*it).second->getName(), (*it).second->getDescription());
        }
        exit(-1);
    }

    target = (*it).second;

    if (argc > 3) {            // if min / max specified
        SWKey *k = target->getKey();
        VerseKey *parser = SWDYNAMIC_CAST(VerseKey, k);
        VerseKey kjvParser;
        if (!parser) parser = &kjvParser;    // use standard KJV parsing as fallback
        scope = parser->parseVerseList(argv[3], *parser, true);
        scope.setPersist(true);
        target->setKey(scope);
    }

    std::cerr << "[0=================================50===============================100]\n ";
    char lineLen = 70;
    listkey = target->search(searchTerm.c_str(), SEARCH_TYPE, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, 0, 0, &percentUpdate, &lineLen);
    std::cerr << std::endl;
    if (argc > 4) {            // if min / max specified
        scope = listkey;
        scope.setPersist(true);
        target->setKey(scope);
        printed = 0;
        std::cerr << " ";
        listkey = target->search(argv[4], SEARCH_TYPE, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, 0, 0, &percentUpdate, &lineLen);
        std::cerr << std::endl;
    }
// we don't want to sort by verse if we've been given scores
//    listkey.sort();
    while (!listkey.popError()) {
        std::cout << (const char *)listkey;
        if (listkey.getElement()->userData) std::cout << " : " << (uint64_t)listkey.getElement()->userData << "%";
        std::cout << std::endl;
        ++listkey;
    }

    return 0;

}
开发者ID:kalemas,项目名称:swordxx,代码行数:69,代码来源:search.cpp

示例5: main

int main(int argc, char **argv) {
  
  const char * helptext = "addvs 1.1 Bible & Commentary module creation tool for the SWORD Project\nUse -a to add a new verse from standard input or a file, -d to delete a verse,\n-l to link two verses, -c to create a new module.\n  usage:\n   %s -a </path/to/module> <verse> [</path/to/file/with/verse>]\n   %s -d </path/to/module> <key>\n   %s -l </path/to/module> <first verse (already assigned)> <second verse>\n   %s -c </path/to/module>\n";
  long entrysize;

  if (argc < 3) {
    fprintf(stderr, helptext, argv[0], argv[0], argv[0], argv[0]);
    exit(-1);
  }
 if (!strcmp(argv[1], "-a") && (argc == 4 || argc == 5)) {	
    
    // Do some initialization stuff
    char buffer[65536];  //this is the max size of any entry
    RawText * mod = new RawText(argv[2]);	// open our datapath with our RawText driver.
    VerseKey *vkey = new VerseKey;
    vkey->setIntros(true);
    vkey->setAutoNormalize(false);
    vkey->setPersist(true);      // the magical setting
    *vkey = argv[3];   
    // Set our VerseKey
    mod->setKey(*vkey);
    if (!vkey->getChapter()) {
      // bad hack >>
      // 0:0 is Book intro
      // (chapter):0 is Chapter intro
      //
      // 0:2 is Module intro
      // 0:1 is Testament intro
      int backstep = vkey->getVerse();
      vkey->setVerse(0);
      *mod -= backstep;       
      // << bad hack

      FILE *infile;
      // case: add from text file
      //Open our data file and read its contents into the buffer
      if (argc == 5) infile = fopen(argv[4], "r");
      // case: add from stdin
      else infile = stdin;
      
      entrysize = fread(buffer, sizeof(char), sizeof(buffer), infile);
      
      mod->setEntry(buffer, entrysize);	// save text to module at current position
    }
    else {
      ListKey listkey = vkey->parseVerseList(argv[3], "Gen1:1", true);
      int i;
      bool havefirst = false;
      VerseKey firstverse;
      for (i = 0; i < listkey.getCount(); i++) {
	VerseKey *element = SWDYNAMIC_CAST(VerseKey, listkey.getElement(i));
	if (element) {
	  mod->setKey(element->getLowerBound());
	  VerseKey finalkey = element->getUpperBound();
	  std::cout << mod->getKeyText() << "-" << (const char*)finalkey << std::endl;
	  if (!havefirst) {
	    havefirst = true;
	    firstverse = *mod->getKey();
	    FILE *infile;
	    // case: add from text file
	    //Open our data file and read its contents into the buffer
	    if (argc == 5) infile = fopen(argv[4], "r");
	    // case: add from stdin
	    else infile = stdin;
	    
	    entrysize = fread(buffer, sizeof(char), sizeof(buffer), infile);
	    
	    mod->setEntry(buffer, entrysize);	// save text to module at current position
	    std::cout << "f" << (const char*)firstverse << std::endl;
	    (*mod)++;
	  }
	  while (*mod->getKey() <= finalkey) {
	    std::cout << mod->getKeyText() << std::endl;
	    *(SWModule*)mod << &firstverse;
	    (*mod)++;
	  }
	}
	else {
	  if (havefirst) {
	    mod->setKey(*listkey.getElement(i));
	    *(SWModule*)mod << &firstverse;
	    std::cout << mod->getKeyText() << std::endl;
	  }
	  else {
	    mod->setKey(*listkey.getElement(i));
	    havefirst = true;
	    firstverse = *mod->getKey();
	    FILE *infile;
	    // case: add from text file
	    //Open our data file and read its contents into the buffer
	    if (argc == 5) infile = fopen(argv[4], "r");
	    // case: add from stdin
	    else infile = stdin;
	    
	    entrysize = fread(buffer, sizeof(char), sizeof(buffer), infile);
	    
	    mod->setEntry(buffer, entrysize);	// save text to module at current position
	    std::cout << "f" << (const char*)firstverse << std::endl;
	  }
	}
//.........这里部分代码省略.........
开发者ID:bluehavana,项目名称:sword,代码行数:101,代码来源:addvs.cpp


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