本文整理汇总了C++中VerseKey类的典型用法代码示例。如果您正苦于以下问题:C++ VerseKey类的具体用法?C++ VerseKey怎么用?C++ VerseKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VerseKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv) {
SWMgr manager(new MarkupFilterMgr(sword::FMT_HTMLHREF, sword::ENC_UTF16));
const char *bookName = (argc > 1) ? argv[1] : "WLC";
SWModule *b = manager.getModule(bookName);
if (!b) return -1;
SWModule &book = *b;
book.setProcessEntryAttributes(false);
VerseKey *vk = SWDYNAMIC_CAST(VerseKey, book.getKey());
// find the first non-zero entry
for (book = TOP; !book.popError() && !book.getRawEntryBuf().size(); book++);
if (!book.getRawEntryBuf().size()) return -2; // empty module
for (;!book.popError(); book++) {
cout << "$$$";
if (vk) cout << vk->getOSISRef();
else cout << book.getKeyText();
cout << "\n" << book.renderText() << "\n\n";
}
return 0;
}
示例2: parseRangeKey
std::string parseRangeKey(const char* keyValue, const char* locale) {
const char* oldLocale = LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName();
LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(locale);
std::string ret;
VerseKey DefaultVSKey;
DefaultVSKey = "jas3:1";
ListKey verses = DefaultVSKey.ParseVerseList(keyValue, DefaultVSKey, true);
for (int i = 0; i < verses.Count(); i++) {
VerseKey *element = dynamic_cast<VerseKey *>(verses.GetElement(i));
if (element) {
if (ret.length()) {
ret.append(" ");
}
ret.appendFormatted( "%s - %s;", (const char*)element->LowerBound(), (const char*)element->UpperBound() );
}
else {
if (ret.length()) {
ret.append(" ");
}
ret.appendFormatted("%s;", (const char *)*verses.GetElement(i));
}
}
// cout << ret.c_str() << endl;
LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(oldLocale);
return ret;
};
示例3: findOffset
void RawCom4::increment(int steps) {
long start;
unsigned long size;
VerseKey *tmpkey = &getVerseKey();
findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size);
SWKey lastgood = *tmpkey;
while (steps) {
long laststart = start;
unsigned long lastsize = size;
SWKey lasttry = *tmpkey;
(steps > 0) ? ++(*key) : --(*key);
tmpkey = &getVerseKey();
if ((error = key->popError())) {
*key = lastgood;
break;
}
long index = tmpkey->getTestamentIndex();
findOffset(tmpkey->getTestament(), index, &start, &size);
if (
(((laststart != start) || (lastsize != size)) // we're a different entry
// && (start > 0)
&& (size)) // and we actually have a size
||(!skipConsecutiveLinks)) { // or we don't want to skip consecutive links
steps += (steps < 0) ? 1 : -1;
lastgood = *tmpkey;
}
}
error = (error) ? KEYERR_OUTOFBOUNDS : 0;
}
示例4:
SWBuf &RawFiles::getRawEntryBuf() {
FileDesc *datafile;
long start = 0;
unsigned short size = 0;
VerseKey *key = &getVerseKey();
findOffset(key->Testament(), key->TestamentIndex(), &start, &size);
entryBuf = "";
if (size) {
SWBuf tmpbuf = path;
tmpbuf += '/';
readText(key->Testament(), start, size, entryBuf);
tmpbuf += entryBuf;
entryBuf = "";
datafile = FileMgr::getSystemFileMgr()->open(tmpbuf.c_str(), FileMgr::RDONLY);
if (datafile->getFd() > 0) {
size = datafile->seek(0, SEEK_END);
char *tmpBuf = new char [ size + 1 ];
memset(tmpBuf, 0, size + 1);
datafile->seek(0, SEEK_SET);
datafile->read(tmpBuf, size);
entryBuf = tmpBuf;
delete [] tmpBuf;
// preptext(entrybuf);
}
FileMgr::getSystemFileMgr()->close(datafile);
}
return entryBuf;
}
示例5: writeidx
void writeidx(VerseKey &key1, VerseKey &key2, VerseKey &key3, long offset, short size)
{
long pos;
short tmp;
for (; ((key1 <= key3) && (key1.popError() != KEYERR_OUTOFBOUNDS) && (key1.getTestament() == testmnt)); key1+=1) {
if (key1.getVerse() == 1) { // new chapter
if (key1.getChapter() == 1) { // new book
pos = lseek(cfp, 0, SEEK_CUR);
write(bfp, &pos, 4);
pos = lseek(vfp, 0, SEEK_CUR); /* Book intro (cps) */
write(cfp, &pos, 4);
write(vfp, &chapoffset, 4); /* Book intro (vss) set to same as chap for now(it should be chap 1 which usually contains the book into anyway)*/
write(vfp, &chapsize, 2);
}
pos = lseek(vfp, 0, SEEK_CUR);
write(cfp, &pos, 4);
write(vfp, &chapoffset, 4); /* Chapter intro */
write(vfp, &chapsize, 2);
}
if (key1 >= key2) {
write(vfp, &offset, 4);
write(vfp, &size, 2);
}
else {
pos = 0;
tmp = 0;
write(vfp, &pos, 4);
write(vfp, &tmp, 2);
}
}
}
示例6: main
int main(int argc, char **argv)
{
const char *range = (argc > 1) ? argv[1] : "Mat 2:10,12-15";
VerseKey parser;
ListKey result;
result = parser.parseVerseList(range, parser.getText().c_str(), true);
// let's iterate the key and display
for (result.positionToTop(); !result.popError(); result.increment()) {
cout << result.getText() << "\n";
}
cout << endl;
// Now let's output a module with the entries from the result
// we'll initialize our library of books
SWMgr library(std::make_shared<MarkupFilterMgr>(FMT_PLAIN)); // render plain without fancy markup
// Let's get a book;
auto const book(library.getModule("KJV"));
// couldn't find our test module
if (!book) return -1;
// now let's iterate the book and display
for (result.positionToTop(); !result.popError(); result.increment()) {
book->setKey(result);
cout << "*** " << book->getKeyText() << ": " << book->renderText() << "\n";
}
return 0;
}
示例7: 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);
}
}
}
}
示例8: VerseKey
SWKey *SWText::createKey() const {
VerseKey *vk = new VerseKey();
vk->setVersificationSystem(versification);
return vk;
}
示例9:
bool RawCom4::hasEntry(const SWKey *k) const {
long start;
unsigned long size;
VerseKey *vk = &getVerseKey(k);
findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size);
return size;
}
示例10: setIndex
void SWCom::setIndex(long iindex) {
VerseKey *key = &getVerseKey();
key->setTestament(1);
key->setIndex(iindex);
if (key != this->key) {
this->key->copyFrom(*key);
}
}
示例11: hasEntry
bool zCom::hasEntry(const SWKey *k) const {
long start;
unsigned short size;
unsigned long buffnum;
VerseKey *vk = &getVerseKey(k);
findOffset(vk->Testament(), vk->TestamentIndex(), &start, &size, &buffnum);
return size;
}
示例12: doLinkEntry
void zCom::linkEntry(const SWKey *inkey) {
VerseKey *destkey = &getVerseKey();
const VerseKey *srckey = &getVerseKey(inkey);
doLinkEntry(destkey->Testament(), destkey->TestamentIndex(), srckey->TestamentIndex());
if (inkey != srckey) // free our key if we created a VerseKey
delete srckey;
}
示例13: tag
bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution
MyUserData *u = (MyUserData *)userData;
XMLTag tag(token);
if ((!tag.isEndTag()) && (!tag.isEmpty()))
u->startTag = tag;
if (tag.getName() && !strcmp(tag.getName(), "sync")) {
SWBuf value = tag.getAttribute("value");
if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //>
buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str());
}
else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) {
if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') {
value<<1;
buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str());
}
else if (value[0] == 'T') {
value<<1;
buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str());
}
}
else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) {
if (!tag.isEndTag())
buf += "{\\b ";
else buf += "}";
}
}
// <note> tag
else if (!strcmp(tag.getName(), "note")) {
if (!tag.isEndTag()) {
if (!tag.isEmpty()) {
SWBuf type = tag.getAttribute("type");
SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
VerseKey *vkey = NULL;
// see if we have a VerseKey * or descendant
SWTRY {
vkey = SWDYNAMIC_CAST(VerseKey, u->key);
}
SWCATCH ( ... ) { }
if (vkey) {
// leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt.
char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, vkey->Verse(), footnoteNumber.c_str());
}
u->suspendTextPassThru = true;
}
}
if (tag.isEndTag()) {
u->suspendTextPassThru = false;
}
}
示例14: main
int main(int argc, char **argv) {
SWMgr mymgr;
SWModule *bbe = mymgr.Modules["BBE"];
if (bbe) {
VerseKey vk;
vk.setPersist(true);
bbe->setKey(vk);
for (; !bbe->popError(); (*bbe)++ ) {
std::cout << vk.getIndex() << std::endl;
}
}
return 0;
}
示例15: flushCache
void zCom::setEntry(const char *inbuf, long len) {
VerseKey *key = &getVerseKey();
// see if we've jumped across blocks since last write
if (lastWriteKey) {
if (!sameBlock(lastWriteKey, key)) {
flushCache();
}
delete lastWriteKey;
}
doSetText(key->Testament(), key->TestamentIndex(), inbuf, len);
lastWriteKey = (VerseKey *)key->clone(); // must delete
}