本文整理汇总了C++中SWModule::search方法的典型用法代码示例。如果您正苦于以下问题:C++ SWModule::search方法的具体用法?C++ SWModule::search怎么用?C++ SWModule::search使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SWModule
的用法示例。
在下文中一共展示了SWModule::search方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SWModule_doSearch
SWHANDLE SWModule_doSearch(SWHANDLE hmodule, const char *searchString, int type, int params ,void (*percent) (char, void *), void *percentUserData) {
static ListKey results;
SWKey * scope = 0;
SWModule *module = (SWModule *)hmodule;
if (!module)
return -1;
results.clear();
results = module->search(searchString, type, params, scope, 0, percent, (void *) &percentUserData);
return (SWHANDLE)&results;
}
示例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;
}
示例3: peeuuu
/*
* Class: org_crosswire_android_sword_SWModule
* Method: search
* Signature: (Ljava/lang/String;IJLjava/lang/String;Lorg/crosswire/android/sword/SWModule/SearchProgressReporter;)[Lorg/crosswire/android/sword/SWModule/SearchHit;
*/
JNIEXPORT jobjectArray JNICALL Java_org_crosswire_android_sword_SWModule_search
(JNIEnv *env, jobject me, jstring expressionJS, jint srchType, jlong flags, jstring scopeJS, jobject progressReporter) {
init();
const int MAX_RETURN_COUNT = 999999;
const char *expression = env->GetStringUTFChars(expressionJS, NULL);
const char *scope = env->GetStringUTFChars(scopeJS, NULL);
jclass clazzSearchHit = env->FindClass("org/crosswire/android/sword/SWModule$SearchHit");
jobjectArray ret = 0;
SWModule *module = getModule(env, me);
struct pu peeuuu(env, progressReporter);
if (module) {
sword::ListKey lscope;
sword::ListKey result;
if ((scope) && (strlen(scope)) > 0) {
sword::SWKey *p = module->CreateKey();
sword::VerseKey *parser = SWDYNAMIC_CAST(VerseKey, p);
if (!parser) {
delete p;
parser = new VerseKey();
}
*parser = module->getKeyText();
lscope = parser->ParseVerseList(scope, *parser, true);
result = module->search(expression, srchType, flags, &lscope, 0, &percentUpdate, &peeuuu);
delete parser;
}
else result = module->search(expression, srchType, flags, 0, 0, &percentUpdate, &peeuuu);
int count = 0;
for (result = sword::TOP; !result.Error(); result++) count++;
if (count > MAX_RETURN_COUNT) count = MAX_RETURN_COUNT;
ret = (jobjectArray) env->NewObjectArray(count, clazzSearchHit, NULL);
// if we're sorted by score, let's re-sort by verse, because Java can always re-sort by score
result = sword::TOP;
if ((count) && (long)result.getElement()->userData)
result.sort();
int i = 0;
jstring modName = env->NewStringUTF(assureValidUTF8(module->getName()));
jfieldID fieldIDModName = env->GetFieldID(clazzSearchHit, "modName", "Ljava/lang/String;");
jfieldID fieldIDKey = env->GetFieldID(clazzSearchHit, "key" , "Ljava/lang/String;");
jfieldID fieldIDScore = env->GetFieldID(clazzSearchHit, "score" , "J");
for (result = sword::TOP; !result.Error(); result++) {
jfieldID fieldID;
jobject searchHit = env->AllocObject(clazzSearchHit);
env->SetObjectField(searchHit, fieldIDModName, modName);
jstring key = env->NewStringUTF(assureValidUTF8((const char *)result));
env->SetObjectField(searchHit, fieldIDKey, key);
env->DeleteLocalRef(key);
env->SetLongField(searchHit, fieldIDScore, (long)result.getElement()->userData);
env->SetObjectArrayElement(ret, i++, searchHit);
env->DeleteLocalRef(searchHit);
if (i >= MAX_RETURN_COUNT) break;
}
env->DeleteLocalRef(modName);
}
env->ReleaseStringUTFChars(scopeJS, scope);
env->ReleaseStringUTFChars(expressionJS, expression);
return (ret) ? ret : (jobjectArray) env->NewObjectArray(0, clazzSearchHit, NULL);
}
示例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;
}
示例5: doquery
void doquery(unsigned long maxverses = -1, unsigned char outputformat = FMT_PLAIN, unsigned char outputencoding = ENC_UTF8, unsigned long optionfilters = 0, unsigned char searchtype = ST_NONE, const char *range = 0, const char *text = 0, const char *locale = 0, const char *ref = 0, ostream* output = &cout, const char *script = 0, signed short variants = 0) {
static DiathekeMgr manager(NULL, NULL, false, outputencoding, outputformat,
((OP_BIDI & optionfilters) == OP_BIDI),
((OP_ARSHAPE & optionfilters) == OP_ARSHAPE));
ModMap::iterator it;
ListKey listkey;
SectionMap::iterator sit;
ConfigEntMap::iterator eit;
SWModule *target;
char *font = 0;
char inputformat = 0;
SWBuf encoding;
char querytype = 0;
if (locale) {
LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(locale);
}
//deal with queries to "system"
if (!::stricmp(text, "system")) {
querytype = QT_SYSTEM;
systemquery(ref, output);
}
if (!strnicmp(text, "info", 4)) {
querytype = QT_INFO;
text = ref;
}
//otherwise, we have a real book
it = manager.Modules.find(text);
if (it == manager.Modules.end()) { //book not found
return;
}
target = (*it).second;
SWKey *p = target->createKey();
VerseKey *parser = SWDYNAMIC_CAST(VerseKey, p);
if (!parser) {
delete p;
parser = new VerseKey();
}
if ((sit = manager.config->Sections.find((*it).second->getName())) != manager.config->Sections.end()) {
if ((eit = (*sit).second.find("SourceType")) != (*sit).second.end()) {
if (!::stricmp((char *)(*eit).second.c_str(), "GBF"))
inputformat = FMT_GBF;
else if (!::stricmp((char *)(*eit).second.c_str(), "ThML"))
inputformat = FMT_THML;
else if (!::stricmp((char *)(*eit).second.c_str(), "OSIS"))
inputformat = FMT_OSIS;
else if (!::stricmp((char *)(*eit).second.c_str(), "TEI"))
inputformat = FMT_TEI;
}
encoding = ((eit = (*sit).second.find("Encoding")) != (*sit).second.end()) ? (*eit).second : (SWBuf)"";
}
if (querytype == QT_INFO) {
switch (inputformat) {
case FMT_THML :
*output << "ThML";
break;
case FMT_GBF :
*output << "GBF";
break;
case FMT_OSIS :
*output << "OSIS";
break;
case FMT_TEI :
*output << "TEI";
break;
default:
*output << "Other";
}
*output << ";";
*output << target->getType();
*output << ";";
delete parser;
return;
}
if (searchtype)
querytype = QT_SEARCH;
else if (!strcmp(target->getType(), "Biblical Texts"))
querytype = QT_BIBLE;
else if (!strcmp(target->getType(), "Commentaries"))
querytype = QT_COMM;
else if (!strcmp(target->getType(), "Lexicons / Dictionaries"))
querytype = QT_LD;
else if (!strcmp(target->getType(), "Generic Books"))
querytype = QT_LD;
if (optionfilters & OP_FOOTNOTES)
manager.setGlobalOption("Footnotes","On");
else
manager.setGlobalOption("Footnotes","Off");
if (optionfilters & OP_HEADINGS)
manager.setGlobalOption("Headings","On");
else
manager.setGlobalOption("Headings","Off");
//.........这里部分代码省略.........