Annotation of Examples/DatabaseKit/Evaluator/MultiBinder.m, revision 1.1.1.1

1.1       root        1: /*
                      2:  * MultiBinder.m
                      3:  * A Binder for fetching multiple results sets from a stored procedure.
                      4:  * You may freely copy, distribute, and reuse the code in this example.
                      5:  * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
                      6:  * fitness for any particular use.
                      7:  * Written by Jack Greenfield
                      8:  */
                      9: 
                     10: #import "MultiBinder.h"
                     11: 
                     12: @implementation MultiBinder
                     13: 
                     14: - initFromPropertyLists:(List *)propLists
                     15: {
                     16:     if ((self = [super init]) != nil)
                     17:     {
                     18:        currentResultSet = 0;
                     19:        if (propLists) propListList = [propLists copyFromZone:[self zone]];
                     20:     }
                     21: 
                     22:     return self;
                     23: }
                     24: 
                     25: - (List *)getCurrentProperties:(List *)aList
                     26: {
                     27:     return [super getProperties:aList];
                     28: }
                     29: 
                     30: - (unsigned int)currentResultSet
                     31: {
                     32:     return currentResultSet ? currentResultSet - 1 : [propListList count];
                     33: }
                     34: 
                     35: - (List *)getProperties:(List *)aList
                     36: {
                     37:     if (currentResultSet)
                     38:        if ([delegate respondsTo:@selector(binderWillChangeResultSet:)])
                     39:            [delegate binderWillChangeResultSet:self];
                     40: 
                     41:     [aList empty];
                     42:     [aList appendList:[propListList objectAt:currentResultSet]];
                     43:     [self setProperties:aList];
                     44:     currentResultSet++;
                     45:     if ([propListList count] && currentResultSet > [propListList count])
                     46:        currentResultSet = [propListList count];
                     47:     else
                     48:        if ([delegate respondsTo:@selector(binderDidChangeResultSet:)])
                     49:            [delegate binderDidChangeResultSet:self];
                     50: 
                     51:     return aList;
                     52: }
                     53: 
                     54: - free
                     55: {
                     56:     [[propListList freeObjects] free];
                     57:     return [super free];
                     58: }
                     59: 
                     60: @end
                     61: 
                     62: @implementation DBBinder (MultiBinderMethods)
                     63: 
                     64: - (List *)getCurrentProperties:(List *)aList
                     65: {
                     66:     return([self getProperties:aList]);
                     67: }
                     68: 
                     69: @end
                     70: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.