本文整理汇总了C++中SWModule::setEntry方法的典型用法代码示例。如果您正苦于以下问题:C++ SWModule::setEntry方法的具体用法?C++ SWModule::setEntry怎么用?C++ SWModule::setEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SWModule
的用法示例。
在下文中一共展示了SWModule::setEntry方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeEntry
void writeEntry(SWModule & module,
std::string const & key,
std::string const & entry,
bool const replace)
{
if (key.size() && entry.size()) {
std::cout << "from file: " << key << std::endl;
VerseKey *vkey = (VerseKey *)module.getKey();
std::unique_ptr<VerseKey> linkMaster(
static_cast<VerseKey *>(module.createKey().release()));
ListKey listKey = vkey->parseVerseList(key.c_str(), "Gen1:1", true);
bool first = true;
for (listKey.positionToTop(); !listKey.popError(); listKey.increment()) {
vkey->positionFrom(listKey);
if (first) {
*linkMaster = *vkey;
std::string text;
if (!replace)
text = module.getRawEntry();
text += entry;
std::cout << "adding entry: " << vkey->getText() << " length " << entry.size() << "/" << (unsigned short)text.size() << std::endl;
module.setEntry(text.c_str());
first = false;
}
else {
std::cout << "linking entry: " << vkey->getText() << " to " << linkMaster->getText() << std::endl;
module.linkEntry(*linkMaster);
}
}
}
}
示例2: getModule
/*
* Class: org_crosswire_android_sword_SWModule
* Method: setRawEntry
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_crosswire_android_sword_SWModule_setRawEntry
(JNIEnv *env, jobject me, jstring newEntryTextJS) {
init();
const char *newEntryText = env->GetStringUTFChars(newEntryTextJS, NULL);
SWModule *module = getModule(env, me);
if (module) {
module->setEntry(newEntryText);
}
env->ReleaseStringUTFChars(newEntryTextJS, newEntryText);
}
示例3: 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);
//.........这里部分代码省略.........
示例4: main
//.........这里部分代码省略.........
SWModule *mod = 0;
SWKey *key, *linkKey;
if (compType == "ZIP") {
#ifndef EXCLUDEZLIB
compressor = new ZipCompress();
#else
usage(*argv, "ERROR: SWORD library not compiled with ZIP compression support.\n\tBe sure libzip is available when compiling SWORD library");
#endif
}
else if (compType == "LZSS") {
compressor = new LZSSCompress();
}
// setup module
if (!append) {
if (compressor) {
if (zLD::createModule(outPath)) {
fprintf(stderr, "ERROR: %s: couldn't create module at path: %s \n", *argv, outPath.c_str());
exit(-1);
}
}
else {
if (!fourByteSize)
RawLD::createModule(outPath);
else RawLD4::createModule(outPath);
}
}
if (compressor) {
// Create a compressed text module allowing very large entries
// Taking defaults except for first, fourth, fifth and last argument
mod = new zLD(outPath, 0, 0, blockCount, compressor, 0, ENC_UNKNOWN, DIRECTION_LTR, FMT_UNKNOWN, 0, caseSensitive);
}
else {
mod = (!fourByteSize)
? (SWModule *)new RawLD (outPath, 0, 0, 0, ENC_UNKNOWN, DIRECTION_LTR, FMT_UNKNOWN, 0, caseSensitive)
: (SWModule *)new RawLD4(outPath, 0, 0, 0, ENC_UNKNOWN, DIRECTION_LTR, FMT_UNKNOWN, 0, caseSensitive);
}
key = mod->createKey();
linkKey = mod->createKey();
key->setPersist(true);
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);
}
}
infile.close();
delete linkKey;
delete key;
delete mod;
return 0;
}