This is NSString.h in view mode; [Download] [Up]
/*
NSString.h
Copyright (C) 1995, 1996 Ovidiu Predescu and Mircea Oancea.
All rights reserved.
Author: Mircea Oancea <mircea@jupiter.elcom.pub.ro>
This file is part of libFoundation.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
We disclaim all warranties with regard to this software, including all
implied warranties of merchantability and fitness, in no event shall
we be liable for any special, indirect or consequential damages or any
damages whatsoever resulting from loss of use, data or profits, whether in
an action of contract, negligence or other tortious action, arising out of
or in connection with the use or performance of this software.
*/
#ifndef __NSString_h__
#define __NSString_h__
#include <limits.h>
#include <stdarg.h>
#include <Foundation/NSObject.h>
#include <Foundation/NSRange.h>
@class NSDictionary;
@class NSMutableDictionary;
@class NSArray;
@class NSData;
@class NSCharacterSet;
/* String limits */
#define NSMaximumStringLength (INT_MAX-1)
#define NSHashStringLength 63
/* Known encodings */
typedef unsigned NSStringEncoding;
enum {
NSASCIIStringEncoding = 1,
NSNEXTSTEPStringEncoding = 2,
NSJapaneseEUCStringEncoding = 3,
NSUTF8StringEncoding = 4,
NSISOLatin1StringEncoding = 5,
NSSymbolStringEncoding = 6,
NSNonLossyASCIIStringEncoding = 7,
NSShiftJISStringEncoding = 8,
NSISOLatin2StringEncoding = 9,
NSUnicodeStringEncoding = 10,
NSAdobeStandardCyrillicStringEncoding = 11,
NSWinLatin1StringEncoding = 12,
};
/*
* Flags passed to compare & rangeOf...: With a zero mask passed in,
* the searches are case sensitive, from the beginning, are non-anchored,
* and take Unicode floating diacritics and other non-visible characters into
* account.
*/
enum {
NSCaseInsensitiveSearch = 1,
NSLiteralSearch = 2, /* Character-by-character search */
NSBackwardsSearch = 4, /* Search backwards in the range */
NSAnchoredSearch = 8 /* Search anchored within specified range */
};
/* Unicode character is 16bit wide (assumes short is 16bit wide in gcc) */
typedef unsigned short unichar;
/*
* NSString
*
* primitive methods:
* - characterAtIndex:
* - length:
* - init* as appropriate
*/
@interface NSString : NSObject <NSCoding, NSCopying, NSMutableCopying>
/* Getting a string's length */
- (unsigned int)length;
/* Accessing characters */
- (unichar)characterAtIndex:(unsigned int)index;
- (void)getCharacters:(unichar*)buffer;
- (void)getCharacters:(unichar*)buffer range:(NSRange)aRange;
/* Combining strings */
- (NSString*)stringByAppendingString:(NSString*)aString;
- (NSString*)stringByAppendingFormat:(NSString*)format,...;
- (NSString*)stringByAppendingFormat:(NSString*)format
arguments:(va_list)argList;
- (NSString*)stringByPrependingString:(NSString*)aString;
- (NSString*)stringByPrependingFormat:(NSString*)format,...;
- (NSString*)stringByPrependingFormat:(NSString*)format
arguments:(va_list)argList;
/* Dividing strings */
- (NSArray*)componentsSeparatedByString:(NSString*)separator;
- (NSString*)substringFromIndex:(unsigned int)index;
- (NSString*)substringWithRange:(NSRange)aRange;
- (NSString*)substringToIndex:(unsigned int)index;
/* Finding characters and substrings */
- (NSRange)rangeOfCharacterFromSet:(NSCharacterSet*)aSet;
- (NSRange)rangeOfCharacterFromSet:(NSCharacterSet*)aSet
options:(unsigned int)mask;
- (NSRange)rangeOfCharacterFromSet:(NSCharacterSet*)aSet
options:(unsigned int)mask range:(NSRange)aRange;
- (NSRange)rangeOfString:(NSString*)string;
- (NSRange)rangeOfString:(NSString*)string options:(unsigned int)mask;
- (NSRange)rangeOfString:(NSString*)aString
options:(unsigned int)mask range:(NSRange)aRange;
- (unsigned int)indexOfString:(NSString*)substring;
- (unsigned int)indexOfString:(NSString*)substring fromIndex:(unsigned)index;
- (unsigned int)indexOfString:(NSString*)substring range:(NSRange)aRange;
/* Determining composed character sequences */
- (NSRange)rangeOfComposedCharacterSequenceAtIndex:(unsigned int)anIndex;
/* Converting string contents into a property list */
- propertyList;
- (NSMutableDictionary*)propertyListFromStringsFileFormat;
/* Identifying and comparing strings */
- (NSComparisonResult)caseInsensitiveCompare:(NSString*)aString;
- (NSComparisonResult)compare:(id)aString;
- (NSComparisonResult)compare:(NSString*)aString options:(unsigned int)mask;
- (NSComparisonResult)compare:(NSString*)aString
options:(unsigned int)mask range:(NSRange)aRange;
- (BOOL)hasPrefix:(NSString*)aString;
- (BOOL)hasSuffix:(NSString*)aString;
- (BOOL)isEqual:(id)anObject;
- (BOOL)isEqualToString:(NSString*)aString;
- (unsigned int)hash;
/* Getting a shared prefix */
- (NSString*)commonPrefixWithString:(NSString*)aString
options:(unsigned int)mask;
/* Changing case */
- (NSString*)capitalizedString;
- (NSString*)lowercaseString;
- (NSString*)uppercaseString;
/* Getting C strings */
- (const char*)cString;
- (unsigned int)cStringLength;
- (void)getCString:(char*)buffer;
- (void)getCString:(char*)buffer maxLength:(unsigned int)maxLength;
- (void)getCString:(char*)buffer maxLength:(unsigned int)maxLength
range:(NSRange)aRange remainingRange:(NSRange*)leftoverRange;
/* Getting numeric values */
- (double)doubleValue;
- (float)floatValue;
- (int)intValue;
/* Working with encodings */
+ (NSStringEncoding*)availableStringEncodings;
+ (NSStringEncoding)defaultCStringEncoding;
+ (NSString*)localizedNameOfStringEncoding:(NSStringEncoding)encoding;
- (BOOL)canBeConvertedToEncoding:(NSStringEncoding)encoding;
- (NSData*)dataUsingEncoding:(NSStringEncoding)encoding;
- (NSData*)dataUsingEncoding:(NSStringEncoding)encoding
allowLossyConversion:(BOOL)flag;
- (NSStringEncoding)fastestEncoding;
- (NSStringEncoding)smallestEncoding;
- (BOOL)getBytes:(void*)bytes maxLength:(unsigned int)maxLength
inEncoding:(NSStringEncoding)encoding
allowLossesInConversion:(BOOL)allowLossesInConversion
fromRange:(NSRange)fromRange
usedRange:(NSRange*)usedRange
remainingRange:(NSRange*)remainingRange;
/* Writing to a file */
- (BOOL)writeToFile:(NSString *)path atomically:(BOOL)flag;
@end
@interface NSString(NSStringCreation)
+ (id)localizedStringWithFormat:(NSString*)format,...;
+ (id)stringWithCharacters:(const unichar*)chars
length:(unsigned int)length;
+ (id)stringWithCharactersNoCopy:(unichar*)chars
length:(unsigned int)length freeWhenDone:(BOOL)flag;
+ (id)stringWithCString:(const char*)byteString;
+ (NSString*)stringWithCString:(const char*)byteString
length:(unsigned int)length;
+ (id)stringWithCStringNoCopy:(char*)byteString
freeWhenDone:(BOOL)flag;
+ (NSString*)stringWithCStringNoCopy:(char*)byteString
length:(unsigned int)length freeWhenDone:(BOOL)flag;
+ (id)stringWithFormat:(NSString*)format,...;
+ (id)stringWithFormat:(NSString*)format arguments:(va_list)argList;
+ (id)stringWithContentsOfFile:(NSString*)path;
@end
@interface NSString(NSStringInitialization)
- init;
- initWithCharacters:(const unichar*)chars length:(unsigned int)length;
- initWithCharactersNoCopy:(unichar*)chars length:(unsigned int)length
freeWhenDone:(BOOL)flag;
- initWithCString:(const char*)byteString;
- initWithCString:(const char*)byteString length:(unsigned int)length;
- initWithCStringNoCopy:(char*)byteString freeWhenDone:(BOOL)flag;
- initWithCStringNoCopy:(char*)byteString length:(unsigned int)length
freeWhenDone:(BOOL)flag;
- initWithString:(NSString*)aString;
- initWithFormat:(NSString*)format, ...;
- initWithFormat:(NSString*)format arguments:(va_list)argList;
- initWithFormat:(NSString*)format
locale:(NSDictionary*)dictionary, ...;
- initWithFormat:(NSString*)format
locale:(NSDictionary*)dictionary arguments:(va_list)argList;
- initWithData:(NSData*)data encoding:(NSStringEncoding)encoding;
- initWithContentsOfFile:(NSString*)path;
@end
/*
* NSMutableString
*
* primitive methods:
* - characterAtIndex:
* - length:
* - replaceCharactersInRange:withString:
* - init* as appropriate
*/
@interface NSMutableString : NSString
/* Modifying a string */
- (void)replaceCharactersInRange:(NSRange)aRange
withString:(NSString*)aString;
- (void)appendFormat:(NSString*)format,...;
- (void)appendFormat:(NSString*)format arguments:(va_list)argList;
- (void)appendString:(NSString*)aString;
- (void)prependFormat:(NSString*)format,...;
- (void)prependFormat:(NSString*)format arguments:(va_list)argList;
- (void)prependString:(NSString*)aString;
- (void)deleteCharactersInRange:(NSRange)range;
- (void)insertString:(NSString*)aString atIndex:(unsigned)index;
- (void)setString:(NSString*)aString;
@end
@interface NSMutableString(NSStringCreation)
+ (id)stringWithCapacity:(unsigned int)capacity;
@end
@interface NSMutableString(NSStringInitialization)
- initWithCapacity:(unsigned int)capacity;
@end
/* Errors & exceptions for strings */
extern NSString* NSStringBoundsError;
/*
* Include header for concrete subclasses for debug info
*/
#include <Foundation/NSConcreteString.h>
#include <Foundation/NSPathUtilities.h>
#endif /* __NSString_h__ */
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.