]> err.no Git - sope/blob - sope-gdl1/SQLite3/SQLiteContext.m
Added SQLite3 adaptor, bumped version informations
[sope] / sope-gdl1 / SQLite3 / SQLiteContext.m
1 /* 
2    SQLiteContext.m
3
4    Copyright (C) 2003-2005 SKYRIX Software AG
5
6    Author: Helge Hess (helge.hess@skyrix.com)
7
8    This file is part of the SQLite Adaptor Library
9
10    This library is free software; you can redistribute it and/or
11    modify it under the terms of the GNU Library General Public
12    License as published by the Free Software Foundation; either
13    version 2 of the License, or (at your option) any later version.
14
15    This library is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    Library General Public License for more details.
19
20    You should have received a copy of the GNU Library General Public
21    License along with this library; see the file COPYING.LIB.
22    If not, write to the Free Software Foundation,
23    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 */
25
26 #include "SQLiteContext.h"
27 #include "SQLiteChannel.h"
28 #include "common.h"
29
30 @implementation SQLiteContext
31
32 - (void)channelDidInit:_channel {
33   if ([channels count] > 0) {
34     [NSException raise:@"TooManyOpenChannelsException"
35                  format:@"SQLite3 only supports one channel per context"];
36   }
37   [super channelDidInit:_channel];
38 }
39
40 - (BOOL)primaryBeginTransaction {
41   BOOL result;
42   
43   result = [[[channels lastObject]
44                        nonretainedObjectValue]
45                        evaluateExpression:@"BEGIN TRANSACTION"];
46   
47   return result;
48 }
49
50 - (BOOL)primaryCommitTransaction {
51   BOOL result;
52
53   result = [[[channels lastObject]
54                        nonretainedObjectValue]
55                        evaluateExpression:@"COMMIT TRANSACTION"];
56
57   return result;
58 }
59
60 - (BOOL)primaryRollbackTransaction {
61   BOOL result;
62
63   result = [[[channels lastObject]
64                        nonretainedObjectValue]
65                        evaluateExpression:@"ROLLBACK TRANSACTION"];
66   return result;
67 }
68
69 - (BOOL)canNestTransactions {
70   return NO;
71 }
72
73 // NSCopying methods
74
75 - (id)copyWithZone:(NSZone *)zone {
76   return [self retain];
77 }
78
79 @end /* SQLiteContext */
80
81 void __link_SQLiteContext() {
82   // used to force linking of object file
83   __link_SQLiteContext();
84 }