/* vim: set syntax=objc ts=4 sw=4 expandtab : */

#import "SimpleString.h"

#include <string.h>

@implementation SimpleString

+ new: (char *) input
{
   SimpleString *temp;
   temp = [[self alloc] init];
   temp->data = input;
   return temp;
}

- (char *) cstring
{
   return data;
}

- ( int ) length
{
   return strlen( data );
}

- ( char ) at: (int) char_index
{
   if ( char_index < 0 ) return (char) 0;
   if ( char_index > [self length] ) return (char) 0;
   return data[char_index];
}

- ( void ) copyout: (int) char_count to: (char *) buffer
{
   int limit = [self length] < char_count ? [self length] : char_count;
   strncpy( data, buffer, limit );
}

@end
