[sword-svn] r2618 - trunk/bindings/objc/src

mdbergmann at crosswire.org mdbergmann at crosswire.org
Sat Mar 19 04:54:59 MST 2011


Author: mdbergmann
Date: 2011-03-19 04:54:58 -0700 (Sat, 19 Mar 2011)
New Revision: 2618

Modified:
   trunk/bindings/objc/src/SwordBible.mm
   trunk/bindings/objc/src/SwordLocaleManager.h
   trunk/bindings/objc/src/SwordLocaleManager.mm
Log:
SwordLocaleManager can be initialized with a given path to locales.d. Swordbible decodeRef class method will now only pass back values where not NULL was delivered.

Modified: trunk/bindings/objc/src/SwordBible.mm
===================================================================
--- trunk/bindings/objc/src/SwordBible.mm	2011-03-16 21:03:54 UTC (rev 2617)
+++ trunk/bindings/objc/src/SwordBible.mm	2011-03-19 11:54:58 UTC (rev 2618)
@@ -49,12 +49,20 @@
 	if(!bibleLock) bibleLock = [[NSLock alloc] init];
 	[bibleLock lock];
 	
-	sword::VerseKey vk([ref UTF8String]);
-	
-	*bookName = [NSString stringWithUTF8String:vk.getBookName()];
-    *book = vk.Book();
-	*chapter = vk.Chapter();
-	*verse = vk.Verse();
+    SwordVerseKey *key = [SwordVerseKey verseKeyWithRef:ref];
+
+    if(bookName != NULL) {
+        *bookName = [key bookName];        
+    }
+    if(book != NULL) {
+        *book = [key book];        
+    }
+    if(chapter != NULL) {
+        *chapter = [key chapter];        
+    }
+    if(verse != NULL) {
+        *verse = [key verse];
+    }
     
 	[bibleLock unlock];
 }

Modified: trunk/bindings/objc/src/SwordLocaleManager.h
===================================================================
--- trunk/bindings/objc/src/SwordLocaleManager.h	2011-03-16 21:03:54 UTC (rev 2617)
+++ trunk/bindings/objc/src/SwordLocaleManager.h	2011-03-19 11:54:58 UTC (rev 2618)
@@ -19,4 +19,10 @@
  */
 - (void)initLocale;
 
+/**
+ Initializes global locale system.
+ Loads the locale (locale.d) folder from the specified path.
+ */
+- (void)initLocaleWithLocaledPath:(NSString *)aPath;
+
 @end

Modified: trunk/bindings/objc/src/SwordLocaleManager.mm
===================================================================
--- trunk/bindings/objc/src/SwordLocaleManager.mm	2011-03-16 21:03:54 UTC (rev 2617)
+++ trunk/bindings/objc/src/SwordLocaleManager.mm	2011-03-19 11:54:58 UTC (rev 2618)
@@ -27,8 +27,12 @@
     // set locale swManager
     NSString *resourcePath = [[NSBundle bundleForClass:[SwordLocaleManager class]] resourcePath];
     NSString *localePath = [resourcePath stringByAppendingPathComponent:@"locales.d"];
+    [self initLocaleWithLocaledPath:localePath];
+}
+
+- (void)initLocaleWithLocaledPath:(NSString *)aPath {
     sword::LocaleMgr *lManager = sword::LocaleMgr::getSystemLocaleMgr();
-    lManager->loadConfigDir([localePath UTF8String]);
+    lManager->loadConfigDir([aPath UTF8String]);
     
     //get the language
     NSArray *availLocales = [NSLocale preferredLanguages];
@@ -56,7 +60,7 @@
     
     if(haveLocale) {
         lManager->setDefaultLocaleName([lang UTF8String]);    
-    }    
+    }
 }
 
 @end




More information about the sword-cvs mailing list