2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 08:35:25 +00:00
|
|
|
#include "DictList.h"
|
|
|
|
#include "Dict.h"
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
@implementation DictList
|
|
|
|
|
|
|
|
//
|
|
|
|
// Read in variable # of objects from FILE *
|
|
|
|
//
|
|
|
|
- initListFromFile:(FILE *)fp
|
|
|
|
{
|
|
|
|
id d;
|
|
|
|
|
|
|
|
[super init];
|
|
|
|
do
|
|
|
|
{
|
|
|
|
d = [(Dict *)[Dict alloc] initFromFile:fp];
|
|
|
|
if (d != NULL)
|
|
|
|
[self addObject:d];
|
|
|
|
} while(d != NULL);
|
2010-09-11 08:35:25 +00:00
|
|
|
[d release];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Write out list file
|
|
|
|
//
|
|
|
|
- writeListFile:(char *)filename
|
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
int i;
|
|
|
|
id obj;
|
|
|
|
|
|
|
|
fp = fopen(filename,"w+t");
|
|
|
|
if (fp == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
fprintf(fp,"// Object List written by QuakeEd\n");
|
|
|
|
|
2010-09-11 08:35:25 +00:00
|
|
|
for (i = 0;i < [self count];i++)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 08:35:25 +00:00
|
|
|
obj = [self objectAtIndex:i];
|
2003-03-18 19:48:24 +00:00
|
|
|
[obj writeBlockTo:fp];
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Find the keyword in all the Dict objects
|
|
|
|
//
|
|
|
|
- (id) findDictKeyword:(char *)key
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
dict_t *d;
|
|
|
|
id dict;
|
|
|
|
|
2010-09-11 08:35:25 +00:00
|
|
|
for (i = 0;i < [self count];i++)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 08:35:25 +00:00
|
|
|
dict = [self objectAtIndex:i];
|
2003-03-18 19:48:24 +00:00
|
|
|
d = [(Dict *)dict findKeyword:key];
|
|
|
|
if (d != NULL)
|
|
|
|
return dict;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|