[sword-svn] r3746 - in trunk: include src/keys

scribe at crosswire.org scribe at crosswire.org
Sun May 17 18:10:52 MST 2020


Author: scribe
Date: 2020-05-17 18:10:52 -0700 (Sun, 17 May 2020)
New Revision: 3746

Modified:
   trunk/include/listkey.h
   trunk/include/swkey.h
   trunk/include/versekey.h
   trunk/src/keys/listkey.cpp
   trunk/src/keys/versekey.cpp
Log:
Added getShortRangeText to boundable keys


Modified: trunk/include/listkey.h
===================================================================
--- trunk/include/listkey.h	2020-05-17 10:32:25 UTC (rev 3745)
+++ trunk/include/listkey.h	2020-05-18 01:10:52 UTC (rev 3746)
@@ -139,6 +139,7 @@
 	virtual long getIndex() const { return arraypos; }
 	virtual const char *getRangeText() const;
 	virtual const char *getOSISRefRangeText() const;
+	virtual const char *getShortRangeText() const;
 	virtual const char *getShortText() const;
 
 	/**

Modified: trunk/include/swkey.h
===================================================================
--- trunk/include/swkey.h	2020-05-17 10:32:25 UTC (rev 3745)
+++ trunk/include/swkey.h	2020-05-18 01:10:52 UTC (rev 3746)
@@ -178,6 +178,7 @@
 	virtual const char *getText() const;
 	virtual const char *getShortText() const { return getText(); }
 	virtual const char *getRangeText() const;
+	virtual const char *getShortRangeText() const { return getRangeText(); }
 	virtual const char *getOSISRefRangeText() const;
 	virtual bool isBoundSet() const { return boundSet; }
 	virtual void clearBounds() const { boundSet = false; }

Modified: trunk/include/versekey.h
===================================================================
--- trunk/include/versekey.h	2020-05-17 10:32:25 UTC (rev 3745)
+++ trunk/include/versekey.h	2020-05-18 01:10:52 UTC (rev 3746)
@@ -436,6 +436,7 @@
 	virtual ListKey parseVerseList(const char *buf, const char *defaultKey = 0, bool expandRange = false, bool useChapterAsVerse = false);
 	SWDEPRECATED ListKey ParseVerseList(const char *buf, const char *defaultKey = 0, bool expandRange = false, bool useChapterAsVerse = false) { return parseVerseList(buf, defaultKey, expandRange, useChapterAsVerse); }
 	virtual const char *getRangeText() const;
+	virtual const char *getShortRangeText() const;
 	virtual const char *getOSISRefRangeText() const;
 	/** Compares another	SWKey object
 	*

Modified: trunk/src/keys/listkey.cpp
===================================================================
--- trunk/src/keys/listkey.cpp	2020-05-17 10:32:25 UTC (rev 3745)
+++ trunk/src/keys/listkey.cpp	2020-05-18 01:10:52 UTC (rev 3746)
@@ -327,6 +327,22 @@
 
 
 /******************************************************************************
+ * ListKey::getShortRangeText - returns short parsable range text for this key
+ */
+
+const char *ListKey::getShortRangeText() const {
+	SWBuf buf;
+	for (int i = 0; i < arraycnt; i++) {
+		buf += array[i]->getShortRangeText();
+		if (i < arraycnt-1)
+			buf += "; ";
+	}
+	stdstr(&rangeText, buf.c_str());
+	return rangeText;
+}
+
+
+/******************************************************************************
  * ListKey::getText - returns text key if (const char *) cast is requested
  */
 

Modified: trunk/src/keys/versekey.cpp
===================================================================
--- trunk/src/keys/versekey.cpp	2020-05-17 10:32:25 UTC (rev 3745)
+++ trunk/src/keys/versekey.cpp	2020-05-18 01:10:52 UTC (rev 3746)
@@ -1842,6 +1842,31 @@
 
 
 /******************************************************************************
+ * VerseKey::getShortRangeText - returns short parsable range text for this key
+ */
+
+const char *VerseKey::getShortRangeText() const {
+	if (isBoundSet() && (lowerBound != upperBound)) {
+		SWBuf buf = getLowerBound().getShortText();
+		buf += "-";
+		if ( getUpperBound().getTestament() == getLowerBound().getTestament()
+		  && getUpperBound().getBook() == getLowerBound().getBook()
+		  && getUpperBound().getChapter() == getLowerBound().getChapter()) {
+			buf.appendFormatted("%d", getUpperBound().getVerse());
+		}
+		else if ( getUpperBound().getTestament() == getLowerBound().getTestament()
+		       && getUpperBound().getBook() == getLowerBound().getBook()) {
+			buf.appendFormatted("%d:%d", getUpperBound().getChapter(), getUpperBound().getVerse());
+		}
+		else buf += getUpperBound().getShortText();
+		stdstr(&rangeText, buf.c_str());
+	}
+	else stdstr(&rangeText, getShortText());
+	return rangeText;
+}
+
+
+/******************************************************************************
  * VerseKey::getOSISRefRangeText - returns parsable range text for this key
  */
 




More information about the sword-cvs mailing list