ObjFW  Artifact [d6fb406d96]

Artifact d6fb406d96e264a406198e821d1968ce9762251f60807240e09e1c5d2941706c:


/*
 * 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 <string.h>
#import "OFConstCString.h"

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

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

- (OFString*)clone
{
	return [OFString newWithConstCString: string];
}

- (int)compare: (OFString*)str
{
	return strcmp(string, [str cString]);
}
@end