#import <Foundation/NSObject.h>
@class NSString, NSURL, NSNumber, NSArray, NSException;
+@class EOQualifier;
@class EOAdaptorChannel;
@class OCSFolderManager, OCSFolderType, OCSChannelManager;
- (NSString *)fetchContentWithName:(NSString *)_name;
- (NSException *)writeContent:(NSString *)_content toName:(NSString *)_name;
+- (NSArray *)fetchFields:(NSArray *)_flds matchingQualifier:(EOQualifier *)_q;
+
@end
#endif /* __OGoContentStore_OCSFolder_H__ */
userInfo:nil];
}
+- (NSString *)columnNameForFieldName:(NSString *)_fieldName {
+ return _fieldName;
+}
+
+- (NSArray *)fetchFields:(NSArray *)_flds matchingQualifier:(EOQualifier *)_q {
+ EOAdaptorChannel *channel;
+ NSException *error;
+ NSMutableString *sql;
+ NSArray *attrs;
+ NSMutableArray *results;
+ NSDictionary *row;
+
+#if 0
+ [self logWithFormat:@"FETCH: %@", _flds];
+ [self logWithFormat:@" MATCH: %@", _q];
+#endif
+
+ /* generate SQL */
+
+ sql = [NSMutableString stringWithCapacity:256];
+ [sql appendString:@"SELECT "];
+ if (_flds == nil)
+ [sql appendString:@"*"];
+ else {
+ unsigned i, count;
+
+ count = [_flds count];
+ for (i = 0; i < count; i++) {
+ if (i > 0) [sql appendString:@", "];
+ [sql appendString:[self columnNameForFieldName:[_flds objectAtIndex:i]]];
+ }
+ }
+ [sql appendString:@" FROM "];
+ [sql appendString:[self quickTableName]];
+
+ /* open channel */
+
+ if ((channel = [self acquireStoreChannel]) == nil) {
+ [self logWithFormat:@"ERROR(%s): could not open storage channel!"];
+ return nil;
+ }
+
+ /* run SQL */
+
+ if ((error = [channel evaluateExpressionX:sql]) != nil) {
+ [self logWithFormat:@"ERROR(%s): cannot execute quick-fetch SQL '%@': %@",
+ __PRETTY_FUNCTION__, sql, error];
+ [self releaseChannel:channel];
+ return nil;
+ }
+
+ /* fetch results */
+
+ results = [NSMutableArray arrayWithCapacity:64];
+ attrs = [channel describeResults];
+ while ((row = [channel fetchAttributes:attrs withZone:NULL]) != nil)
+ [results addObject:row];
+
+ /* release channels */
+
+ [self releaseChannel:channel];
+
+ return results;
+}
+
/* description */
- (NSString *)description {