[sword-svn] r2227 - in trunk: include src/keys
scribe at crosswire.org
scribe at crosswire.org
Sat Jan 17 13:51:49 MST 2009
Author: scribe
Date: 2009-01-17 13:51:48 -0700 (Sat, 17 Jan 2009)
New Revision: 2227
Modified:
trunk/include/versekey.h
trunk/src/keys/versekey.cpp
Log:
Added a setter to compliment the getBookName getter.
initialized VerseKey testament, book, chaper, verse, headings
values to something that isn't out of bounds.
Modified: trunk/include/versekey.h
===================================================================
--- trunk/include/versekey.h 2009-01-14 06:28:45 UTC (rev 2226)
+++ trunk/include/versekey.h 2009-01-17 20:51:48 UTC (rev 2227)
@@ -120,6 +120,13 @@
protected:
+ /************************************************************************
+ * VerseKey::getBookAbbrev - Attempts to find a book no from a name or
+ * abbreviation
+ *
+ * ENT: @param abbr - key for which to search;
+ * RET: @return book number or < 0 = not valid
+ */
virtual int getBookAbbrev(const char *abbr);
/** Refresh keytext based on testament|book|chapter|verse
@@ -256,7 +263,11 @@
virtual void increment(int steps = 1);
virtual bool isTraversable() const { return true; }
+ /** Get/Set position of this key by Book Name
+ */
virtual const char *getBookName() const;
+ virtual void setBookName(const char *bname);
+
virtual const char *getBookAbbrev() const;
/** Gets testament
*
Modified: trunk/src/keys/versekey.cpp
===================================================================
--- trunk/src/keys/versekey.cpp 2009-01-14 06:28:45 UTC (rev 2226)
+++ trunk/src/keys/versekey.cpp 2009-01-17 20:51:48 UTC (rev 2227)
@@ -44,10 +44,10 @@
upperBound = 0;
lowerBound = 0;
boundSet = false;
- testament = 0;
- book = 0;
- chapter = 0;
- verse = 0;
+ testament = 1;
+ book = 1;
+ chapter = 1;
+ verse = 1;
suffix = 0;
locale = 0;
@@ -321,8 +321,9 @@
-/******************************************************************************
- * VerseKey::getBookAbbrev - Attempts to find a book abbreviation for a buffer
+/************************************************************************
+ * VerseKey::getBookAbbrev - Attempts to find a book no from a name or
+ * abbreviation
*
* ENT: abbr - key for which to search;
* RET: book number or < 0 = not valid
@@ -1278,10 +1279,6 @@
* VerseKey::Book - Sets/gets book
*
* ENT: ibook - value which to set book
- * [MAXPOS(char)] - only get
- *
- * RET: if unchanged -> value of book
- * if changed -> previous value of book
*/
void VerseKey::setBook(char ibook)
@@ -1292,14 +1289,28 @@
}
+
/******************************************************************************
+ * VerseKey::Book - Sets/gets book by name
+ *
+ * ENT: bname - book name/abbrev
+ */
+
+void VerseKey::setBookName(const char *bname)
+{
+ int bnum = getBookAbbrev(bname);
+ if (bnum > -1) {
+ setTestament(1);
+ setBook(bnum);
+ }
+ else error = KEYERR_OUTOFBOUNDS;
+}
+
+
+/******************************************************************************
* VerseKey::Chapter - Sets/gets chapter
*
* ENT: ichapter - value which to set chapter
- * [MAXPOS(int)] - only get
- *
- * RET: if unchanged -> value of chapter
- * if changed -> previous value of chapter
*/
void VerseKey::setChapter(int ichapter)
More information about the sword-cvs
mailing list