API 0.9.5
CPString Class Reference

An immutable string (collection of characters). More...

#import <CPString.h>

Inheritance diagram for CPString:

List of all members.

Instance Methods

(BOOL) - boolValue
(CPString- capitalizedString
(CPComparisonResult) - caseInsensitiveCompare:
(CPString- characterAtIndex:
(CPString- commonPrefixWithString:
(CPString- commonPrefixWithString:options:
(CPComparisonResult) - compare:
(CPComparisonResult) - compare:options:
(CPComparisonResult) - compare:options:range:
(CPArray- componentsSeparatedByCharactersInSet:
(CPArray- componentsSeparatedByString:
(CPString- cssString
(CPString- description
(double) - doubleValue
(float) - floatValue
(BOOL) - hasPrefix:
(BOOL) - hasSuffix:
(id) - initWithFormat:
(id) - initWithString:
(int) - intValue
(BOOL) - isEqual:
(BOOL) - isEqualToString:
(CPString- lastPathComponent
(int) - length
(CPString- lowercaseString
(JSObject) - objectFromJSON
(CPArray- pathComponents
(CPString- pathExtension
(CPRange) - rangeOfString:
(CPRange) - rangeOfString:options:
(CPRange) - rangeOfString:options:range:
(CGSize) - sizeWithFont:
(CGSize) - sizeWithFont:inWidth:
(CPString- string
(CPString- stringByAppendingFormat:
(CPString- stringByAppendingString:
(CPString- stringByDeletingLastPathComponent
(CPString- stringByDeletingPathExtension
(CPString- stringByEscapingRegexControlCharacters
(CPString- stringByPaddingToLength:withString:startingAtIndex:
(CPString- stringByReplacingCharactersInRange:withString:
(CPString- stringByReplacingOccurrencesOfString:withString:
(CPString- stringByReplacingOccurrencesOfString:withString:options:range:
(CPString- stringByStandardizingPath
(id) - stringByTrimmingCharactersInSet:
(CPString- stringByTrimmingWhitespace
(CPString- substringFromIndex:
(CPString- substringToIndex:
(CPString- substringWithRange:
(unsigned) - UID
(CPString- uppercaseString

Class Methods

(id) + alloc
(CPString+ JSONFromObject:
(CPDictionary+ metricsOfFont:
(id) + stringWithFormat:
(id) + stringWithHash:
(id) + stringWithString:
(CPString+ UUID

Detailed Description

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

Search ignores diacritic marks.

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 30 of file CPStringDrawing.j.


Method Documentation

+ (id) alloc

Definition at line 92 of file CPString.j.

- (BOOL) boolValue

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 679 of file CPString.j.

- (CPString) capitalizedString

Returns a copy of the receiver with all the first letters of words capitalized.

Definition at line 635 of file CPString.j.

- (CPComparisonResult) caseInsensitiveCompare: (CPString aString

Definition at line 486 of file CPString.j.

- (CPString) characterAtIndex: (unsigned)  anIndex

Returns the character at the specified index.

Parameters:
anIndexthe index of the desired character

Definition at line 200 of file CPString.j.

- (CPString) commonPrefixWithString: (CPString aString

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.

Parameters:
aStringthe string with which to compare the receiver

Definition at line 599 of file CPString.j.

- (CPString) commonPrefixWithString: (CPString aString
options: (int)  aMask 

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.

Parameters:
aStringthe string with which to compare the receiver
aMaskoptions for comparison

Definition at line 610 of file CPString.j.

- (CPComparisonResult) compare: (CPString aString

Compares the receiver to the specified string.

Parameters:
aStringthe string with which to compare
Returns:
the result of the comparison

Definition at line 476 of file CPString.j.

- (CPComparisonResult) compare: (CPString aString
options: (int)  aMask 

Compares the receiver to the specified string, using options.

Parameters:
aStringthe string with which to compare
aMaskthe options to use for the comparison
Returns:
the result of the comparison

Definition at line 497 of file CPString.j.

- (CPComparisonResult) compare: (CPString aString
options: (int)  aMask
range: (CPRange)  range 

Compares the receiver to the specified string, using options in range.

Parameters:
aStringthe string with which to compare the range of the receiver specified by range.
aMaskthe options to use for the comparison
rangethe range of the receiver over which to perform the comparison. The range must not exceed the bounds of the receiver.
Returns:
the result of the comparison

Definition at line 530 of file CPString.j.

- (CPArray) componentsSeparatedByCharactersInSet: (CPCharacterSet separator

Tokenizes the receiver string using the characters in a given set. For example, if the receiver is: "Baku baku to jest skład." and the set is [CPCharacterSet whitespaceCharacterSet] the returned array would contain:

 ["Baku", "baku", "to", "jest", "", "skład."] 

Adjacent occurrences of the separator characters produce empty strings in the result.

Author:
Arkadiusz Młynarczyk <arek@tupux.com>
Parameters:
Acharacter set containing the characters to use to split the receiver. Must not be nil.
Returns:
An CPArray object containing substrings from the receiver that have been divided by characters in separator.

Definition at line 422 of file CPCharacterSet.j.

- (CPArray) componentsSeparatedByString: (CPString aString

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"] 
Parameters:
thedelimiter
Returns:
the array of tokens

Definition at line 276 of file CPString.j.

- (CPString) cssString

Returns the string

Definition at line 43 of file CPStringDrawing.j.

- (CPString) description

Returns a description of this CPString object.

Definition at line 183 of file CPString.j.

- (double) doubleValue

Returns the text as a floating point value.

Definition at line 670 of file CPString.j.

- (float) floatValue

Returns the text as a float point value.

Definition at line 688 of file CPString.j.

- (BOOL) hasPrefix: (CPString aString

Returns YES if the receiver starts with the specified string. If aString is empty, the method will return NO.

Definition at line 543 of file CPString.j.

- (BOOL) hasSuffix: (CPString aString

Returns NO if the receiver ends with the specified string. If aString is empty, the method will return NO.

Definition at line 553 of file CPString.j.

- (id) initWithFormat: (CPString format
,   ... 

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.

Parameters:
formatthe format to be used, printf-style
Returns:
the initialized CPString

Definition at line 155 of file CPString.j.

- (id) initWithString: (CPString aString

Initializes the string with data from the specified string.

Parameters:
aStringthe string to copy data from
Returns:
the initialized CPString

Definition at line 138 of file CPString.j.

- (int) intValue

Returns the text as an integer

Definition at line 696 of file CPString.j.

- (BOOL) isEqual: (id)  anObject

Definition at line 558 of file CPString.j.

- (BOOL) isEqualToString: (CPString aString

Returns YES if the specified string contains the same characters as the receiver.

Definition at line 573 of file CPString.j.

+ (CPString) JSONFromObject: (JSObject)  anObject

Returns a string representing the supplied JavaScript object encoded as JSON.

Definition at line 789 of file CPString.j.

- (CPString) lastPathComponent

Returns the last component of this string. This method assumes that the string's content is a '/' separated file system path.

Definition at line 734 of file CPString.j.

- (int) length

Returns the number of UTF-8 characters in the string.

Definition at line 191 of file CPString.j.

- (CPString) lowercaseString

Returns a copy of the string with all its characters made lower case.

Definition at line 654 of file CPString.j.

+ (CPDictionary) metricsOfFont: (CPFont aFont

Returns a dictionary with the items "ascender", "descender", "lineHeight"

Definition at line 35 of file CPStringDrawing.j.

- (JSObject) objectFromJSON

Returns a JavaScript object decoded from the string's JSON representation.

Definition at line 797 of file CPString.j.

- (CPArray) pathComponents

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 706 of file CPString.j.

- (CPString) pathExtension

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 721 of file CPString.j.

- (CPRange) rangeOfString: (CPString aString

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.

Parameters:
aStringthe string to search for in the receiver
Returns:
the range of characters in the receiver

Definition at line 327 of file CPString.j.

- (CPRange) rangeOfString: (CPString aString
options: (int)  aMask 

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
    
Parameters:
aStringthe string to search for
aMaskthe options to use in the search
Returns:
the range of characters in the receiver. If the string was not found, the length of the range will be 0.

Definition at line 349 of file CPString.j.

- (CPRange) rangeOfString: (CPString aString
options: (int)  aMask
range: (CPrange)  aRange 

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
    
Parameters:
aStringthe string to search for
aMaskthe options to use in the search
aRangethe range of the receiver in which to search for
Returns:
the range of characters in the receiver. The range is relative to the start of the full string and not the passed-in range. If the string was not found, or if it was "", the range will be {CPNotFound, 0}.

Definition at line 373 of file CPString.j.

- (CGSize) sizeWithFont: (CPFont aFont

Definition at line 48 of file CPStringDrawing.j.

- (CGSize) sizeWithFont: (CPFont aFont
inWidth: (float)  aWidth 

Definition at line 53 of file CPStringDrawing.j.

- (id) string

Returns the string (self).

Returns a new string

Definition at line 56 of file CPTextField.j.

- (CPString) stringByAppendingFormat: (CPString format
,   ... 

Returns a string made by appending to the receiver a string constructed from a given format string and the following arguments

Parameters:
formatthe format string in printf-style.
Returns:
the initialized CPString

Definition at line 213 of file CPString.j.

- (CPString) stringByAppendingString: (CPString aString

Creates a new CPString from the concatenation of the receiver and the specified string.

Parameters:
aStringthe string to append to the receiver
Returns:
the new string

Definition at line 226 of file CPString.j.

- (CPString) stringByDeletingLastPathComponent

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 745 of file CPString.j.

- (CPString) stringByDeletingPathExtension

Deletes the extension of a string.

Definition at line 764 of file CPString.j.

- (CPString) stringByEscapingRegexControlCharacters

Definition at line 407 of file CPString.j.

- (CPString) stringByPaddingToLength: (unsigned)  aLength
withString: (CPString aString
startingAtIndex: (unsigned)  anIndex 

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.

Parameters:
aLengththe desired length of the new CPString
aStringthe padding string to use (if necessary)
anIndexthe index of the padding string to start from (if necessary to use)
Returns:
the new padded string

Definition at line 243 of file CPString.j.

- (CPString) stringByReplacingCharactersInRange: (CPRange)  range
withString: (CPString replacement 

Definition at line 456 of file CPString.j.

- (CPString) stringByReplacingOccurrencesOfString: (CPString target
withString: (CPString replacement 

Returns a new string in which all occurrences of a target string in the receiver are replaced by another given string.

Parameters:
targetThe string to replace.
replacementthe string with which to replace the target

Definition at line 419 of file CPString.j.

- (CPString) stringByReplacingOccurrencesOfString: (CPString target
withString: (CPString replacement
options: (int)  options
range: (CPRange)  searchRange 

Definition at line 433 of file CPString.j.

- (CPString) stringByStandardizingPath

Definition at line 776 of file CPString.j.

- (id) stringByTrimmingCharactersInSet: (CPCharacterSet set

Definition at line 449 of file CPCharacterSet.j.

- (CPString) stringByTrimmingWhitespace

Returns a new string with leading and trailing whitespace trimmed

Definition at line 464 of file CPString.j.

+ (id) stringWithFormat: (CPString format
,   ... 

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.

Parameters:
formatthe format to be used, printf-style
Returns:
the initialized CPString

Definition at line 171 of file CPString.j.

+ (id) stringWithHash: (unsigned)  aHash

Returns a CPString containing the specified hash.

Parameters:
aHashthe hash to represent as a string

Definition at line 112 of file CPString.j.

+ (id) stringWithString: (CPString aString

Returns a copy of the specified string.

Parameters:
aStringa non-nil string to copy
Exceptions:
CPInvalidArgumentExceptionif aString is nil
Returns:
the new CPString

Definition at line 124 of file CPString.j.

- (CPString) substringFromIndex: (unsigned)  anIndex

Returns a substring starting from the specified index to the end of the receiver.

Parameters:
anIndexthe starting string (inclusive)
Returns:
the substring

Definition at line 286 of file CPString.j.

- (CPString) substringToIndex: (unsigned)  anIndex

Creates a substring of characters from the receiver, starting at the beginning and up to the given index.

Parameters:
anIndexthe index of the receiver where the substring should end (non inclusive)
Returns:
the substring

Definition at line 311 of file CPString.j.

- (CPString) substringWithRange: (CPRange)  aRange

Returns a substring starting from the specified range location to the range length.

Parameters:
therange of the substring
Returns:
the substring

Definition at line 296 of file CPString.j.

- (unsigned) UID

Returns a hash of the string instance.

Definition at line 581 of file CPString.j.

- (CPString) uppercaseString

Returns a copy of the string with all its characters made upper case.

Definition at line 662 of file CPString.j.

+ (CPString) UUID

Returns a randomly generated Universally Unique Identifier.

Definition at line 810 of file CPString.j.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Defines