mirror of
https://github.com/nickshanks/ResKnife.git
synced 2025-01-02 13:30:55 +00:00
Added DBYT/CHAR and DLNG template fields.
This commit is contained in:
parent
6ac84fab82
commit
6635f26984
23
NuTemplateEditor/NuTemplateDBYTElement.h
Normal file
23
NuTemplateEditor/NuTemplateDBYTElement.h
Normal file
@ -0,0 +1,23 @@
|
||||
//
|
||||
// NuTemplateDBYTElement.h
|
||||
// ResKnife (PB2)
|
||||
//
|
||||
// Created by Uli Kusterer on Tue Aug 05 2003.
|
||||
// Copyright (c) 2003 M. Uli Kusterer. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NuTemplateElement.h"
|
||||
|
||||
|
||||
@interface NuTemplateDBYTElement : NuTemplateElement
|
||||
{
|
||||
char charValue;
|
||||
}
|
||||
|
||||
-(void) setCharValue: (char)n;
|
||||
-(char) charValue;
|
||||
|
||||
-(NSString*) stringValue;
|
||||
-(void) setStringValue: (NSString*)str;
|
||||
|
||||
@end
|
91
NuTemplateEditor/NuTemplateDBYTElement.m
Normal file
91
NuTemplateEditor/NuTemplateDBYTElement.m
Normal file
@ -0,0 +1,91 @@
|
||||
//
|
||||
// NuTemplateDBYTElement.m
|
||||
// ResKnife (PB2)
|
||||
//
|
||||
// Created by Uli Kusterer on Tue Aug 05 2003.
|
||||
// Copyright (c) 2003 M. Uli Kusterer. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NuTemplateDBYTElement.h"
|
||||
|
||||
|
||||
@implementation NuTemplateDBYTElement
|
||||
|
||||
-(id) initForType: (NSString*)t withLabel: (NSString*)l
|
||||
{
|
||||
if( self = [super initForType:t withLabel:l] )
|
||||
{
|
||||
if( [l isEqualToString: @"CHAR"] )
|
||||
charValue = ' ';
|
||||
else
|
||||
charValue = 0;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) copyWithZone: (NSZone*)zone
|
||||
{
|
||||
NuTemplateDBYTElement* el = [super copyWithZone: zone];
|
||||
|
||||
if( el )
|
||||
[el setCharValue: charValue];
|
||||
|
||||
return el;
|
||||
}
|
||||
|
||||
|
||||
-(void) readDataFrom: (NuTemplateStream*)stream
|
||||
{
|
||||
[stream readAmount:2 toBuffer: &charValue];
|
||||
}
|
||||
|
||||
|
||||
-(unsigned int) sizeOnDisk
|
||||
{
|
||||
return sizeof(charValue);
|
||||
}
|
||||
|
||||
-(void) writeDataTo: (NuTemplateStream*)stream
|
||||
{
|
||||
[stream writeAmount:sizeof(charValue) fromBuffer: &charValue];
|
||||
}
|
||||
|
||||
|
||||
-(void) setCharValue: (char)d
|
||||
{
|
||||
charValue = d;
|
||||
}
|
||||
|
||||
-(char) charValue
|
||||
{
|
||||
return charValue;
|
||||
}
|
||||
|
||||
|
||||
-(NSString*) stringValue
|
||||
{
|
||||
if( [l isEqualToString: @"CHAR"] )
|
||||
return [NSString stringWithCString:&charValue length:1];
|
||||
else
|
||||
return [NSString stringWithFormat: @"%d", charValue];
|
||||
}
|
||||
|
||||
|
||||
-(void) setStringValue: (NSString*)str
|
||||
{
|
||||
if( [l isEqualToString: @"CHAR"] )
|
||||
charValue = [str cString][0];
|
||||
else
|
||||
{
|
||||
char cstr[256];
|
||||
char* endPtr = cstr +255;
|
||||
|
||||
strncpy( cstr, [str cString], 255 );
|
||||
charValue = strtol( cstr, &endPtr, 10 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
23
NuTemplateEditor/NuTemplateDLNGElement.h
Normal file
23
NuTemplateEditor/NuTemplateDLNGElement.h
Normal file
@ -0,0 +1,23 @@
|
||||
//
|
||||
// NuTemplateDLNGlement.h
|
||||
// ResKnife (PB2)
|
||||
//
|
||||
// Created by Uli Kusterer on Tue Aug 05 2003.
|
||||
// Copyright (c) 2003 M. Uli Kusterer. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NuTemplateElement.h"
|
||||
|
||||
|
||||
@interface NuTemplateDLNGElement : NuTemplateElement
|
||||
{
|
||||
long longValue;
|
||||
}
|
||||
|
||||
-(void) setLongValue: (long)n;
|
||||
-(long) longValue;
|
||||
|
||||
-(NSString*) stringValue;
|
||||
-(void) setStringValue: (NSString*)str;
|
||||
|
||||
@end
|
78
NuTemplateEditor/NuTemplateDLNGElement.m
Normal file
78
NuTemplateEditor/NuTemplateDLNGElement.m
Normal file
@ -0,0 +1,78 @@
|
||||
//
|
||||
// NuTemplateDLNGElement.m
|
||||
// ResKnife (PB2)
|
||||
//
|
||||
// Created by Uli Kusterer on Tue Aug 05 2003.
|
||||
// Copyright (c) 2003 M. Uli Kusterer. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NuTemplateDLNGElement.h"
|
||||
|
||||
|
||||
@implementation NuTemplateDLNGElement
|
||||
|
||||
-(id) initForType: (NSString*)t withLabel: (NSString*)l
|
||||
{
|
||||
if( self = [super initForType:t withLabel:l] )
|
||||
longValue = 0;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) copyWithZone: (NSZone*)zone
|
||||
{
|
||||
NuTemplateDLNGElement* el = [super copyWithZone: zone];
|
||||
|
||||
if( el )
|
||||
[el setLongValue: longValue];
|
||||
|
||||
return el;
|
||||
}
|
||||
|
||||
|
||||
-(void) readDataFrom: (NuTemplateStream*)stream
|
||||
{
|
||||
[stream readAmount:2 toBuffer: &longValue];
|
||||
}
|
||||
|
||||
|
||||
-(unsigned int) sizeOnDisk
|
||||
{
|
||||
return sizeof(longValue);
|
||||
}
|
||||
|
||||
-(void) writeDataTo: (NuTemplateStream*)stream
|
||||
{
|
||||
[stream writeAmount:sizeof(longValue) fromBuffer: &longValue];
|
||||
}
|
||||
|
||||
|
||||
-(void) setLongValue: (long)d
|
||||
{
|
||||
longValue = d;
|
||||
}
|
||||
|
||||
-(long) longValue
|
||||
{
|
||||
return longValue;
|
||||
}
|
||||
|
||||
|
||||
-(NSString*) stringValue
|
||||
{
|
||||
return [NSString stringWithFormat: @"%ld", longValue];
|
||||
}
|
||||
|
||||
|
||||
-(void) setStringValue: (NSString*)str
|
||||
{
|
||||
char cstr[256];
|
||||
char* endPtr = cstr +255;
|
||||
|
||||
strncpy( cstr, [str cString], 255 );
|
||||
longValue = strtol( cstr, &endPtr, 10 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
@ -30,6 +30,8 @@
|
||||
#import "NuTemplateTNAMElement.h"
|
||||
#import "NuTemplatePSTRElement.h"
|
||||
#import "NuTemplateDWRDElement.h"
|
||||
#import "NuTemplateDLNGElement.h"
|
||||
#import "NuTemplateDBYTElement.h"
|
||||
#import "NuTemplateStream.h"
|
||||
|
||||
#import "NSOutlineView-SelectedItems.h"
|
||||
@ -198,6 +200,9 @@
|
||||
[fieldReg setObject: [NuTemplatePSTRElement class] forKey: @"P020"];
|
||||
[fieldReg setObject: [NuTemplatePSTRElement class] forKey: @"P040"];
|
||||
[fieldReg setObject: [NuTemplateDWRDElement class] forKey: @"DWRD"];
|
||||
[fieldReg setObject: [NuTemplateDLNGElement class] forKey: @"DLNG"];
|
||||
[fieldReg setObject: [NuTemplateDBYTElement class] forKey: @"DBYT"];
|
||||
[fieldReg setObject: [NuTemplateDBYTElement class] forKey: @"CHAR"];
|
||||
}
|
||||
|
||||
// Read new fields from the template and add them to our list:
|
||||
|
Loading…
Reference in New Issue
Block a user