ObjFW  Artifact [f25f4f5f15]

Artifact f25f4f5f1557b32ea66b5613b0093e8d30e19c79c3ca8e85c0dd5ec9c38cdf3a:


/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import <stdlib.h>
#import <string.h>
#import "OFConstString.h"

@implementation OFConstString
+ new:(const char*)str
{
	return [[OFConstString alloc] init:str];
}

- init
{
	return [self init:NULL];
}

- init:(const char*)str
{
	if ((self = [super init])) {
		if (str == NULL) {
			length = 0;
			string = NULL;
		} else {
			length = strlen(string);
			string = str;
		}
	}
	return self;
}

- (const char*)cString
{
	return string;
}

- (size_t)length
{
	return length;
}
@end