Comment: | Add documentation |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
c78968b79b683101d6f1cc6d81e8ebfe |
User & Date: | js on 2024-08-11 11:40:10 |
Other Links: | manifest | tags |
2024-08-11
| ||
11:48 | Use IRIs instead of paths check-in: 91e2a50711 user: js tags: trunk | |
11:40 | Add documentation check-in: c78968b79b user: js tags: trunk | |
08:51 | Change license to unmodified ISC check-in: 368cf0769e user: js tags: trunk | |
Added Doxyfile version [0fc2a9a064].
> > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | PROJECT_NAME = "ObjSQLite3" OUTPUT_DIRECTORY = docs/ INPUT = src src/exceptions FILE_PATTERNS = *.h *.m HTML_OUTPUT = . HAVE_DOT = NO GENERATE_LATEX = NO HIDE_UNDOC_CLASSES = YES HIDE_UNDOC_MEMBERS = YES TYPEDEF_HIDES_STRUCT = YES PREDEFINED = _Nullable= \ OF_DESIGNATED_INITIALIZER= \ OF_HAVE_BLOCKS \ OF_GENERIC(...)= \ OF_NULLABLE_PROPERTY(...)= MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = YES IGNORE_PREFIX = SL3 EXTRACT_STATIC = yes |
Modified src/SL3Connection.h from [2f11a63715] to [e3ea62406e].
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2020, 2024 Jonathan Schleifer <js@nil.im> * * https://fl.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 appear in all copies. * |
︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #include <sqlite3.h> #import "SL3PreparedStatement.h" OF_ASSUME_NONNULL_BEGIN @interface SL3Connection: OFObject { #ifdef SL3_PUBLIC_IVARS @public #endif sqlite3 *_conn; } + (instancetype)connectionWithPath: (OFString *)path; + (instancetype)connectionWithPath: (OFString *)path flags: (int)flags; - (instancetype)initWithPath: (OFString *)path; - (instancetype)initWithPath: (OFString *)path flags: (int)flags OF_DESIGNATED_INITIALIZER; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > | > > > > > > > > > > | 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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | #include <sqlite3.h> #import "SL3PreparedStatement.h" OF_ASSUME_NONNULL_BEGIN /** * @class SL3Connection SL3Connection.h ObjSQLite3/ObjSQLite3.h * * @brief A connection to a database. */ @interface SL3Connection: OFObject { #ifdef SL3_PUBLIC_IVARS @public #endif sqlite3 *_conn; } /** * @brief Creates a new connection to the database at the specified path. * * @param path The path to the database * @return A new database connection * @throw SL3OpenFailedException The database could not be opened */ + (instancetype)connectionWithPath: (OFString *)path; /** * @brief Creates a new connection to the database at the specified path. * * @param path The path to the database * @param flags The flags to open the database with * @return A new database connection * @throw SL3OpenFailedException The database could not be opened */ + (instancetype)connectionWithPath: (OFString *)path flags: (int)flags; /** * @brief Initializes an already allocated connection to connect to the * database at the specified path. * * @param path The path to the database * @return An initialized connection to the specified database * @throw SL3OpenFailedException The database could not be opened */ - (instancetype)initWithPath: (OFString *)path; /** * @brief Initializes an already allocated connection to connect to the * database at the specified path. * * @param path The path to the database * @param flags The flags to open the database with * @return An initialized connection to the specified database * @throw SL3OpenFailedException The database could not be opened */ - (instancetype)initWithPath: (OFString *)path flags: (int)flags OF_DESIGNATED_INITIALIZER; /** * @brief Prepares the specified SQL statement for the connection and returns * it. * * @param SQLStatement An SQL statement to prepare * @return A prepared statement * @throw SL3PrepareStatementFailedException The statement could not be prepared */ - (SL3PreparedStatement *)prepareStatement: (OFConstantString *)SQLStatement; /** * @brief Executes the specified statement without results. * * @param SQLStatement The SQL statement to execute * @throw SL3ExecuteStatementFailedException The statement could not be executed */ - (void)executeStatement: (OFConstantString *)SQLStatement; #ifdef OF_HAVE_BLOCKS /** * @brief Executes the specified block in an transaction. * * Before the block is executed, a transaction is started. If the block returns * true, the transaction is committed. If the block returns true or throws an * exception, the transaction is rolled back. * * @param block The block to execute in a transaction */ - (void)transactionWithBlock: (bool (^)(void))block; #endif @end OF_ASSUME_NONNULL_END |
Modified src/SL3Connection.m from [48f8ce5290] to [8fccf2b938].
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2020, 2024 Jonathan Schleifer <js@nil.im> * * https://fl.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 appear in all copies. * |
︙ | ︙ | |||
66 67 68 69 70 71 72 | - (void)dealloc { sqlite3_close(_conn); [super dealloc]; } | | | | > | | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | - (void)dealloc { sqlite3_close(_conn); [super dealloc]; } - (SL3PreparedStatement *)prepareStatement: (OFConstantString *)SQLStatement { return [[[SL3PreparedStatement alloc] sl3_initWithConnection: self SQLStatement: SQLStatement] autorelease]; } - (void)executeStatement: (OFConstantString *)SQLStatement { int code = sqlite3_exec(_conn, SQLStatement.UTF8String, NULL, NULL, NULL); if (code != SQLITE_OK) @throw [SL3ExecuteStatementFailedException exceptionWithConnection: self errorCode: code]; } |
︙ | ︙ |
Modified src/SL3PreparedStatement.h from [317568a3ca] to [6260188b5f].
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2020, 2024 Jonathan Schleifer <js@nil.im> * * https://fl.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 appear in all copies. * |
︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include <sqlite3.h> OF_ASSUME_NONNULL_BEGIN @class SL3Connection; @interface SL3PreparedStatement: OFObject { #ifdef SL3_PUBLIC_IVARS @public #endif SL3Connection *_connection; sqlite3_stmt *_stmt; } | > > > > > > > > | > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > | 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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | #include <sqlite3.h> OF_ASSUME_NONNULL_BEGIN @class SL3Connection; /** * @class SL3PreparedStatement SL3PreparedStatement.h ObjSQLite3/ObjSQLite3.h * * @brief A prepared statement. */ @interface SL3PreparedStatement: OFObject { #ifdef SL3_PUBLIC_IVARS @public #endif SL3Connection *_connection; sqlite3_stmt *_stmt; } /** * @brief The current row as an array. */ @property (readonly, nonatomic) OFArray *currentRowArray; /** * @brief The current row as a dictionary. */ @property (readonly, nonatomic) OFDictionary OF_GENERIC(OFString *, id) *currentRowDictionary; /** * @brief Binds the objects from the specified array. * * @param array An array of objects to bind * @throw OFOutOfRangeException The array has more objects than columns */ - (void)bindWithArray: (OFArray *)array; /** * @brief Binds the objects from the specified dictionary that maps each column * name to a value. * * @param dictionary A map of column names to values * @throw OFUndefinedKeyException A column name which does not exist was * specified */ - (void)bindWithDictionary: (OFDictionary OF_GENERIC(OFString *, id) *)dictionary; /** * @brief Clears all bindings. * * @throw SL3ClearBindingsFailedException The bindings could not be cleared */ - (void)clearBindings; /** * @brief Steps the prepared statement, returning the next row, if any. * * @return Whether there was another row * @throw SL3ExecuteStatementFailedException Executing the prepared statement * failed */ - (bool)step; /** * @brief Returns the object for the specified column of the current row. */ - (id)objectForCurrentRowAtColumn: (size_t)column; /** * @brief The number of columns. */ - (size_t)columnCount; /** * @brief Returns the name for the specified column. */ - (OFString *)nameForColumn: (size_t)column; /** * @brief Resets the prepared statement. * * @throw SL3ResetStatementFailedException The prepared statement could not be * reset */ - (void)reset; @end OF_ASSUME_NONNULL_END |
Modified src/SL3PreparedStatement.m from [2b5e97d424] to [ae1450d339].
︙ | ︙ | |||
168 169 170 171 172 173 174 | @throw [SL3ExecuteStatementFailedException exceptionWithStatement: self errorCode: code]; return (code == SQLITE_ROW); } | | | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | @throw [SL3ExecuteStatementFailedException exceptionWithStatement: self errorCode: code]; return (code == SQLITE_ROW); } - (id)objectForCurrentRowAtColumn: (size_t)column { if (column > INT_MAX) @throw [OFOutOfRangeException exception]; switch (sqlite3_column_type(_stmt, column)) { case SQLITE_INTEGER: return [OFNumber numberWithLongLong: |
︙ | ︙ | |||
212 213 214 215 216 217 218 | if ((name = sqlite3_column_name(_stmt, column)) == NULL) @throw [OFOutOfMemoryException exception]; return [OFString stringWithUTF8String: name]; } | | | | | | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | if ((name = sqlite3_column_name(_stmt, column)) == NULL) @throw [OFOutOfMemoryException exception]; return [OFString stringWithUTF8String: name]; } - (OFArray *)currentRowArray { size_t count = [self columnCount]; OFMutableArray *array = [OFMutableArray arrayWithCapacity: count]; for (size_t i = 0; i < count; i++) [array addObject: [self objectForCurrentRowAtColumn: i]]; [array makeImmutable]; return array; } - (OFDictionary OF_GENERIC(OFString *, id) *)currentRowDictionary { size_t count = [self columnCount]; OFMutableDictionary *dictionary = [OFMutableDictionary dictionaryWithCapacity: count]; for (size_t i = 0; i < count; i++) [dictionary setObject: [self objectForCurrentRowAtColumn: i] forKey: [self nameForColumn: i]]; [dictionary makeImmutable]; return dictionary; } |
︙ | ︙ |
Modified src/exceptions/SL3BindObjectFailedException.h from [d24a6570aa] to [d357a79354].
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2020, 2024 Jonathan Schleifer <js@nil.im> * * https://fl.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 appear in all copies. * |
︙ | ︙ | |||
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 | #import "SL3Exception.h" #import "SL3PreparedStatement.h" OF_ASSUME_NONNULL_BEGIN @interface SL3BindObjectFailedException: SL3Exception { id _object; int _column; SL3PreparedStatement *_statement; } @property (readonly, nonatomic) id object; @property (readonly, nonatomic) int column; @property (readonly, nonatomic) SL3PreparedStatement *statement; + (instancetype)exceptionWithConnection: (nullable SL3Connection *)connection errorCode: (int)errorCode OF_UNAVAILABLE; + (instancetype)exceptionWithObject: (id)object column: (int)column statement: (SL3PreparedStatement *)statement errorCode: (int)errorCode; - (instancetype)initWithConnection: (nullable SL3Connection *)connection errorCode: (int)errorCode OF_UNAVAILABLE; - (instancetype)initWithObject: (id)object column: (int)column statement: (SL3PreparedStatement *)statement errorCode: (int)errorCode OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | #import "SL3Exception.h" #import "SL3PreparedStatement.h" OF_ASSUME_NONNULL_BEGIN /** * @class SL3BindObjectFailedException SL3BindObjectFailedException.h * ObjSQLite3/ObjSQLite3.h * * @brief An exception indicating that binding an object to a prepared * statement failed. */ @interface SL3BindObjectFailedException: SL3Exception { id _object; int _column; SL3PreparedStatement *_statement; } /** * @brief The object that could not be bound to a prepared statement. */ @property (readonly, nonatomic) id object; /** * @brief The column of the prepared statement to which the object could not be * bound. */ @property (readonly, nonatomic) int column; /** * @brief The statement to which the object could not be bound. */ @property (readonly, nonatomic) SL3PreparedStatement *statement; + (instancetype)exceptionWithConnection: (nullable SL3Connection *)connection errorCode: (int)errorCode OF_UNAVAILABLE; /** * @brief Creates an new bind object failed exception. * * @param object The object that could not be bound to a prepared statement * @param column The column of the prepared statement to which the object could * not be bound * @param statement The statement to which the object could not be bound * @param errorCode The SQLite3 error code * @return A new, autoreleased bind object failed exception */ + (instancetype)exceptionWithObject: (id)object column: (int)column statement: (SL3PreparedStatement *)statement errorCode: (int)errorCode; - (instancetype)initWithConnection: (nullable SL3Connection *)connection errorCode: (int)errorCode OF_UNAVAILABLE; /** * @brief Initializes an already allocated bind object failed exception. * * @param object The object that could not be bound to a prepared statement * @param column The column of the prepared statement to which the object could * not be bound * @param statement The statement to which the object could not be bound * @param errorCode The SQLite3 error code * @return An initialized bind object failed exception */ - (instancetype)initWithObject: (id)object column: (int)column statement: (SL3PreparedStatement *)statement errorCode: (int)errorCode OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/SL3ClearBindingsFailedException.h from [65ecd7ad93] to [ef6f531da0].
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2020, 2024 Jonathan Schleifer <js@nil.im> * * https://fl.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 appear in all copies. * |
︙ | ︙ | |||
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 | #import "SL3Exception.h" #import "SL3PreparedStatement.h" OF_ASSUME_NONNULL_BEGIN @interface SL3ClearBindingsFailedException: SL3Exception { SL3PreparedStatement *_statement; } @property (readonly, nonatomic) SL3PreparedStatement *statement; + (instancetype)exceptionWithConnection: (nullable SL3Connection *)connection errorCode: (int)errorCode OF_UNAVAILABLE; + (instancetype)exceptionWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode; - (instancetype)initWithConnection: (nullable SL3Connection *)connection errorCode: (int)errorCode OF_UNAVAILABLE; - (instancetype)initWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END | > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 56 57 58 59 60 61 62 63 64 65 66 67 68 | #import "SL3Exception.h" #import "SL3PreparedStatement.h" OF_ASSUME_NONNULL_BEGIN /** * @class SL3ClearBindingsFailedException SL3ClearBindingsFailedException.h * ObjSQLite3/ObjSQLite3.h * * @brief An exception indicating that clearing a statement's bindings failed. */ @interface SL3ClearBindingsFailedException: SL3Exception { SL3PreparedStatement *_statement; } /** * @brief The statement whose bindings could not be cleared. */ @property (readonly, nonatomic) SL3PreparedStatement *statement; + (instancetype)exceptionWithConnection: (nullable SL3Connection *)connection errorCode: (int)errorCode OF_UNAVAILABLE; /** * @brief Creates a new clear bindings failed exception. * * @param statement The statement whose bindings could not be cleared * @param errorCode The SQLite3 error code * @return A new, autoreleased clear bindings failed exception */ + (instancetype)exceptionWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode; - (instancetype)initWithConnection: (nullable SL3Connection *)connection errorCode: (int)errorCode OF_UNAVAILABLE; /** * @brief Initializes an already allocated clear bindings failed exception. * * @param statement The statement whose bindings could not be cleared * @param errorCode The SQLite3 error code * @return An initialized clear bindings failed exception */ - (instancetype)initWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/SL3Exception.h from [38943d3f40] to [20362e9a91].
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2020, 2024 Jonathan Schleifer <js@nil.im> * * https://fl.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 appear in all copies. * |
︙ | ︙ | |||
18 19 20 21 22 23 24 25 26 | #import <ObjFW/ObjFW.h> #import "SL3Connection.h" OF_ASSUME_NONNULL_BEGIN @interface SL3Exception: OFException { | > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > | 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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #import <ObjFW/ObjFW.h> #import "SL3Connection.h" OF_ASSUME_NONNULL_BEGIN /** * @class SL3Exception SL3Exception.h ObjSQLite3/ObjSQLite3.h * * @brief An SQLite3 exception. */ @interface SL3Exception: OFException { SL3Connection *_Nullable _connection; int _errorCode; } /** * @brief The connection for which the exception occurred. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) SL3Connection *connection; /** * @brief The SQLite3 error code. */ @property (readonly, nonatomic) int errorCode; + (instancetype)exception OF_UNAVAILABLE; /** * @brief Creates a new SQLite3 exception. * * @param connection The connection for which the exception occurred. * @param errorCode The SQLite3 error code. * @return A new, autoreleased SQLite3 exception */ + (instancetype)exceptionWithConnection: (nullable SL3Connection *)connection errorCode: (int)errorCode; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated SQLite3 exception. * * @param connection The connection for which the exception occurred. * @param errorCode The SQLite3 error code. * @return An initialized SQLite3 exception */ - (instancetype)initWithConnection: (nullable SL3Connection *)connection errorCode: (int)errorCode OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/SL3ExecuteStatementFailedException.h from [954884630e] to [8312b607be].
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2020, 2024 Jonathan Schleifer <js@nil.im> * * https://fl.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 appear in all copies. * |
︙ | ︙ | |||
18 19 20 21 22 23 24 25 26 | #import "SL3Exception.h" #import "SL3PreparedStatement.h" OF_ASSUME_NONNULL_BEGIN @interface SL3ExecuteStatementFailedException: SL3Exception { | > > > > > > > | > > > > | > > > > > > > > > > > > > > > > | 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 56 57 58 59 60 61 62 63 64 65 | #import "SL3Exception.h" #import "SL3PreparedStatement.h" OF_ASSUME_NONNULL_BEGIN /** * @class SL3ExecuteStatementFailedException * SL3ExecuteStatementFailedException.h * ObjSQLite3/ObjSQLite3.h * * @brief An exception indicating that executing a statement failed. */ @interface SL3ExecuteStatementFailedException: SL3Exception { SL3PreparedStatement *_Nullable _statement; } /** * @brief The statement that could not be executed. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) SL3PreparedStatement *statement; /** * @brief Creates a new execute statement failed exception. * * @param statement The statement that could not be executed * @param errorCode The SQLite3 error code * @return A new, autoreleased execute statement exception failed. */ + (instancetype)exceptionWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode; /** * @brief Initializes an an already allocated execute statement failed * exception. * * @param statement The statement that could not be executed * @param errorCode The SQLite3 error code * @return An initialized execute statement exception failed. */ - (instancetype)initWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/SL3OpenFailedException.h from [a4d8e6cbd0] to [f58ebd31b2].
1 | /* | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | /* * Copyright (c) 2020, 2024 Jonathan Schleifer <js@nil.im> * * https://fl.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 appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #import "SL3Exception.h" OF_ASSUME_NONNULL_BEGIN /** * @class SL3OpenFailedException SL3OpenFailedException.h * ObjSQLite3/ObjSQLite3.h * * @brief An exception indicating that a database could not be opened. */ @interface SL3OpenFailedException: SL3Exception { OFString *_path; int _flags; } /** * @brief The path of the database that could not be opened. */ @property (readonly, nonatomic) OFString *path; /** * @brief The flags with which the database could not be opened. */ @property (readonly, nonatomic) int flags; + (instancetype)exceptionWithConnection: (nullable SL3Connection *)connection errorCode: (int)errorCode OF_UNAVAILABLE; /** * @brief Creates a new open failed exception. * * @param path The path of the database that could not be opened * @param flags The flags with which the database could not be opened * @param errorCode The SQLite3 error code * @return A new, autoreleased open failed exception */ + (instancetype)exceptionWithPath: (OFString *)path flags: (int)flags errorCode: (int)errorCode; - (instancetype)initWithConnection: (nullable SL3Connection *)connection errorCode: (int)errorCode OF_UNAVAILABLE; /** * @brief Initializes an already allocated open failed exception. * * @param path The path of the database that could not be opened * @param flags The flags with which the database could not be opened * @param errorCode The SQLite3 error code * @return An initialized open failed exception */ - (instancetype)initWithPath: (OFString *)path flags: (int)flags errorCode: (int)errorCode OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/SL3PrepareStatementFailedException.h from [04a3b10aa5] to [1fa6c9301b].
1 | /* | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | /* * Copyright (c) 2020, 2024 Jonathan Schleifer <js@nil.im> * * https://fl.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 appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #import "SL3Exception.h" OF_ASSUME_NONNULL_BEGIN /** * @class SL3PrepareStatementFailedException * SL3PrepareStatementFailedException.h * ObjSQLite3/ObjSQLite3.h * * @brief An exception indicating that preparing a statement failed. */ @interface SL3PrepareStatementFailedException: SL3Exception { OFConstantString *_SQLStatement; } /** * @brief The SQL statement which could not be prepared. */ @property (readonly, nonatomic) OFConstantString *SQLStatement; + (instancetype)exceptionWithConnection: (nullable SL3Connection *)connection errorCode: (int)errorCode OF_UNAVAILABLE; /** * @brief Creates a new prepare statement failed exception. * * @param connection The connection for which the statement could not be * prepared * @param SQLStatement The SQL statement which could not be prepared * @param errorCode The SQLite3 error code * @return A new, autoreleased prepare statement failed exception */ + (instancetype)exceptionWithConnection: (SL3Connection *)connection SQLStatement: (OFConstantString *)SQLStatement errorCode: (int)errorCode; - (instancetype)initWithConnection: (nullable SL3Connection *)connection errorCode: (int)errorCode OF_UNAVAILABLE; /** * @brief Initializes an already allocated prepare statement failed exception. * * @param connection The connection for which the statement could not be * prepared * @param SQLStatement The SQL statement which could not be prepared * @param errorCode The SQLite3 error code * @return An initialized prepare statement failed exception */ - (instancetype)initWithConnection: (SL3Connection *)connection SQLStatement: (OFConstantString *)SQLStatement errorCode: (int)errorCode OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/SL3ResetStatementFailedException.h from [59f43fd194] to [00919a8dd9].
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2020, 2024 Jonathan Schleifer <js@nil.im> * * https://fl.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 appear in all copies. * |
︙ | ︙ | |||
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 | #import "SL3Exception.h" #import "SL3PreparedStatement.h" OF_ASSUME_NONNULL_BEGIN @interface SL3ResetStatementFailedException: SL3Exception { SL3PreparedStatement *_statement; } @property (readonly, nonatomic) SL3PreparedStatement *statement; + (instancetype)exceptionWithConnection: (nullable SL3Connection *)connection errorCode: (int)errorCode OF_UNAVAILABLE; + (instancetype)exceptionWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode; - (instancetype)initWithConnection: (nullable SL3Connection *)connection errorCode: (int)errorCode OF_UNAVAILABLE; - (instancetype)initWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END | > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 56 57 58 59 60 61 62 63 64 65 66 67 68 | #import "SL3Exception.h" #import "SL3PreparedStatement.h" OF_ASSUME_NONNULL_BEGIN /** * @class SL3ResetStatementFailedException SL3ResetStatementFailedException.h * ObjSQLite3/ObjSQLite3.h * * @param An exception indicating that resetting a statement failed. */ @interface SL3ResetStatementFailedException: SL3Exception { SL3PreparedStatement *_statement; } /** * @brief The statement that could not be reset. */ @property (readonly, nonatomic) SL3PreparedStatement *statement; + (instancetype)exceptionWithConnection: (nullable SL3Connection *)connection errorCode: (int)errorCode OF_UNAVAILABLE; /** * @brief Creates a new reset statement failed exception. * * @param statement The statement that could not be reset * @param errorCode The SQLite3 error code * @return A new, autoreleased reset statement failed exception. */ + (instancetype)exceptionWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode; - (instancetype)initWithConnection: (nullable SL3Connection *)connection errorCode: (int)errorCode OF_UNAVAILABLE; /** * @brief Initializes an already allocated reset statement failed exception. * * @param statement The statement that could not be reset * @param errorCode The SQLite3 error code * @return An initialized reset statement failed exception. */ - (instancetype)initWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Modified tests/Tests.m from [3d8f1556f2] to [620287316c].
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2020, 2021, 2023, 2024 Jonathan Schleifer <js@nil.im> * * https://fl.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 appear in all copies. * |
︙ | ︙ | |||
83 84 85 86 87 88 89 | c = [OFData dataWithItems: "xyz" count: 3]; break; default: OFEnsure(0); } | | | | | | | | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | c = [OFData dataWithItems: "xyz" count: 3]; break; default: OFEnsure(0); } OFEnsure([[stmt objectForCurrentRowAtColumn: 0] isEqual: a]); OFEnsure([[stmt objectForCurrentRowAtColumn: 1] isEqual: b]); OFEnsure([[stmt objectForCurrentRowAtColumn: 2] isEqual: c]); OFEnsure([[stmt currentRowArray] isEqual: ([OFArray arrayWithObjects: a, b, c, nil])]); OFEnsure([[stmt currentRowDictionary] isEqual: ([OFDictionary dictionaryWithKeysAndObjects: @"a", a, @"b", b, @"c", c, nil])]); } [OFApplication terminate]; } @end |