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