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
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "SL3Connection.h"
#import "SL3Exception.h"
@implementation SL3Connection
+ (instancetype)connectionWithPath: (OFString *)path
flags: (int)flags
{
return [[[self alloc] initWithPath: path
flags: flags] autorelease];
}
- (instancetype)initWithPath: (OFString *)path
flags: (int)flags
{
self = [super init];
@try {
int errorCode = sqlite3_open_v2(path.UTF8String, &_database,
flags, NULL);
if (errorCode != SQLITE_OK)
/* TODO: Use an SL3Exception subclass. */
@throw [SL3Exception
exceptionWithConnection: nil
errorCode: errorCode];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|
|
<
|
|
>
|
|
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
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "SL3Connection.h"
#import "SL3OpenFailedException.h"
@implementation SL3Connection
+ (instancetype)connectionWithPath: (OFString *)path
flags: (int)flags
{
return [[[self alloc] initWithPath: path
flags: flags] autorelease];
}
- (instancetype)initWithPath: (OFString *)path
flags: (int)flags
{
self = [super init];
@try {
int errorCode = sqlite3_open_v2(path.UTF8String, &_database,
flags, NULL);
if (errorCode != SQLITE_OK)
@throw [SL3OpenFailedException
exceptionWithPath: path
flags: flags
errorCode: errorCode];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|