123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- //
- // FMDatabaseAdditions.h
- // fmdb
- //
- // Created by August Mueller on 10/30/05.
- // Copyright 2005 Flying Meat Inc.. All rights reserved.
- //
-
- #import <Foundation/Foundation.h>
- #import "AWSFMDatabase.h"
-
-
- /** Category of additions for `<FMDatabase>` class.
-
- ### See also
-
- - `<FMDatabase>`
- */
-
- @interface AWSFMDatabase (AWSFMDatabaseAdditions)
-
- ///----------------------------------------
- /// @name Return results of SQL to variable
- ///----------------------------------------
-
- /** Return `int` value for query
-
- @param query The SQL query to be performed.
- @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
-
- @return `int` value.
-
- @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
- */
-
- - (int)intForQuery:(NSString*)query, ...;
-
- /** Return `long` value for query
-
- @param query The SQL query to be performed.
- @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
-
- @return `long` value.
-
- @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
- */
-
- - (long)longForQuery:(NSString*)query, ...;
-
- /** Return `BOOL` value for query
-
- @param query The SQL query to be performed.
- @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
-
- @return `BOOL` value.
-
- @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
- */
-
- - (BOOL)boolForQuery:(NSString*)query, ...;
-
- /** Return `double` value for query
-
- @param query The SQL query to be performed.
- @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
-
- @return `double` value.
-
- @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
- */
-
- - (double)doubleForQuery:(NSString*)query, ...;
-
- /** Return `NSString` value for query
-
- @param query The SQL query to be performed.
- @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
-
- @return `NSString` value.
-
- @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
- */
-
- - (NSString*)stringForQuery:(NSString*)query, ...;
-
- /** Return `NSData` value for query
-
- @param query The SQL query to be performed.
- @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
-
- @return `NSData` value.
-
- @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
- */
-
- - (NSData*)dataForQuery:(NSString*)query, ...;
-
- /** Return `NSDate` value for query
-
- @param query The SQL query to be performed.
- @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
-
- @return `NSDate` value.
-
- @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
- */
-
- - (NSDate*)dateForQuery:(NSString*)query, ...;
-
-
- // Notice that there's no dataNoCopyForQuery:.
- // That would be a bad idea, because we close out the result set, and then what
- // happens to the data that we just didn't copy? Who knows, not I.
-
-
- ///--------------------------------
- /// @name Schema related operations
- ///--------------------------------
-
- /** Does table exist in database?
-
- @param tableName The name of the table being looked for.
-
- @return `YES` if table found; `NO` if not found.
- */
-
- - (BOOL)tableExists:(NSString*)tableName;
-
- /** The schema of the database.
-
- This will be the schema for the entire database. For each entity, each row of the result set will include the following fields:
-
- - `type` - The type of entity (e.g. table, index, view, or trigger)
- - `name` - The name of the object
- - `tbl_name` - The name of the table to which the object references
- - `rootpage` - The page number of the root b-tree page for tables and indices
- - `sql` - The SQL that created the entity
-
- @return `FMResultSet` of schema; `nil` on error.
-
- @see [SQLite File Format](http://www.sqlite.org/fileformat.html)
- */
-
- - (AWSFMResultSet*)getSchema;
-
- /** The schema of the database.
-
- This will be the schema for a particular table as report by SQLite `PRAGMA`, for example:
-
- PRAGMA table_info('employees')
-
- This will report:
-
- - `cid` - The column ID number
- - `name` - The name of the column
- - `type` - The data type specified for the column
- - `notnull` - whether the field is defined as NOT NULL (i.e. values required)
- - `dflt_value` - The default value for the column
- - `pk` - Whether the field is part of the primary key of the table
-
- @param tableName The name of the table for whom the schema will be returned.
-
- @return `FMResultSet` of schema; `nil` on error.
-
- @see [table_info](http://www.sqlite.org/pragma.html#pragma_table_info)
- */
-
- - (AWSFMResultSet*)getTableSchema:(NSString*)tableName;
-
- /** Test to see if particular column exists for particular table in database
-
- @param columnName The name of the column.
-
- @param tableName The name of the table.
-
- @return `YES` if column exists in table in question; `NO` otherwise.
- */
-
- - (BOOL)columnExists:(NSString*)columnName inTableWithName:(NSString*)tableName;
-
- /** Test to see if particular column exists for particular table in database
-
- @param columnName The name of the column.
-
- @param tableName The name of the table.
-
- @return `YES` if column exists in table in question; `NO` otherwise.
-
- @see columnExists:inTableWithName:
-
- @warning Deprecated - use `<columnExists:inTableWithName:>` instead.
- */
-
- - (BOOL)columnExists:(NSString*)tableName columnName:(NSString*)columnName __attribute__ ((deprecated));
-
-
- /** Validate SQL statement
-
- This validates SQL statement by performing `sqlite3_prepare_v2`, but not returning the results, but instead immediately calling `sqlite3_finalize`.
-
- @param sql The SQL statement being validated.
-
- @param error This is a pointer to a `NSError` object that will receive the autoreleased `NSError` object if there was any error. If this is `nil`, no `NSError` result will be returned.
-
- @return `YES` if validation succeeded without incident; `NO` otherwise.
-
- */
-
- - (BOOL)validateSQL:(NSString*)sql error:(NSError**)error;
-
-
- ///-----------------------------------
- /// @name Application identifier tasks
- ///-----------------------------------
-
- /** Retrieve application ID
-
- @return The `uint32_t` numeric value of the application ID.
-
- @see setApplicationID:
- */
-
- - (uint32_t)applicationID;
-
- /** Set the application ID
-
- @param appID The `uint32_t` numeric value of the application ID.
-
- @see applicationID
- */
-
- - (void)setApplicationID:(uint32_t)appID;
-
- #if TARGET_OS_MAC && !TARGET_OS_IPHONE
- /** Retrieve application ID string
-
- @return The `NSString` value of the application ID.
-
- @see setApplicationIDString:
- */
-
-
- - (NSString*)applicationIDString;
-
- /** Set the application ID string
-
- @param string The `NSString` value of the application ID.
-
- @see applicationIDString
- */
-
- - (void)setApplicationIDString:(NSString*)string;
- #endif
-
- ///-----------------------------------
- /// @name user version identifier tasks
- ///-----------------------------------
-
- /** Retrieve user version
-
- @return The `uint32_t` numeric value of the user version.
-
- @see setUserVersion:
- */
-
- - (uint32_t)userVersion;
-
- /** Set the user-version
-
- @param version The `uint32_t` numeric value of the user version.
-
- @see userVersion
- */
-
- - (void)setUserVersion:(uint32_t)version;
-
- @end
|