Example #1
0
int main(int argc, char **argv) {

    const char* modName = (argc >= 2) ? argv[1] : "KJV";
    const char* keyName = (argc == 3) ? argv[2] : "John 1:1";

    SWMgr mgr(0, 0, true, new MarkupFilterMgr(FMT_WEBIF, ENC_UTF8));
    mgr.setGlobalOption("Strong's Numbers", "on");
    mgr.setGlobalOption("Morphological Tags", "on");

    SWModule *module = mgr.Modules[modName];
    if (!module) {
        module = mgr.Modules.begin()->second;
    }
    module->setKey(keyName);
    std::cout << module->renderText() << std::endl<< std::endl<< std::endl;

    //------------------------

    SWMgr mgr2(0, 0, true, new MarkupFilterMgr(FMT_HTMLHREF, ENC_UTF8));
    mgr2.setGlobalOption("Strong's Numbers", "on");
    mgr2.setGlobalOption("Morphological Tags", "on");
    module = mgr2.Modules[modName];
    if (!module) {
        module = mgr2.Modules.begin()->second;
    }

    module->setKey(keyName);
    std::cout << module->renderText() << std::endl;

    return 0;
}
Example #2
0
int main(int argc, char **argv) {

	if (argc != 2) {
		cerr << "\nusage: " << *argv << " <modName>\n" << endl;
		exit(-1);
	}

	SWMgr library(new MarkupFilterMgr(FMT_XHTML));
	library.setGlobalOption("Headings", "On");

	SWModule *module = library.getModule(argv[1]);

	if (!module) {
		cerr << "\nCouldn't find module: " << argv[1] << "\n" << endl;
		exit(-2);
	}

	module->setKey("Ps.3.1");
	outputCurrentVerse(module);

	module->setKey("Mark.1.14");
	outputCurrentVerse(module);


	cout << "\nWhitespace tests around headings:\n";
	((VerseKey *)module->getKey())->setIntros(true);
	*module = TOP;
	// module heading
	cout << module->renderText() << "\n";
	(*module)++;
	// testament heading
	cout << module->renderText() << "\n";
	(*module)++;
	// book heading
	cout << module->renderText() << "\n";
	(*module)++;
	// chapter heading
	cout << module->renderText() << "\n";
	(*module)++;
	// verse body
	module->renderText();
	SWBuf header = module->getEntryAttributes()["Heading"]["Preverse"]["0"];
	cout << module->renderText(header) << endl;
	cout << "[ " << module->getKeyText() << " ] " << module->renderText() << "\n";
	(*module)++;
	// verse body
	module->renderText();
	header = module->getEntryAttributes()["Heading"]["Preverse"]["0"];
	cout << module->renderText(header) << endl;
	cout << "[ " << module->getKeyText() << " ] " << module->renderText() << "\n";

	return 0;
}
Example #3
0
const char *SWModule_getEntryAttributes(SWHANDLE hmodule, const char *level1, const char *level2, const char *level3) {
	SWModule *module = (SWModule *)hmodule;
	static SWBuf retval;	
	module->renderText();                 	
	retval = module->getEntryAttributes()[level1][level2][level3].c_str();
	return (retval.length()) ? (const char*)retval.c_str() : NULL;
}
Example #4
0
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, true);

	// let's iterate the key and display
	for (result = TOP; !result.popError(); result++) {
		cout << result << "\n";
	}
	cout << endl;

	// Now let's output a module with the entries from the result
	
	// we'll initialize our library of books
	SWMgr library(new MarkupFilterMgr(FMT_PLAIN));	// render plain without fancy markup

	// Let's get a book;
	SWModule *book = library.getModule("KJV");

	// couldn't find our test module
	if (!book) return -1;

	// now let's iterate the book and display
	for (result = TOP; !result.popError(); result++) {
		book->setKey(result);
		cout << "*** " << book->getKeyText() << ": " << book->renderText() << "\n";
	}

	return 0;
}
Example #5
0
const char *SWModule_getFootnoteRefList(SWHANDLE hmodule, const char *key, const char *note) {
	SWModule *module = (SWModule *)hmodule;
	static SWBuf refList;
	module->popError();
	module->setKey(key);
	module->renderText();	
	refList = module->getEntryAttributes()["Footnote"][note]["refList"].c_str();
	return (refList) ? (const char*)refList.c_str() : NULL;
}
Example #6
0
const char *SWModule_getFootnoteType(SWHANDLE hmodule, const char *key, const char *note) {
	SWModule *module = (SWModule *)hmodule;
	static SWBuf type;
	module->popError();
	module->setKey(key);
	module->renderText();	
	type = module->getEntryAttributes()["Footnote"][note]["type"].c_str();
	return (type) ? (const char*)type.c_str() : NULL;
}
Example #7
0
const char *SWModule_getPreverseHeader(SWHANDLE hmodule, const char *key, int pvHeading) {
	SWModule *module = (SWModule *)hmodule;
	static SWBuf preverseHeading;
	char buf[12];	
	sprintf(buf, "%i", pvHeading);  
	module->setKey(key);	
	module->renderText();                 	
	preverseHeading = module->getEntryAttributes()["Heading"]["Preverse"][buf].c_str();
	return (preverseHeading.length()) ? (const char*)preverseHeading.c_str() : NULL;
}
Example #8
0
const char *SWModule_getFootnoteBody(SWHANDLE hmodule, const char *key, const char *note) {
	SWModule *module = (SWModule *)hmodule;
	static SWBuf body;
	module->popError();
	module->setKey(key);
	module->renderText();
	body = module->getEntryAttributes()["Footnote"][note]["body"].c_str();
	SWKey *keybuf = module->getKey();;
	module->renderFilter(body, keybuf);
	return (body) ? (const char*)body.c_str() : NULL;
}
Example #9
0
/*
 * Class:     org_crosswire_android_sword_SWModule
 * Method:    getRenderText
 * Signature: ()Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL Java_org_crosswire_android_sword_SWModule_getRenderText
  (JNIEnv *env, jobject me) {

	init();

	SWModule *module = getModule(env, me);

	jstring retVal = 0;
	if (module) {
		retVal = env->NewStringUTF(assureValidUTF8(module->renderText()));
	}
	return retVal;
}
Example #10
0
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, true);
	// let's iterate the key and display
	for (result = TOP; !result.popError(); result++) {
		cout << result << "\n";
	}
	cout << endl;

	// Now if we'd like persist this key for use inside of a book...
	result.setPersist(true);
	
	// Let's get a book;
	SWMgr library(new MarkupFilterMgr(FMT_PLAIN));	// render plain without fancy markup
	SWModule *book = library.getModule("KJV");

	// and set our limited key inside
	book->setKey(result);

	// now let's iterate the book and display
	for ((*book) = TOP; !book->popError(); (*book)++) {
		cout << "*** " << book->getKeyText() << ": " << book->renderText() << "\n";
	}

	// Since we've told our result key to persist in book, we can reuse our
	// setup by simply resetting result, e.g.
	//
	// result = parser.ParseVerseList(someNewRange, parser, true);
	//
	// Now an iteration of book will give us our new range.
	//
	// To stop persistence of our custom key, we'll need to set our book's key
	// to something simple:
	// 
	// book->setKey("gen.1.1");
	// 
	// Resetting our book object's key to something not persistent will revert our book object to using its default key for positioning
	//
	//

	return 0;
}
Example #11
0
int main(int argc, char **argv) {
	if (argc < 2) {
		fprintf(stderr, "usage: %s <Mod Name>\n", argv[0]);
		exit(-1);
	}

	SWMgr mgr;

	ModMap::iterator it = mgr.Modules.find(argv[1]);
	if (it == mgr.Modules.end()) {
		fprintf(stderr, "error: %s: couldn't find module: %s \n", argv[0], argv[1]);
		exit(-2);
	}

	SWModule *mod = it->second;

	SWKey *key = (*mod);
	VerseKey *vkey = 0;
	SWTRY {
		vkey = dynamic_cast<VerseKey *>(key);
	}
	SWCATCH (...) {}

	if (!vkey) {
		fprintf(stderr, "error: %s: %s module is not keyed to verses \n", argv[0], argv[1]);
		exit(-3);
	}

	vkey->setIntros(false);	// turn on mod/testmnt/book/chap headings

	(*mod) = TOP;

	while (!mod->popError()) {
	  
	if (vkey->getVerse())
		if (!mod->renderText().length())
			std::cout << *vkey << std::endl;
		(*mod)++;
	}
}
Example #12
0
int main(int argc, char **argv) {

    SWMgr manager;        // create a default manager that looks in the current directory for mods.conf

    cout << "\nInstalled Modules:\n\n";

    ModMap::iterator modIterator;

// Loop thru all installed modules and print out information

    for (modIterator = manager.Modules.begin(); modIterator != manager.Modules.end(); modIterator++) {
        std::string   modName  = (*modIterator).first;  // mod.conf section name (stored in module->Name())
        SWModule *module  = (*modIterator).second;

        cout << modName << "(" << module->getName() << ") | " << module->getType() << "\n";
    }

// Print out a verse from the first module:

    cout << "\n" << manager.Modules.begin()->second->getKeyText() << ":\n";
    cout << manager.Modules.begin()->second->renderText();
    cout << " (" << manager.Modules.begin()->second->getName() << ")\n";

// Print out the same verse from the second module (less confusing):

    modIterator = manager.Modules.begin();    // get first module
    modIterator++;                // increment to next module

    SWModule *mod = modIterator->second;

    cout << "\n" << mod->getKeyText() << ":\n";
//    cout << (const char *)(*mod);        // we could do this, the same as above
    cout << mod->renderText();
    cout << " (" << mod->getName() << ")\n\n";

    return 0;

}
Example #13
0
const char *SWModule_getRenderText(SWHANDLE hmodule) {
	SWModule *module = (SWModule *)hmodule;
	return (const char *)((module) ? module->renderText().c_str() : 0);
}
Example #14
0
/*
 * Class:     org_crosswire_android_sword_SWModule
 * Method:    getEntryAttribute
 * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)[Ljava/lang/String;
 */
JNIEXPORT jobjectArray JNICALL Java_org_crosswire_android_sword_SWModule_getEntryAttribute
  (JNIEnv *env, jobject me, jstring level1JS, jstring level2JS, jstring level3JS, jboolean filteredJS) {

	init(); 

	const char *level1 = env->GetStringUTFChars(level1JS, NULL);
	const char *level2 = env->GetStringUTFChars(level2JS, NULL);
	const char *level3 = env->GetStringUTFChars(level3JS, NULL);
	bool filtered = (filteredJS == JNI_TRUE);

	jclass clazzString = env->FindClass("java/lang/String");
	jobjectArray ret = 0;

	SWModule *module = getModule(env, me);

	if (module) {

		module->renderText();	// force parse
		vector<SWBuf> results;

		sword::AttributeTypeList &entryAttribs = module->getEntryAttributes();
		sword::AttributeTypeList::iterator i1Start, i1End;
		sword::AttributeList::iterator i2Start, i2End;
		sword::AttributeValue::iterator i3Start, i3End;

		if ((level1) && (*level1)) {
			i1Start = entryAttribs.find(level1);
			i1End = i1Start;
			if (i1End != entryAttribs.end())
				++i1End;
		}
		else {
			i1Start = entryAttribs.begin();
			i1End   = entryAttribs.end();
		}
		for (;i1Start != i1End; ++i1Start) {
			if ((level2) && (*level2)) {
				i2Start = i1Start->second.find(level2);
				i2End = i2Start;
				if (i2End != i1Start->second.end())
					++i2End;
			}
			else {
				i2Start = i1Start->second.begin();
				i2End   = i1Start->second.end();
			}
			for (;i2Start != i2End; ++i2Start) {
				if ((level3) && (*level3)) {
					i3Start = i2Start->second.find(level3);
					i3End = i3Start;
					if (i3End != i2Start->second.end())
						++i3End;
				}
				else {
					i3Start = i2Start->second.begin();
					i3End   = i2Start->second.end();
				}
				for (;i3Start != i3End; ++i3Start) {
					results.push_back(i3Start->second);
				}
				if (i3Start != i3End)
					break;
			}
			if (i2Start != i2End)
				break;
		}

		ret = (jobjectArray) env->NewObjectArray(results.size(), clazzString, NULL);

SWLog::getSystemLog()->logDebug("getEntryAttributes: size returned: %d", results.size());

		for (int i = 0; i < results.size(); i++) {
			if (filtered) {
				env->SetObjectArrayElement(ret, i, env->NewStringUTF(assureValidUTF8(module->renderText(results[i].c_str()))));
			}
			else {
				env->SetObjectArrayElement(ret, i, env->NewStringUTF(assureValidUTF8(results[i].c_str())));
			}
		}
	}

	env->ReleaseStringUTFChars(level3JS, level3);
	env->ReleaseStringUTFChars(level2JS, level2);
	env->ReleaseStringUTFChars(level1JS, level1);

	return (ret) ? ret : (jobjectArray) env->NewObjectArray(0, clazzString, NULL);
}