home *** CD-ROM | disk | FTP | other *** search
- /*
- ODBCAdaptor.h
- Copyright (c) 1996, NeXT Software, Inc.
- All rights reserved.
- */
-
- #import <EOAccess/EOAccess.h>
-
- //
- // These strings define the standard connection information in the
- // connection dictionary for an ODBC logon.
- //
- #define dataSourceKey @"dataSource"
- #define userNameKey @"userName"
- #define passwordKey @"password"
- // The string returned by -odbcConnectionString looks like:
- // "DSN=<dataSource>;UID=<userName>;PWD=<password>"
-
- #define connectionStringKey @"connectionString"
- // If this string is present in the connection dictionary, the others
- // logon keys are ignored and this string is returned as is from the
- // -odbcConnectionString method.
-
-
- @interface ODBCAdaptor:EOAdaptor
-
- // Overiding the superclass
- //
- - (EOAdaptorContext *)createAdaptorContext;
- // Returns a new EOAdaptorContext, or nil if a new context cannot be
- // created. EOAdaptors by default have no contexts at all. The newly
- // created context retains its adaptor.
-
- - (Class)defaultExpressionClass;
- // This method should never be invoked by the programmer. It is implemented
- // by the adaptor subclass and invoked by the framework when determining
- // which sqlExpression class should be used.
-
- - (BOOL)isValidQualifierType:(NSString *)typeName model:(EOModel *)model;
- // Returns YES if an attribute of type typeName can be used in a
- // qualifier, otherwise returns NO. typeName is the external type.
-
- - (void)assertConnectionDictionaryIsValid;
- // Raises an exception if any error occurs. An actual connection is made
- // to check the connection dictionary.
-
- // ODBC Specific
- //
- - (NSString *)odbcConnectionString;
- // The string used to connect to the database.
-
- - (void *)odbcEnvironment;
- // ODBC HENV. It's returned as a (void *) to avoid including any ODBC
- // headers.
-
- @end
-
-
- //
- // Since different ODBC driver could handle different types, and to
- // avoid costly connection to the driver and/or the database, the type
- // information is cached in the connection dictionary. The typeInfo
- // dictionary contains the following information for every type
- // in your database:
- //
- // - <typeName> = {
- // defaultODBCType = (<CHAR/TIMESTAMP/BIT/...>, ...);
- // precision = <precision>;
- // minScale = <minScale>;
- // maxScale = <maxScale>;
- // isUnsigned = <YES/NO>;
- // isNullable = <YES/NO>;
- // isSearchable = <YES/NO>;
- // createParams = <0/1/2>;
- // }
- //
- // Some of the keys could be ommited. A missing boolean is NO, a missing int
- // is 0. defaultODBCType is mandatory.
- //
- //
- #define typeInfoKey @"typeInfo"
-
- //
- // Also, some important aspects regarding the driver are also cached in the
- // connection dictionary under the key driverInfo. This dictionary contains
- // the driver name, version, and some other stuff.
- //
- #define driverInfoKey @"driverInfo"
-
- @interface ODBCAdaptor(ODBCInfoAccessors)
- + (NSDictionary *)getOdbcInfoWithConnectionDictionary:(NSDictionary *)connectionDictionary;
- // Setup the typeInfo and the driverInfo dictionaries and
- // return an updated connection dictionary. This method
- // is creating an adaptor, a context and a channel and is
- // connecting to the database to get the information.
-
- + (NSDictionary *)resetOdbcInfoWithConnectionDictionary:(NSDictionary *)connectionDictionary;
- // Reset both caches.
-
- + (NSDictionary *)typeInfoForModel:(EOModel *)model;
- + (NSDictionary *)driverInfoForModel:(EOModel *)model;
- // These method are used for convenient access to the type and driver information
- // cached in the connection dictionary of the model. Calling these methods could create
- // a connection to the database to get the information.
-
- - (NSDictionary *)typeInfo;
- - (NSDictionary *)driverInfo;
- // Access the information located inside the adaptor's connection dictionary.
- // Calling these methods could create a connection to the database to get the information.
- @end
-
- //
- // The following conventions are used:
- //
- // - internal type: the ObjectiveC class allocated for an attribute.
- // - odbcType: The ODBC generic type used
- // - externalType: the database dependent type
- //
- // With the Access ODBC driver for example, we have the following
- // configuration:
- //
- // ExternalType odbcType internalType
- // TEXT SQL_VARCHAR NSString
- // CURRENCY SQL_NUMERIC NSDecimalNumber
- // BINARY SQL_BINARY NSData
- // DATETIME SQL_TIMESTAMP NSCalendarDate
- // ... etc...
- //
- @interface ODBCAdaptor(ODBCTypeMapping)
-
- + (NSArray *)externalTypesWithModel:(EOModel *)model;
- // Extract all the keys from the type info dictionary.
- // Used by EOModeler to display the type popup
-
- + (NSString *)stringRepresentationForOdbcType:(int)type;
- + (int)odbcTypeForStringRepresentation:(NSString *)type;
- // Translate SQL_CHAR to @"CHAR" and vice-versa. Used to
- // encode ODBC types in the type info dictionary.
-
- + (NSString *)odbcTypeForExternalType:(NSString *)extType model:(EOModel *)model;
-
- + (NSString *)internalTypeForExternalType:(NSString *)extType model:(EOModel *)model;
- // return a default ObjectiveC class for an external type. This method
- // use the typeInfo dictionary to extract the default ODBC type, and
- // provide a class based on this information.
-
- + (NSString *)externalTypeForOdbcType:(int)type model:(EOModel *)model;
- // Return the closest external type for an ODBC type.
-
- + (void)assignExternalInfoForAttribute:(EOAttribute *)attribute;
- // This method is setting the external information on an attribute
- // based on the internal type, precision and width.
-
- @end
-