blob: c8d169970f67b97df0fb1c21a0b7e56c483f56a5 [file] [log] [blame]
// This file is part of class-dump, a utility for examining the Objective-C segment of Mach-O files.
// Copyright (C) 1997-1998, 2000-2001, 2004-2006 Steve Nygard
#import "NSString-Extensions.h"
#import <Foundation/Foundation.h>
@implementation NSString (CDExtensions)
+ (NSString *)stringWithFileSystemRepresentation:(const char *)str;
{
// 2004-01-16: I'm don't understand why we need to pass in the length.
return [[NSFileManager defaultManager] stringWithFileSystemRepresentation:str length:strlen(str)];
}
+ (NSString *)spacesIndentedToLevel:(int)level;
{
return [self spacesIndentedToLevel:level spacesPerLevel:4];
}
+ (NSString *)spacesIndentedToLevel:(int)level spacesPerLevel:(int)spacesPerLevel;
{
NSString *spaces = @" ";
NSString *levelSpaces;
NSMutableString *str;
int l;
assert(spacesPerLevel <= [spaces length]);
levelSpaces = [spaces substringToIndex:spacesPerLevel];
str = [NSMutableString string];
for (l = 0; l < level; l++)
[str appendString:levelSpaces];
return str;
}
+ (NSString *)stringWithUnichar:(unichar)character;
{
return [NSString stringWithCharacters:&character length:1];
}
- (BOOL)isFirstLetterUppercase;
{
NSRange letterRange;
letterRange = [self rangeOfCharacterFromSet:[NSCharacterSet letterCharacterSet]];
if (letterRange.length == 0)
return NO;
return [[NSCharacterSet uppercaseLetterCharacterSet] characterIsMember:[self characterAtIndex:letterRange.location]];
}
@end