00001 #pragma once
00002 #include "stdafx.h"
00003 #include "sword2net.h"
00004 #include "swordbible.h"
00005 #include <swkey.h>
00006 #include <versekey.h>
00007 #include <defs.h>
00008 #include <swmgr.h>
00009 #include <swconfig.h>
00010 #include <swmodule.h>
00011 #include <markupfiltmgr.h>
00012 #include <iostream>
00013 using namespace std;
00014 using namespace sword;
00015 using namespace sword2net;
00016 using namespace System;
00017 using namespace System::Text;
00018 using namespace System::Collections;
00019 using namespace System::Runtime::InteropServices;
00020
00021
00022 SwordBibleModule::SwordBibleModule(){}
00023
00024 SwordBibleModule::SwordBibleModule(String^ modname, char markup, char encoding){
00025 try{
00026 Fmodulename= (const char*) (Marshal::StringToHGlobalAnsi(modname)).ToPointer();
00027 Fmodulemarkup=markup;
00028 Fmoduleencoding=encoding;
00029 SWMgr library=(new MarkupFilterMgr(Fmodulemarkup,Fmoduleencoding));
00030 SWModule *FFSwordBible=library.getModule(Fmodulename);
00031 Fmodulereference=gcnew String(FFSwordBible->getKey()->getShortText());
00032
00033 }finally{
00034
00035
00036 }
00037
00038 }
00039
00040
00041 String^ SwordBibleModule::GetVerse(String^ verseref){
00042
00043 try {
00044 SWMgr library=(new MarkupFilterMgr(this->Fmodulemarkup,this->Fmoduleencoding));
00045 if(0!=String::Compare(verseref,"",false)){
00046 this->Fmodulereference=verseref;
00047 }
00048 SWKey *KeyToQuery=new SWKey((const char*) (Marshal::StringToHGlobalAnsi(this->Fmodulereference)).ToPointer());
00049 SWModule *FFSwordBible=library.getModule(Fmodulename);
00050 return gcnew String(KeyToQuery->getShortText())+" "+(gcnew String(FFSwordBible->RenderText(KeyToQuery)))->Trim();
00051 }finally{
00052
00053
00054 }
00055
00056 }
00057
00058 String^ SwordBibleModule::NextVerse(){
00059
00060 try{
00061 SWMgr library=(new MarkupFilterMgr(this->Fmodulemarkup,this->Fmoduleencoding));
00062 VerseKey *KeyToQuery=new VerseKey((const char*) (Marshal::StringToHGlobalAnsi(this->Fmodulereference)).ToPointer());
00063 KeyToQuery->increment(1);
00064 this->Fmodulereference=gcnew String(KeyToQuery->getShortText());
00065 SWModule *FFSwordBible=library.getModule(Fmodulename);
00066 return gcnew String(KeyToQuery->getShortText())+" "+(gcnew String(FFSwordBible->RenderText(KeyToQuery)))->Trim();
00067 }
00068 finally{
00069
00070 }
00071 }
00072
00073 void SwordBibleModule::DumpBibleModuleContent(String^ modname,char markup, char encoding){
00074
00075 try{
00076 SWMgr library=(new MarkupFilterMgr(markup,encoding));
00077 const char* modname1 = (const char*) (Marshal::StringToHGlobalAnsi(modname)).ToPointer();
00078 SWModule *FFSwordBible=library.getModule(modname1);
00079 if (0==String::Compare(gcnew String(FFSwordBible->Type()), "Biblical Texts",false)){
00080 for ((*FFSwordBible)=TOP; !FFSwordBible->Error(); (*FFSwordBible)++){
00081 OnDumpNotify(gcnew String(FFSwordBible->getKey()->getShortText())+" "+ (gcnew String(FFSwordBible->RenderText()))->Trim());
00082 }}else{
00083
00084 OnDumpNotify(gcnew String("This is not a bible module!"));
00085 }
00086
00087 }
00088 finally{
00089
00090
00091 }
00092 }