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
|
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
|
-
+
-
+
-
+
-
-
+
-
-
+
-
-
+
+
-
+
-
-
+
+
-
-
-
+
+
+
|
#import "SL3PreparedStatement.h"
#import "SL3PreparedStatement+Private.h"
#import "SL3ExecuteStatementFailedException.h"
#import "SL3OpenFailedException.h"
@implementation SL3Connection
+ (instancetype)connectionWithPath: (OFString *)path
+ (instancetype)connectionWithIRI: (OFIRI *)IRI
{
return [[[self alloc] initWithPath: path] autorelease];
return [[[self alloc] initWithIRI: IRI] autorelease];
}
+ (instancetype)connectionWithPath: (OFString *)path
+ (instancetype)connectionWithIRI: (OFIRI *)IRI flags: (int)flags
flags: (int)flags
{
return [[[self alloc] initWithPath: path
return [[[self alloc] initWithIRI: IRI flags: flags] autorelease];
flags: flags] autorelease];
}
- (instancetype)initWithPath: (OFString *)path
- (instancetype)initWithIRI: (OFIRI *)IRI
{
return [self initWithPath: path
flags: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE];
return [self initWithIRI: IRI
flags: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE];
}
- (instancetype)initWithPath: (OFString *)path
- (instancetype)initWithIRI: (OFIRI *)IRI flags: (int)flags
flags: (int)flags
{
self = [super init];
@try {
int code = sqlite3_open_v2(path.UTF8String, &_conn, flags,
int code = sqlite3_open_v2(
IRI.fileSystemRepresentation.UTF8String, &_conn, flags,
NULL);
if (code != SQLITE_OK)
@throw [SL3OpenFailedException exceptionWithPath: path
flags: flags
errorCode: code];
@throw [SL3OpenFailedException exceptionWithIRI: IRI
flags: flags
errorCode: code];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|