2003-08-06 17:40:46 +00:00
|
|
|
//
|
|
|
|
// NuTemplateGroupElement.m
|
|
|
|
// ResKnife (PB2)
|
|
|
|
//
|
|
|
|
// Created by Uli Kusterer on Tue Aug 05 2003.
|
|
|
|
// Copyright (c) 2003 M. Uli Kusterer. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "NuTemplateGroupElement.h"
|
|
|
|
|
|
|
|
|
|
|
|
@implementation NuTemplateGroupElement
|
|
|
|
|
|
|
|
-(id) initForType: (NSString*)t withLabel: (NSString*)l
|
|
|
|
{
|
|
|
|
if( self = [super initForType:t withLabel:l] )
|
|
|
|
subElements = [[NSMutableArray alloc] init];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void) dealloc
|
|
|
|
{
|
|
|
|
[subElements release];
|
|
|
|
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(id) copyWithZone: (NSZone*)zone
|
|
|
|
{
|
|
|
|
NuTemplateGroupElement* el = [super copyWithZone: zone];
|
2003-08-07 19:42:25 +00:00
|
|
|
|
2003-08-06 17:40:46 +00:00
|
|
|
if( el )
|
|
|
|
{
|
2003-08-07 19:42:25 +00:00
|
|
|
NSMutableArray* arr = [[subElements mutableCopy] autorelease];
|
|
|
|
NSEnumerator* enny = [arr objectEnumerator];
|
|
|
|
NSObject* obj;
|
|
|
|
unsigned x = 0;
|
|
|
|
|
|
|
|
while( obj = [enny nextObject] )
|
|
|
|
{
|
|
|
|
[arr replaceObjectAtIndex:x withObject: [[obj copy] autorelease]];
|
|
|
|
x++;
|
|
|
|
}
|
|
|
|
|
2003-08-06 17:40:46 +00:00
|
|
|
[el setSubElements: arr];
|
|
|
|
}
|
|
|
|
|
|
|
|
return el;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-(void) setSubElements: (NSMutableArray*)a
|
|
|
|
{
|
|
|
|
[a retain];
|
|
|
|
[subElements release];
|
|
|
|
subElements = a;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(NSMutableArray*) subElements
|
|
|
|
{
|
|
|
|
return subElements;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(int) subElementCount
|
|
|
|
{
|
|
|
|
return [subElements count];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(NuTemplateElement*) subElementAtIndex: (int)n
|
|
|
|
{
|
|
|
|
return [subElements objectAtIndex: n];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void) readSubElementsFrom: (NuTemplateStream*)stream
|
|
|
|
{
|
|
|
|
NSLog(@"Code for reading this object's sub-elements is missing.");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Before writeDataTo: is called, this is called to calculate the final resource size:
|
|
|
|
// This returns the sizes of all our sub-elements. If you subclass, add to that the size
|
|
|
|
// of this element itself.
|
|
|
|
-(unsigned int) sizeOnDisk
|
|
|
|
{
|
|
|
|
unsigned int theSize = 0;
|
|
|
|
NSEnumerator* enny = [subElements objectEnumerator];
|
|
|
|
NuTemplateElement* obj;
|
|
|
|
|
|
|
|
while( obj = [enny nextObject] )
|
|
|
|
theSize += [obj sizeOnDisk];
|
|
|
|
|
|
|
|
return theSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Writes out the data of all our sub-elements here:
|
|
|
|
-(void) writeDataTo: (NuTemplateStream*)stream
|
|
|
|
{
|
|
|
|
NSEnumerator* enny = [subElements objectEnumerator];
|
|
|
|
NuTemplateElement* obj;
|
|
|
|
|
|
|
|
while( obj = [enny nextObject] )
|
|
|
|
[obj writeDataTo: stream];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@end
|