Exemplo n.º 1
0
int main(int argc, char **argv)
{
//	SWMgr manager(0, 0, true, new MarkupFilterMgr(FMT_RTF, ENC_RTF));
	SWMgr manager;

	if ((argc < 3) || (argc > 3)) {
	        usage();
		exit(-1);
	}

        int stripFilters = atoi(argv[1]);
        
        if ((stripFilters < 1) || (stripFilters > 15)) {
                usage();
		exit(-1);
        }        
	SWBuf stripTerm = argv[2];
	
	manager.setGlobalOption("Greek Accents", "Off");
	manager.setGlobalOption("Arabic Vowel Points", "Off");
	manager.setGlobalOption("Hebrew Vowel Points", "Off");
	manager.setGlobalOption("Hebrew Cantillation", "Off");
	
	if (stripFilters & (1 << 3)) manager.filterText("Hebrew Cantillation", stripTerm);
	if (stripFilters & (1 << 2)) manager.filterText("Hebrew Vowel Points", stripTerm);
	if (stripFilters & (1 << 1)) manager.filterText("Arabic Vowel Points", stripTerm);
	if (stripFilters & (1 << 0)) manager.filterText("Greek Accents", stripTerm);
	
	fprintf(stdout,"%s\n",stripTerm.c_str());
	return 0;

}
Exemplo n.º 2
0
void SWMgr_setGlobalOption(SWHANDLE hmgr, const char *option, const char *value) {
	SWMgr *mgr = (SWMgr *)hmgr;
	if (mgr)
		mgr->setGlobalOption(option, value);
}
Exemplo n.º 3
0
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;

}