CPObjectCPString
@implementation CPString : CPObject
CPString
is an object that allows management of strings. Because CPString
is
based on the JavaScript String
object, CPString
s are immutable, although the
class does have methods that create new CPString
s generated from modifications to the
receiving instance.
A handy feature of CPString
instances is that they can be used wherever a JavaScript is
required, and vice versa.
Global Variables |
---|
CPLiteralSearch = 2 |
CPCaseInsensitiveSearch = 1 |
CPAnchoredSearch = 8 |
CPBackwardsSearch = 4 |
CPNumericSearch = 64 |
Method Summary | |
---|---|
+(id) | string Returns a new string. |
+(id) | stringWithHash:(unsigned)aHash Returns a CPString containing the specified hash. |
+(id) | stringWithString:(CPString)aString Returns a copy of the specified string. |
-(id) | initWithString:(CPString)aString Initializes the string with data from the specified string. |
-(CPString) | capitalizedString Returns a copy of the receiver with all the first letters of words capitalized. |
-(CPComparisonResult) | caseInsensitiveCompare:(CPString)aString Compares the receiver to the specified string. |
-(CPString) | characterAtIndex:(unsigned)anIndex Returns the character at the specified index. |
-(CPComparisonResult) | compare:(CPString)aString options:(int)aMask Compares the receiver to the specified string, using options. |
-(CPArray) | componentsSeparatedByString:(CPString)aString Tokenizes the receiver string using the specified delimiter. |
-(CPString) | copy Makes a deep copy of the receiver. |
-(CPString) | cssString Returns the string. |
-(CPString) | description Returns a description of this CPString object. |
-(double) | doubleValue Returns the text as a floating point value. |
-(float) | floatValue Returns the text as a float point value. |
-(BOOL) | hasPrefix:(CPString)aString Returns YES if the receiver starts
with the specified string. |
-(BOOL) | hasSuffix:(CPString)aString Returns NO if the receiver ends
with the specified string. |
-(unsigned) | hash Returns a hash of the string instance. |
-(int) | intValue Returns the text as an integer. |
-(BOOL) | isEqualToString:(CPString)aString Returns YES if the specified string contains the same characters as the receiver. |
-(CPString) | lastPathComponent |
-(int) | length Returns the number of UTF-8 characters in the string. |
-(CPString) | lowercaseString Returns a copy of the string with all its characters made lower case. |
-(CPArray) | pathComponents Returns an the path components of this string. |
-(CPString) | pathExtension Returns the extension of the file denoted by this string. |
-(CPRange) | rangeOfString:(CPString)aString Finds the range of characters in the receiver where the specified string exists. |
-(CPRange) | rangeOfString:(CPString)aString options:(int)aMask Finds the range of characters in the receiver where the specified string exists. |
-(CGSize) | sizeWithFont:(CPFont)aFont |
-(CPString) | string Returns the string ( self ). |
-(CPString) | stringByAppendingString:(CPString)aString Creates a new CPString from the concatenation of the receiver and the specified string. |
-(CPString) | stringByPaddingToLength:(unsigned)aLength withString:(CPString)aString startingAtIndex:(unsigned)anIndex Returns a new string formed by padding characters or removing them. |
-(CPString) | stringByStandardizingPath |
-(CPString) | substringFromIndex:(unsigned)anIndex Returns a substring starting from the specified index to the end of the receiver. |
-(CPString) | substringToIndex:(unsigned)anIndex Creates a substring from the beginning of the receiver to the specified index. |
-(CPString) | substringWithRange:(CPRange)aRange Returns a substring starting from the specified range location to the range length . |
-(CPString) | uppercaseString Returns a copy of the string with all its characters made upper case. |
Method Detail |
---|
+(id)string
+(id)stringWithHash:(unsigned)aHash
CPString
containing the specified hash.aHash
- the hash to represent as a string+(id)stringWithString:(CPString)aString
aString
- a non-nil
string to copyCPInvalidArgumentException
- if aString
is nil
CPString
-(id)initWithString:(CPString)aString
aString
- the string to copy data fromCPString
-(CPString)capitalizedString
-(CPComparisonResult)caseInsensitiveCompare:(CPString)aString
aString
- the string with which to compare-(CPString)characterAtIndex:(unsigned)anIndex
anIndex
- the index of the desired character-(CPComparisonResult)compare:(CPString)aString options:(int)aMask
aString
- the string with which to compareaMask
- the options to use for the comparison-(CPArray)componentsSeparatedByString:(CPString)aString
"arash.francisco.ross.tom"and the delimiter is:
"."the returned array would contain:
["arash", "francisco", "ross", "tom"]
aString
-(CPString)copy
-(CPString)cssString
-(CPString)description
CPString
object.-(double)doubleValue
-(float)floatValue
-(BOOL)hasPrefix:(CPString)aString
YES
if the receiver starts
with the specified string. If aString
is empty, the method will return NO
.aString
-(BOOL)hasSuffix:(CPString)aString
NO
if the receiver ends
with the specified string. If aString
is empty, the method will return NO
.aString
-(unsigned)hash
-(int)intValue
-(BOOL)isEqualToString:(CPString)aString
YES
if the specified string contains the same characters as the receiver.aString
-(CPString)lastPathComponent
-(int)length
-(CPString)lowercaseString
-(CPArray)pathComponents
-(CPString)pathExtension
-(CPRange)rangeOfString:(CPString)aString
length
will be 0.aString
- the string to search for in the receiver-(CPRange)rangeOfString:(CPString)aString options:(int)aMask
CPCaseInsensitiveSearch CPLiteralSearch CPBackwardsSearch CPAnchoredSearch CPNumericSearch
aString
- the string to search foraMask
- the options to use in the searchlength
of the range will be 0.
-(CGSize)sizeWithFont:(CPFont)aFont
aFont
-(CPString)string
self
).-(CPString)stringByAppendingString:(CPString)aString
CPString
from the concatenation of the receiver and the specified string.aString
- the string to append to the receiver-(CPString)stringByPaddingToLength:(unsigned)aLength withString:(CPString)aString startingAtIndex:(unsigned)anIndex
aLength
- the desired length of the new CPString
aString
- the padding string to use (if necessary)anIndex
- the index of the padding string to start from (if necessary to use)-(CPString)stringByStandardizingPath
-(CPString)substringFromIndex:(unsigned)anIndex
anIndex
- the starting string (inclusive)-(CPString)substringToIndex:(unsigned)anIndex
anIndex
- the last index of the receiver to use for the substring (inclusive)-(CPString)substringWithRange:(CPRange)aRange
location
to the range length
.aRange
-(CPString)uppercaseString
Created on Sat Sep 13 14:15:43 PDT 2008