libs-base/Source/NSRange.m
Richard Frith-MacDonald 7c5fdd0f66 Make most functions inline for performance.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4030 72102866-910b-0410-8b05-ffd578937521
1999-04-05 07:07:03 +00:00

36 lines
711 B
Objective-C

/* NSRange - range functions
*/
#include <config.h>
#define IN_NSRANGE_M 1
#include <Foundation/NSException.h>
#include <Foundation/NSString.h>
#include <Foundation/NSRange.h>
@class NSString;
NSRange
NSMakeRange(unsigned int location, unsigned int length)
{
NSRange range;
unsigned int end = location + length;
if (end < location || end < length)
{
[NSException raise: NSRangeException
format: @"Range location + length too great"];
}
range.location = location;
range.length = length;
return range;
}
NSString *
NSStringFromRange(NSRange range)
{
return [NSString stringWithFormat: @"{location = %d, length = %d}",
range.location, range.length];
}