summaryrefslogtreecommitdiff
path: root/bindings/objc/src/SwordListKey.mm
blob: 161c6aa90a8b2bd15cb9d9535b1e86df0022a5fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//
//  SwordListKey.mm
//  MacSword2
//
//  Created by Manfred Bergmann on 10.04.09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "SwordListKey.h"
#import "SwordBible.h"
#import "SwordVerseKey.h"
#import "VerseEnumerator.h"

@interface SwordListKey ()
@end

@implementation SwordListKey

+ (id)listKeyWithRef:(NSString *)aRef {
    return [[[SwordListKey alloc] initWithRef:aRef] autorelease];
}

+ (id)listKeyWithRef:(NSString *)aRef v11n:(NSString *)scheme {
    return [[[SwordListKey alloc] initWithRef:aRef v11n:scheme] autorelease];
}

+ (id)listKeyWithRef:(NSString *)aRef headings:(BOOL)headings v11n:(NSString *)scheme {
    return [[[SwordListKey alloc] initWithRef:aRef headings:headings v11n:scheme] autorelease];
}

+ (id)listKeyWithSWListKey:(sword::ListKey *)aLk {
    return [[[SwordListKey alloc] initWithSWListKey:aLk] autorelease];
}

+ (id)listKeyWithSWListKey:(sword::ListKey *)aLk makeCopy:(BOOL)copy {
    return [[[SwordListKey alloc] initWithSWListKey:aLk makeCopy:copy] autorelease];    
}

- (id)init {
    return [super init];
}

- (id)initWithSWListKey:(sword::ListKey *)aLk {
    return [super initWithSWKey:aLk];
}

- (id)initWithSWListKey:(sword::ListKey *)aLk makeCopy:(BOOL)copy {
    return [super initWithSWKey:aLk makeCopy:copy];
}

- (id)initWithRef:(NSString *)aRef {
    return [self initWithRef:aRef v11n:nil];
}

- (id)initWithRef:(NSString *)aRef v11n:(NSString *)scheme {
    return [self initWithRef:aRef headings:NO v11n:scheme];
}

- (id)initWithRef:(NSString *)aRef headings:(BOOL)headings v11n:(NSString *)scheme {
    sword::VerseKey vk;
    vk.Headings((char)headings);
    if(scheme) {
        vk.setVersificationSystem([scheme UTF8String]);
    }
    sword::ListKey listKey = vk.ParseVerseList([aRef UTF8String], "gen", true);
    sword::ListKey *lk = new sword::ListKey(listKey);
    return [super initWithSWKey:lk];    
}

- (void)finalize {
    [super finalize];
}

- (void)dealloc {
    [super dealloc];    
}

- (NSInteger)numberOfVerses {
    NSInteger ret = 0;
    
    if(sk) {
        for(*sk = sword::TOP; !sk->Error(); *sk++) ret++;    
    }
    
    return ret;
}

- (void)parse {
    
}

- (void)parseWithHeaders {
    
}

- (VerseEnumerator *)verseEnumerator {
    return [[[VerseEnumerator alloc] initWithListKey:self] autorelease];
}

- (BOOL)containsKey:(SwordVerseKey *)aVerseKey {
    BOOL ret = NO;
    
    if(sk) {
        *sk = [[aVerseKey osisRef] UTF8String];
        ret = !sk->Error();
    }
    
    return ret;
}

- (sword::ListKey *)swListKey {
    return (sword::ListKey *)sk;
}

@end