本文整理汇总了C++中SWModule::CreateKey方法的典型用法代码示例。如果您正苦于以下问题:C++ SWModule::CreateKey方法的具体用法?C++ SWModule::CreateKey怎么用?C++ SWModule::CreateKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SWModule
的用法示例。
在下文中一共展示了SWModule::CreateKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv) {
SWMgr mgr;
SWModule *mod = mgr.getModule("KJVgb");
VerseKey *key1 = (VerseKey *)mod->CreateKey();
key1->Testament(2);
key1->Book(4);
key1->Chapter(2);
key1->Verse(3);
cout << "\n" << key1->getText() << ":\n\n";
ListKey keys;
keys << *key1;
cout << "\n" << keys.getRangeText() << ":\n\n";
ListKey keys2 = keys;
cout << "\n" << keys2.getRangeText() << ":\n\n";
keys = key1->ParseVerseList("Lk.4.5");
cout << "\n" << key1->getText() << ":\n\n";
key1->setText("jn.6.7");
cout << "\n" << key1->getText() << ":\n\n";
mod->setKey("lk.2.3");
cout << "\n" << mod->getKeyText() << ":\n" << endl;
cout << mod->getRawEntry() << endl;
cout << "\nListkey persist key iteration test\n\n";
keys = key1->ParseVerseList("mat1", 0, true);
for (keys = TOP; !keys.Error(); keys++) {
cout << "\n" << keys.getText() << ":\n" << endl;
}
keys.Persist(1);
mod->setKey(keys);
for ((*mod) = TOP; !mod->Error(); (*mod)++) {
cout << "\n" << mod->getKeyText() << ":\n" << endl;
}
delete key1;
return 0;
}
示例2: main
int main(int argc, char **argv) {
const char * helptext ="imp2ld 1.0 Lexicon/Dictionary/Daily Devotional/Glossary module creation tool for the SWORD Project\n usage:\n %s <filename> [modname] [ 4 (default) | 2 | z - module driver]\n";
signed long i = 0;
string keybuffer;
string entbuffer;
string linebuffer;
char modname[16];
char links = 0;
std::vector<string> linkbuffer;
if (argc > 2) {
strcpy (modname, argv[2]);
}
else if (argc > 1) {
for (i = 0; (i < 16) && (argv[1][i]) && (argv[1][i] != '.'); i++) {
modname[i] = argv[1][i];
}
modname[i] = 0;
}
else {
fprintf(stderr, helptext, argv[0]);
exit(-1);
}
std::ifstream infile(argv[1]);
char mode = 1;
if (argc > 3) {
switch (*argv[3]) {
case 'z': mode = 3; break;
case '2': mode = 2; break;
default: mode = 1;
}
}
SWModule *mod = 0;
SWKey *key, *linkKey;
switch (mode) {
case 3:
zLD::createModule(modname);
mod = new zLD(modname, 0, 0, 30, new ZipCompress());
break;
case 2:
RawLD::createModule(modname);
mod = new RawLD(modname);
break;
case 1:
RawLD4::createModule(modname);
mod = new RawLD4(modname);
break;
}
key = mod->CreateKey();
linkKey = mod->CreateKey();
key->Persist(1);
mod->setKey(key);
while (!infile.eof()) {
std::getline(infile, linebuffer);
if (linebuffer.size() > 3 && linebuffer.substr(0,3) == "$$$") {
if (keybuffer.size() && entbuffer.size()) {
std::cout << keybuffer << std::endl;
*key = keybuffer.c_str();
mod->setEntry(entbuffer.c_str(), entbuffer.size());
for (i = 0; i < links; i++) {
std::cout << "Linking: " << linkbuffer[i] << std::endl;
*linkKey = linkbuffer[i].c_str();
mod->linkEntry(linkKey);
}
}
if (linebuffer.size() > 3)
keybuffer = linebuffer.substr(3,linebuffer.size());
entbuffer.resize(0);
linkbuffer.clear();
links = 0;
}
else if (linebuffer.size() > 3 && linebuffer.substr(0,3) == "%%%") {
linkbuffer.push_back(linebuffer.substr(3,linebuffer.size()));
links++;
}
else {
entbuffer += linebuffer;
}
}
//handle final entry
if (keybuffer.size() && entbuffer.size()) {
std::cout << keybuffer << std::endl;
*key = keybuffer.c_str();
mod->setEntry(entbuffer.c_str(), entbuffer.size());
for (i = 0; i < links; i++) {
std::cout << "Linking: " << linkbuffer[i] << std::endl;
*linkKey = linkbuffer[i].c_str();
mod->linkEntry(linkKey);
//.........这里部分代码省略.........
示例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);
}