Index: Makefile ================================================================== --- Makefile +++ Makefile @@ -1,7 +1,7 @@ SUBDIRS = src -DISTCLEAN = ObjSQLite.oc \ +DISTCLEAN = ObjSQLite3.oc \ aclocal.m4 \ autom4te.cache \ buildsys.mk \ config.h \ config.log \ DELETED ObjSQLite.oc.in Index: ObjSQLite.oc.in ================================================================== --- ObjSQLite.oc.in +++ /dev/null @@ -1,3 +0,0 @@ -package_format 1 -CPPFLAGS="$CPPFLAGS @SQLITE_CPPFLAGS@" -LIBS="-lobjsqlite @SQLITE_LIBS@ $LIBS" ADDED ObjSQLite3.oc.in Index: ObjSQLite3.oc.in ================================================================== --- /dev/null +++ ObjSQLite3.oc.in @@ -0,0 +1,3 @@ +package_format 1 +CPPFLAGS="$CPPFLAGS @SQLITE3_CPPFLAGS@" +LIBS="-lobjsqlite3 @SQLITE3_LIBS@ $LIBS" Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -1,6 +1,6 @@ -AC_INIT(ObjSQLite, 0.1, js@nil.im) +AC_INIT(ObjSQLite3, 0.1, js@nil.im) AC_CONFIG_SRCDIR(src) AC_CONFIG_AUX_DIR(build-aux) AC_CONFIG_MACRO_DIR(build-aux/m4) for i in configure.ac build-aux/m4/*; do @@ -38,36 +38,36 @@ AC_PROG_RANLIB AC_ARG_ENABLE(shared, AS_HELP_STRING([--disable-shared], [do not build shared library])) AS_IF([test x"$enable_shared" != x"no"], [ BUILDSYS_SHARED_LIB - AC_SUBST(OBJSQLITE_SHARED_LIB, "${LIB_PREFIX}objsqlite${LIB_SUFFIX}") + AC_SUBST(OBJSQLITE3_SHARED_LIB, "${LIB_PREFIX}objsqlite3${LIB_SUFFIX}") AC_SUBST(EXCEPTIONS_LIB_A, "exceptions.lib.a") AC_SUBST(EXCEPTIONS_EXCEPTIONS_LIB_A, "exceptions/exceptions.lib.a") BUILDSYS_FRAMEWORK([ - AC_SUBST(OBJSQLITE_FRAMEWORK, "ObjSQLite.framework") + AC_SUBST(OBJSQLITE3_FRAMEWORK, "ObjSQLite3.framework") ]) ]) AC_ARG_ENABLE(static, AS_HELP_STRING([--enable-static], [build static library])) AS_IF([test x"$enable_static" = x"yes" -o x"$enable_shared" = x"no"], [ - AC_SUBST(OBJSQLITE_STATIC_LIB, "libobjsqlite.a") + AC_SUBST(OBJSQLITE3_STATIC_LIB, "libobjsqlite3.a") AC_SUBST(EXCEPTIONS_A, "exceptions.a") AC_SUBST(EXCEPTIONS_EXCEPTIONS_A, "exceptions/exceptions.a") ]) -AC_ARG_WITH(sqlite, AS_HELP_STRING([--with-sqlite=PREFIX], - [build with SQLite in the specified prefix])) -AS_IF([test x"$with_sqlite" != x"no" -a x"$with_sqlite" != x""], [ - SQLITE_CPPFLAGS="-I$with_sqlite/include" - SQLITE_LIBS="-L$with_sqlite/lib" - CPPFLAGS="$CPPFLAGS $SQLITE_CPPFLAGS" - LIBS="$LIBS $SQLITE_LIBS" +AC_ARG_WITH(sqlite3, AS_HELP_STRING([--with-sqlite3=PREFIX], + [build with SQLite3 in the specified prefix])) +AS_IF([test x"$with_sqlite3" != x"no" -a x"$with_sqlite3" != x""], [ + SQLITE3_CPPFLAGS="-I$with_sqlite3/include" + SQLITE3_LIBS="-L$with_sqlite3/lib" + CPPFLAGS="$CPPFLAGS $SQLITE3_CPPFLAGS" + LIBS="$LIBS $SQLITE3_LIBS" ]) AC_CHECK_LIB(sqlite3, main, [ - SQLITE_LIBS="$SQLITE_LIBS -lsqlite3" + SQLITE3_LIBS="$SQLITE3_LIBS -lsqlite3" LIBS="$LIBS -lsqlite3" ], [ AC_MSG_ERROR(You need SQLite3 and installed!) ]) @@ -108,10 +108,10 @@ dnl We don't call AC_PROG_CPP, but only AC_PROG_OBJCPP and set CPP to OBJCPP dnl and add OBJCPPFLAGS to CPPFLAGS, thus we need to AC_SUBST these ourself. AC_SUBST(CPP) AC_SUBST(CPPFLAGS) -AC_SUBST(SQLITE_CFLAGS) -AC_SUBST(SQLITE_LIBS) +AC_SUBST(SQLITE3_CPPFLAGS) +AC_SUBST(SQLITE3_LIBS) -AC_CONFIG_FILES([buildsys.mk extra.mk ObjSQLite.oc]) +AC_CONFIG_FILES([buildsys.mk extra.mk ObjSQLite3.oc]) AC_OUTPUT Index: extra.mk.in ================================================================== --- extra.mk.in +++ extra.mk.in @@ -1,8 +1,8 @@ -OBJSQLITE_SHARED_LIB = @OBJSQLITE_SHARED_LIB@ -OBJSQLITE_STATIC_LIB = @OBJSQLITE_STATIC_LIB@ -OBJSQLITE_FRAMEWORK = @OBJSQLITE_FRAMEWORK@ +OBJSQLITE3_SHARED_LIB = @OBJSQLITE3_SHARED_LIB@ +OBJSQLITE3_STATIC_LIB = @OBJSQLITE3_STATIC_LIB@ +OBJSQLITE3_FRAMEWORK = @OBJSQLITE3_FRAMEWORK@ EXCEPTIONS_A = @EXCEPTIONS_A@ EXCEPTIONS_EXCEPTIONS_A = @EXCEPTIONS_EXCEPTIONS_A@ EXCEPTIONS_EXCEPTIONS_LIB_A = @EXCEPTIONS_EXCEPTIONS_LIB_A@ EXCEPTIONS_LIB_A = @EXCEPTIONS_LIB_A@ Index: src/Makefile ================================================================== --- src/Makefile +++ src/Makefile @@ -1,18 +1,18 @@ include ../extra.mk SUBDIRS = exceptions -SHARED_LIB = ${OBJSQLITE_SHARED_LIB} -STATIC_LIB = ${OBJSQLITE_STATIC_LIB} -FRAMEWORK = ${OBJSQLITE_FRAMEWORK} +SHARED_LIB = ${OBJSQLITE3_SHARED_LIB} +STATIC_LIB = ${OBJSQLITE3_STATIC_LIB} +FRAMEWORK = ${OBJSQLITE3_FRAMEWORK} LIB_MAJOR = 0 LIB_MINOR = 0 -SRCS = SLConnection.m +SRCS = SL3Connection.m INCLUDES := ${SRCS:.m=.h} \ - ObjSQLite.h + ObjSQLite3.h OBJS_EXTRA = ${EXCEPTIONS_EXCEPTIONS_A} LIB_OBJS_EXTRA = ${EXCEPTIONS_EXCEPTIONS_LIB_A} include ../buildsys.mk DELETED src/ObjSQLite.h Index: src/ObjSQLite.h ================================================================== --- src/ObjSQLite.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2020, Jonathan Schleifer - * - * https://fossil.nil.im/objsqlite - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice is present in all copies. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * 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 "SLConnection.h" ADDED src/ObjSQLite3.h Index: src/ObjSQLite3.h ================================================================== --- /dev/null +++ src/ObjSQLite3.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2020, Jonathan Schleifer + * + * https://fossil.nil.im/objsqlite3 + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice is present in all copies. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * 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" ADDED src/SL3Connection.h Index: src/SL3Connection.h ================================================================== --- /dev/null +++ src/SL3Connection.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020, Jonathan Schleifer + * + * https://fossil.nil.im/objsqlite3 + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice is present in all copies. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * 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 + +#include + +OF_ASSUME_NONNULL_BEGIN + +@interface SL3Connection: OFObject +{ + sqlite3 *_database; +} + ++ (instancetype)connectionWithPath: (OFString *)path + flags: (int)flags; +- (instancetype)initWithPath: (OFString *)path + flags: (int)flags; +@end + +OF_ASSUME_NONNULL_END ADDED src/SL3Connection.m Index: src/SL3Connection.m ================================================================== --- /dev/null +++ src/SL3Connection.m @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2020, Jonathan Schleifer + * + * https://fossil.nil.im/objsqlite3 + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice is present in all copies. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * 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; +} + +- (void)dealloc +{ + sqlite3_close(_database); + + [super dealloc]; +} +@end DELETED src/SLConnection.h Index: src/SLConnection.h ================================================================== --- src/SLConnection.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020, Jonathan Schleifer - * - * https://fossil.nil.im/objsqlite - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice is present in all copies. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * 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 - -#include - -OF_ASSUME_NONNULL_BEGIN - -@interface SLConnection: OFObject -{ - sqlite3 *_database; -} - -+ (instancetype)connectionWithPath: (OFString *)path - flags: (int)flags; -- (instancetype)initWithPath: (OFString *)path - flags: (int)flags; -@end - -OF_ASSUME_NONNULL_END DELETED src/SLConnection.m Index: src/SLConnection.m ================================================================== --- src/SLConnection.m +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2020, Jonathan Schleifer - * - * https://fossil.nil.im/objsqlite - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice is present in all copies. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * 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 "SLConnection.h" - -#import "SLException.h" - -@implementation SLConnection -+ (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 SLException subclass. */ - @throw [SLException exceptionWithConnection: nil - errorCode: errorCode]; - } @catch (id e) { - [self release]; - @throw e; - } - - return self; -} - -- (void)dealloc -{ - sqlite3_close(_database); - - [super dealloc]; -} -@end Index: src/exceptions/Makefile ================================================================== --- src/exceptions/Makefile +++ src/exceptions/Makefile @@ -1,11 +1,11 @@ include ../../extra.mk STATIC_PIC_LIB_NOINST = ${EXCEPTIONS_LIB_A} STATIC_LIB_NOINST = ${EXCEPTIONS_A} -SRCS = SLException.m +SRCS = SL3Exception.m INCLUDES = ${SRCS:.m=.h} include ../../buildsys.mk ADDED src/exceptions/SL3Exception.h Index: src/exceptions/SL3Exception.h ================================================================== --- /dev/null +++ src/exceptions/SL3Exception.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2020, Jonathan Schleifer + * + * https://fossil.nil.im/objsqlite3 + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice is present in all copies. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * 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 + +#import "SL3Connection.h" + +OF_ASSUME_NONNULL_BEGIN + +@interface SL3Exception: OFException +{ + SL3Connection *_connection; + int _errorCode; +} + +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) SL3Connection *connection; +@property (readonly, nonatomic) int errorCode; + ++ (instancetype)exceptionWithConnection: (nullable SL3Connection *)connection + errorCode: (int)errorCode; +- (instancetype)initWithConnection: (nullable SL3Connection *)connection + errorCode: (int)errorCode OF_DESIGNATED_INITIALIZER; +@end + +OF_ASSUME_NONNULL_END ADDED src/exceptions/SL3Exception.m Index: src/exceptions/SL3Exception.m ================================================================== --- /dev/null +++ src/exceptions/SL3Exception.m @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2020, Jonathan Schleifer + * + * https://fossil.nil.im/objsqlite3 + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice is present in all copies. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * 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 "SL3Exception.h" + +@implementation SL3Exception +@synthesize connection = _connection, errorCode = _errorCode; + ++ (instancetype)exceptionWithConnection: (SL3Connection *)connection + errorCode: (int)errorCode +{ + return [[[self alloc] initWithConnection: connection + errorCode: errorCode] autorelease]; +} + +- (instancetype)initWithConnection: (SL3Connection *)connection + errorCode: (int)errorCode +{ + self = [super init]; + + _connection = [connection retain]; + _errorCode = errorCode; + + return self; +} + +- (void)dealloc +{ + [_connection release]; + + [super dealloc]; +} + +- (OFString *)description +{ + return [OFString stringWithUTF8String: sqlite3_errstr(_errorCode)]; +} +@end DELETED src/exceptions/SLException.h Index: src/exceptions/SLException.h ================================================================== --- src/exceptions/SLException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2020, Jonathan Schleifer - * - * https://fossil.nil.im/objsqlite - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice is present in all copies. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * 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 - -#import "SLConnection.h" - -OF_ASSUME_NONNULL_BEGIN - -@interface SLException: OFException -{ - SLConnection *_connection; - int _errorCode; -} - -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) SLConnection *connection; -@property (readonly, nonatomic) int errorCode; - -+ (instancetype)exceptionWithConnection: (nullable SLConnection *)connection - errorCode: (int)errorCode; -- (instancetype)initWithConnection: (nullable SLConnection *)connection - errorCode: (int)errorCode OF_DESIGNATED_INITIALIZER; -@end - -OF_ASSUME_NONNULL_END DELETED src/exceptions/SLException.m Index: src/exceptions/SLException.m ================================================================== --- src/exceptions/SLException.m +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2020, Jonathan Schleifer - * - * https://fossil.nil.im/objsqlite - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice is present in all copies. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * 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 "SLException.h" - -@implementation SLException -@synthesize connection = _connection, errorCode = _errorCode; - -+ (instancetype)exceptionWithConnection: (SLConnection *)connection - errorCode: (int)errorCode -{ - return [[[self alloc] initWithConnection: connection - errorCode: errorCode] autorelease]; -} - -- (instancetype)initWithConnection: (SLConnection *)connection - errorCode: (int)errorCode -{ - self = [super init]; - - _connection = [connection retain]; - _errorCode = errorCode; - - return self; -} - -- (void)dealloc -{ - [_connection release]; - - [super dealloc]; -} - -- (OFString *)description -{ - return [OFString stringWithUTF8String: sqlite3_errstr(_errorCode)]; -} -@end