/* String.m
 * Written By:  Thomas Burkholder
 *
 * You may freely copy, distribute, and reuse the code in this example.
 * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
 * fitness for any particular use.
 */

#import <String.h>
#import <ctype.h>

@implementation String

- init
{
	[super init];
	buffer = NULL;
	return self;
}

- read:(NXTypedStream *)aStream
{
	[super read:aStream];
	NXReadType(aStream,"*",&buffer);
	
	return self;
}

- write:(NXTypedStream *)aStream
{
	[super write:aStream];
	NXWriteTypes(aStream,"*",&buffer);
	
	return self;
}

- free
{
	if(buffer) NX_FREE(buffer);
	return [super free];
}

- setStringValue:(const char *)aString
{
	if (buffer) NX_FREE(buffer);
	buffer = NXCopyStringBufferFromZone(aString,[self zone]);
	return self;
}

- (const char *)stringValue
{
	return buffer;
}

@end