2008-07-31 21:31:19 +00:00
|
|
|
#import "ElementDLLG.h"
|
|
|
|
|
2010-08-30 23:38:46 +00:00
|
|
|
#define SIZE_ON_DISK (8)
|
|
|
|
|
2008-07-31 21:31:19 +00:00
|
|
|
@implementation ElementDLLG
|
|
|
|
|
|
|
|
- (id)copyWithZone:(NSZone*)zone
|
|
|
|
{
|
|
|
|
ElementDLLG *element = [super copyWithZone:zone];
|
|
|
|
[element setValue:value];
|
|
|
|
return element;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)readDataFrom:(TemplateStream *)stream
|
|
|
|
{
|
2010-08-30 23:38:46 +00:00
|
|
|
SInt64 tmp;
|
|
|
|
[stream readAmount:SIZE_ON_DISK toBuffer:&tmp];
|
|
|
|
value = CFSwapInt64BigToHost(tmp);
|
2008-07-31 21:31:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (unsigned int)sizeOnDisk
|
|
|
|
{
|
2010-08-30 23:38:46 +00:00
|
|
|
return SIZE_ON_DISK;
|
2008-07-31 21:31:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)writeDataTo:(TemplateStream *)stream
|
|
|
|
{
|
2010-08-30 23:38:46 +00:00
|
|
|
SInt64 tmp = CFSwapInt64HostToBig(value);
|
|
|
|
[stream writeAmount:SIZE_ON_DISK fromBuffer:&tmp];
|
2008-07-31 21:31:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setValue:(SInt64)v
|
|
|
|
{
|
|
|
|
value = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (SInt64)value
|
|
|
|
{
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)stringValue
|
|
|
|
{
|
|
|
|
return [NSString stringWithFormat:@"%lld", value];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setStringValue:(NSString *)str
|
|
|
|
{
|
|
|
|
char cstr[256];
|
|
|
|
char *endPtr = cstr + 255;
|
2012-07-04 22:13:25 +00:00
|
|
|
strncpy(cstr, [str cStringUsingEncoding:NSMacOSRomanStringEncoding], 255);
|
2008-07-31 21:31:19 +00:00
|
|
|
value = strtoll(cstr, &endPtr, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|