passage.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * BIBISH Is [a] Bible Interactive SHell, a front-end for the SWORD Project
  3. * inspired by Debian's bible package
  4. * Copyright (C) 2015 David Blue <yudahsshadow@gmx.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation version 2.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. */
  20. #include "passage.h"
  21. #include "library.h"
  22. #include <string>
  23. #include <iostream>
  24. #include <list>
  25. #include <swmgr.h>
  26. #include <swmodule.h>
  27. #include <markupfiltmgr.h>
  28. #include <versekey.h>
  29. #include <listkey.h>
  30. void Passage::setVersion (std::string version) {
  31. this->version = version;
  32. }
  33. void Passage::setLibrary(sword::SWMgr &library) {
  34. swordLibrary = library;
  35. }
  36. std::string Passage::getText (std::string reference) {
  37. std::string text = "";
  38. //Variables related to splitting up the reference for iteration
  39. sword::ListKey refRange;
  40. //Module variables
  41. sword::SWModule *module = \
  42. swordLibrary.getModule(version.c_str());
  43. sword::VerseKey key;
  44. refRange = key.parseVerseList(reference.c_str(), key, true);
  45. for(refRange = sword::TOP; !refRange.popError(); refRange++) {
  46. module->setKey(refRange);
  47. text += " "; //TODO: Fix this to show the book name on the first verse
  48. //TODO: show chap and verse only after the first verse
  49. text += module->getKeyText();
  50. text += " ";
  51. text += module->renderText();
  52. }
  53. return text;
  54. }