Because there is no SQL server behind the scenes, FlatFileChannel has to perform basic database operations itself ‚ it evaluates EOQualifiers in memory via evaluateWithObject: and sorts its results using EOF's extensions to NSArray. A normal adaptor would simply pass SQL strings generated by its EOSQLExpression subclass to a server via evaluateExpression: and process the results. Its EOAdaptorChannel subclass's deleteRowsDescribedByQualifier: might look like:
- (void)deleteRowsDescribedByQualifier:(EOQualifier *)qualifier entity:(EOEntity *)entity { EOSQLExpression *sqlExpression; NSDictionary *pkDict = nil; if (_delegateRespondsTo.willDeleteRows) { EODelegateResponse response; response = [_delegate adaptorChannel:self willDeleteRowsDescribedByQualifier:qualifier entity:entity]; if (response != EODelegateApproves) return; } sqlExpression = [[[_context adaptor] expressionClass] deleteStatementWithQualifier:qualifier entity:entity]; [self evaluateExpression:sqlExpression]; if (_cda.rpc == 0) { // check database error return code [NSException raise:EOGeneralAdaptorException format:@"%@ -- %@ 0x%x: Attempted to delete a row that is not in the database", NSStringFromSelector(_cmd), NSStringFromClass([self class]), self]; } if (_delegateRespondsTo.didDeleteRows) [_delegate adaptorChannel:self didDeleteRowsDescribedByQualifier:qualifier entity:entity]; }Despite such implementation differences, FlatFileAdaptor is structured the same way a SQL adaptor would be.
Classes
Other Components
FlatFileAdaptor Manages connection information and type mappings. FlatFileContext Maintains files' state within a transaction scope. FlatFileChannel Manipulates the NSData representations of the files. FlatFileColumn Facilitates conversion of ASCII strings to object values. FlatFileSQLExpression Provides support for creating and removing files via FlatFileChannel's evaluateExpression: which parses simple (nonñSQL) statements. Don't be fooled by the class name.
Open Issues
FlatFileDescription Adds a category on FlatFileChannel to configure an EOModel to reflect the structure of an existing database. FileScanning Contains a simple function (FFNextTokenIn) for parsing ASCII text (read: char *) into a stream of tokens. FlatFileLoginPanel Provides a simple UI for connecting to a "database," which is really just a set of files.