An immutable string (collection of characters). More...
Public Member Functions | |
(BOOL) | - boolValue [implementation] |
(CPString) | - capitalizedString [implementation] |
(CPComparisonResult) | - caseInsensitiveCompare: [implementation] |
(CPString) | - characterAtIndex: [implementation] |
(CPString) | - commonPrefixWithString: [implementation] |
(CPString) | - commonPrefixWithString:options: [implementation] |
(CPComparisonResult) | - compare: [implementation] |
(CPComparisonResult) | - compare:options: [implementation] |
(CPComparisonResult) | - compare:options:range: [implementation] |
(CPArray) | - componentsSeparatedByString: [implementation] |
(CPString) | - copy [implementation] |
(CPString) | - cssString [implementation] |
(CPString) | - description [implementation] |
(double) | - doubleValue [implementation] |
(float) | - floatValue [implementation] |
(BOOL) | - hasPrefix: [implementation] |
(BOOL) | - hasSuffix: [implementation] |
(id) | - initWithFormat: [implementation] |
(id) | - initWithString: [implementation] |
(int) | - intValue [implementation] |
(BOOL) | - isEqualToString: [implementation] |
(CPString) | - lastPathComponent [implementation] |
(int) | - length [implementation] |
(CPString) | - lowercaseString [implementation] |
(JSObject) | - objectFromJSON [implementation] |
(CPArray) | - pathComponents [implementation] |
(CPString) | - pathExtension [implementation] |
(CPRange) | - rangeOfString: [implementation] |
(CPRange) | - rangeOfString:options: [implementation] |
(CPRange) | - rangeOfString:options:range: [implementation] |
(CGSize) | - sizeWithFont: [implementation] |
(CGSize) | - sizeWithFont:inWidth: [implementation] |
(CPString) | - string [implementation] |
(CPString) | - stringByAppendingFormat: [implementation] |
(CPString) | - stringByAppendingString: [implementation] |
(CPString) | - stringByDeletingLastPathComponent [implementation] |
(CPString) | - stringByEscapingRegexControlCharacters [implementation] |
(CPString) | - stringByPaddingToLength:withString:startingAtIndex: [implementation] |
(CPString) | - stringByReplacingCharactersInRange:withString: [implementation] |
(CPString) | - stringByReplacingOccurrencesOfString:withString: [implementation] |
(CPString) | - stringByReplacingOccurrencesOfString:withString:options:range: [implementation] |
(CPString) | - stringByStandardizingPath [implementation] |
(CPString) | - stringByTrimmingWhitespace [implementation] |
(CPString) | - substringFromIndex: [implementation] |
(CPString) | - substringToIndex: [implementation] |
(CPString) | - substringWithRange: [implementation] |
(unsigned) | - UID [implementation] |
(CPString) | - uppercaseString [implementation] |
Static Public Member Functions | |
(CPString) | + JSONFromObject: [implementation] |
(id) | + stringWithFormat: [implementation] |
(id) | + stringWithHash: [implementation] |
(id) | + stringWithString: [implementation] |
(CPString) | + UUID [implementation] |
An immutable string (collection of characters).
A case insensitive search
Exact character match
Start searching from the end of the string
Numbers in the string are compared as numbers instead of strings
CPString is an object that allows management of strings. Because CPString is based on the JavaScript String
object, CPStrings are immutable, although the class does have methods that create new CPStrings 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.
Definition at line 28 of file CPStringDrawing.j.
- (BOOL) boolValue | [implementation] |
Returns YES
on encountering one of "Y", "y", "T", "t", or a digit 1-9. Returns NO
otherwise. This method skips the initial whitespace characters, +,- followed by Zeroes.
Definition at line 623 of file CPString.j.
- (CPString) capitalizedString | [implementation] |
Returns a copy of the receiver with all the first letters of words capitalized.
Definition at line 581 of file CPString.j.
- (CPComparisonResult) caseInsensitiveCompare: | (CPString) | aString | [implementation] |
Definition at line 451 of file CPString.j.
- (CPString) characterAtIndex: | (unsigned) | anIndex | [implementation] |
Returns the character at the specified index.
anIndex | the index of the desired character |
Definition at line 184 of file CPString.j.
Returns a string containing characters the receiver and a given string have in common, starting from the beginning of each up to the first characters that aren't equivalent.
aString | the string with which to compare the receiver |
Definition at line 545 of file CPString.j.
Returns a string containing characters the receiver and a given string have in common, starting from the beginning of each up to the first characters that aren't equivalent.
aString | the string with which to compare the receiver | |
aMask | options for comparision |
Definition at line 556 of file CPString.j.
- (CPComparisonResult) compare: | (CPString) | aString | [implementation] |
Compares the receiver to the specified string.
aString | the string with which to compare |
Definition at line 440 of file CPString.j.
- (CPComparisonResult) compare: | (CPString) | aString | ||
options: | (int) | aMask | ||
[implementation] |
Compares the receiver to the specified string, using options.
aString | the string with which to compare | |
aMask | the options to use for the comparison |
Definition at line 462 of file CPString.j.
- (CPComparisonResult) compare: | (CPString) | aString | ||
options: | (int) | aMask | ||
range: | (CPRange) | range | ||
[implementation] |
Compares the receiver to the specified string, using options in range.
aString | the string with which to compare the range of the receiver specified by range. | |
aMask | the options to use for the comparison | |
range | the range of the receiver over which to perform the comparison. The range must not exceed the bounds of the receiver. |
Definition at line 488 of file CPString.j.
Tokenizes the receiver string using the specified delimiter. For example, if the receiver is: "arash.francisco.ross.tom"
and the delimiter is: "."
the returned array would contain:
["arash", "francisco", "ross", "tom"]
the | delimiter |
Definition at line 260 of file CPString.j.
- (CPString) copy | [implementation] |
Definition at line 707 of file CPString.j.
- (CPString) cssString | [implementation] |
Returns the string
Definition at line 33 of file CPStringDrawing.j.
- (CPString) description | [implementation] |
Returns a description of this CPString object.
Definition at line 167 of file CPString.j.
- (double) doubleValue | [implementation] |
Returns the text as a floating point value.
Definition at line 613 of file CPString.j.
- (float) floatValue | [implementation] |
Returns the text as a float point value.
Definition at line 632 of file CPString.j.
- (BOOL) hasPrefix: | (CPString) | aString | [implementation] |
Returns YES
if the receiver starts with the specified string. If aString
is empty, the method will return NO
.
Definition at line 501 of file CPString.j.
- (BOOL) hasSuffix: | (CPString) | aString | [implementation] |
Returns NO
if the receiver ends with the specified string. If aString
is empty, the method will return NO
.
Definition at line 511 of file CPString.j.
- (id) initWithFormat: | (CPString) | format | ||
, | ... | |||
[implementation] |
Initializes a string using C printf-style formatting. First argument should be a constant format string, like ' "float val = %f" ', remaining arguments should be the variables to print the values of, comma-separated.
format | the format to be used, printf-style |
Definition at line 139 of file CPString.j.
- (id) initWithString: | (CPString) | aString | [implementation] |
Initializes the string with data from the specified string.
aString | the string to copy data from |
Definition at line 129 of file CPString.j.
- (int) intValue | [implementation] |
Returns the text as an integer
Definition at line 640 of file CPString.j.
- (BOOL) isEqualToString: | (CPString) | aString | [implementation] |
Returns YES
if the specified string contains the same characters as the receiver.
Definition at line 519 of file CPString.j.
+ (CPString) JSONFromObject: | (JSObject) | anObject | [implementation] |
Returns a string representing the supplied JavaScript object encoded as JSON.
Definition at line 720 of file CPString.j.
- (CPString) lastPathComponent | [implementation] |
Returns the last component of this string. This method assumes that the string's content is a '/' separated file system path.
Definition at line 675 of file CPString.j.
- (int) length | [implementation] |
Returns the number of UTF-8 characters in the string.
Definition at line 175 of file CPString.j.
- (CPString) lowercaseString | [implementation] |
Returns a copy of the string with all its characters made lower case.
Definition at line 597 of file CPString.j.
- (JSObject) objectFromJSON | [implementation] |
Returns a JavaScript object decoded from the string's JSON representation.
Definition at line 728 of file CPString.j.
- (CPArray) pathComponents | [implementation] |
Returns an the path components of this string. This method assumes that the string's content is a '/' separated file system path.
Definition at line 650 of file CPString.j.
- (CPString) pathExtension | [implementation] |
Returns the extension of the file denoted by this string. The '.' is not a part of the extension. This method assumes that the string's contents is the path to a file or just a filename.
Definition at line 665 of file CPString.j.
- (CPRange) rangeOfString: | (CPString) | aString | [implementation] |
Finds the range of characters in the receiver where the specified string exists. If the string does not exist in the receiver, the range length
will be 0.
aString | the string to search for in the receiver |
Definition at line 303 of file CPString.j.
- (CPRange) rangeOfString: | (CPString) | aString | ||
options: | (int) | aMask | ||
[implementation] |
Finds the range of characters in the receiver where the specified string exists. The search is subject to the options specified in the specified mask which can be a combination of:
CPCaseInsensitiveSearch CPLiteralSearch CPBackwardsSearch CPAnchoredSearch CPNumericSearch
aString | the string to search for | |
aMask | the options to use in the search |
length
of the range will be 0. Definition at line 325 of file CPString.j.
- (CPRange) rangeOfString: | (CPString) | aString | ||
options: | (int) | aMask | ||
range: | (CPrange) | aRange | ||
[implementation] |
Finds the range of characters in the receiver where the specified string exists in the given range of the receiver.The search is subject to the options specified in the specified mask which can be a combination of:
CPCaseInsensitiveSearch CPLiteralSearch CPBackwardsSearch CPAnchoredSearch CPNumericSearch
aString | the string to search for | |
aMask | the options to use in the search | |
aRange | the range of the receiver in which to search for |
length
of the range will be 0. Definition at line 348 of file CPString.j.
- (CGSize) sizeWithFont: | (CPFont) | aFont | [implementation] |
Definition at line 38 of file CPStringDrawing.j.
- (CGSize) sizeWithFont: | (CPFont) | aFont | ||
inWidth: | (float) | aWidth | ||
[implementation] |
Definition at line 43 of file CPStringDrawing.j.
- (id) string | [implementation] |
Returns a string made by appending to the reciever a string constructed from a given format string and the floowing arguments
format | the format string in printf-style. |
Definition at line 197 of file CPString.j.
Creates a new CPString from the concatenation of the receiver and the specified string.
aString | the string to append to the receiver |
Definition at line 210 of file CPString.j.
- (CPString) stringByDeletingLastPathComponent | [implementation] |
Deletes the last path component of a string. This method assumes that the string's content is a '/' separated file system path.
Definition at line 686 of file CPString.j.
- (CPString) stringByEscapingRegexControlCharacters | [implementation] |
Definition at line 371 of file CPString.j.
- (CPString) stringByPaddingToLength: | (unsigned) | aLength | ||
withString: | (CPString) | aString | ||
startingAtIndex: | (unsigned) | anIndex | ||
[implementation] |
Returns a new string formed by padding characters or removing them. If the padding length is shorter than the receiver's length, the new string will be trimmed down to the padding length size. If the padding length is longer than the receiver's length, then the new string is repeatedly padded with the characters from the specified string starting at the specified index.
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) |
Definition at line 227 of file CPString.j.
- (CPString) stringByReplacingCharactersInRange: | (CPRange) | range | ||
withString: | (CPString) | replacement | ||
[implementation] |
Definition at line 420 of file CPString.j.
- (CPString) stringByReplacingOccurrencesOfString: | (CPString) | target | ||
withString: | (CPString) | replacement | ||
[implementation] |
Returns a new string in which all occurrences of a target string in the reciever are replaced by another given string.
target | The string to replace. | |
replacement | the string with which to replace the target |
Definition at line 383 of file CPString.j.
- (CPString) stringByReplacingOccurrencesOfString: | (CPString) | target | ||
withString: | (CPString) | replacement | ||
options: | (int) | options | ||
range: | (CPRange) | searchRange | ||
[implementation] |
Definition at line 397 of file CPString.j.
- (CPString) stringByStandardizingPath | [implementation] |
Definition at line 702 of file CPString.j.
- (CPString) stringByTrimmingWhitespace | [implementation] |
Returns a new string with leading and trailing whitespace trimmed
Definition at line 428 of file CPString.j.
+ (id) stringWithFormat: | (CPString) | format | ||
, | ... | |||
[implementation] |
Creates a new string using C printf-style formatting. First argument should be a constant format string, like ' "float val = %f" ', remaining arguments should be the variables to print the values of, comma-separated.
format | the format to be used, printf-style |
Definition at line 155 of file CPString.j.
+ (id) stringWithHash: | (unsigned) | aHash | [implementation] |
Returns a CPString containing the specified hash.
aHash | the hash to represent as a string |
Definition at line 103 of file CPString.j.
+ (id) stringWithString: | (CPString) | aString | [implementation] |
Returns a copy of the specified string.
aString | a non-nil string to copy |
CPInvalidArgumentException | if aString is nil |
Definition at line 115 of file CPString.j.
- (CPString) substringFromIndex: | (unsigned) | anIndex | [implementation] |
Returns a substring starting from the specified index to the end of the receiver.
anIndex | the starting string (inclusive) |
Definition at line 270 of file CPString.j.
- (CPString) substringToIndex: | (unsigned) | anIndex | [implementation] |
Creates a substring from the beginning of the receiver to the specified index.
anIndex | the last index of the receiver to use for the substring (inclusive) |
Definition at line 290 of file CPString.j.
- (CPString) substringWithRange: | (CPRange) | aRange | [implementation] |
Returns a substring starting from the specified range location
to the range length
.
the | range of the substring |
Definition at line 280 of file CPString.j.
- (unsigned) UID | [implementation] |
Returns a hash of the string instance.
Definition at line 527 of file CPString.j.
- (CPString) uppercaseString | [implementation] |
Returns a copy of the string with all its characters made upper case.
Definition at line 605 of file CPString.j.
+ (CPString) UUID | [implementation] |
Returns a randomly generated Universally Unique Identifier.
Definition at line 741 of file CPString.j.