API  0.9.6
 All Classes Files Functions Variables Macros Modules Pages
CPString Class Reference

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

#import <CPString.h>

+ Inheritance diagram for CPString:

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- stringByAppendingFormat:
 
(CPString- stringByAppendingPathComponent:
 
(CPString- stringByAppendingPathExtension:
 
(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
 
- Instance Methods inherited from CPObject
(void) - addObserver:forKeyPath:options:context:
 
(void) - applyChange:toKeyPath:
 
(id) - autorelease
 
(id) - awakeAfterUsingCoder:
 
(void) - awakeFromCib
 
(void) - bind:toObject:withKeyPath:options:
 
(Class) - classForCoder
 
(Class) - classForKeyedArchiver
 
(CPString- className
 
(id) - copy
 
(void) - dealloc
 
(CPDictionary- dictionaryWithValuesForKeys:
 
(void) - didChange:valuesAtIndexes:forKey:
 
(void) - didChangeValueForKey:
 
(void) - didChangeValueForKey:withSetMutation:usingObjects:
 
(void) - doesNotRecognizeSelector:
 
(CPArray- exposedBindings
 
(id) - forwardingTargetForSelector:
 
(void) - forwardInvocation:
 
(unsigned) - hash
 
(BOOL) - implementsSelector:
 
(CPDictionary- infoForBinding:
 
(id) - init
 
(BOOL) - isKindOfClass:
 
(BOOL) - isMemberOfClass:
 
(BOOL) - isProxy
 
(IMP) - methodForSelector:
 
(CPMethodSignature) - methodSignatureForSelector:
 
(id) - mutableArrayValueForKey:
 
(id) - mutableArrayValueForKeyPath:
 
(id) - mutableCopy
 
(id) - mutableSetValueForKey:
 
(id) - mutableSetValueForKeyPath:
 
(id) - performSelector:
 
(id) - performSelector:withObject:
 
(id) - performSelector:withObject:withObject:
 
(id) - performSelector:withObjects:
 
(void) - release
 
(void) - removeObserver:forKeyPath:
 
(id) - replacementObjectForArchiver:
 
(id) - replacementObjectForCoder:
 
(id) - replacementObjectForKeyedArchiver:
 
(BOOL) - respondsToSelector:
 
(id) - retain
 
(id) - self
 
(void) - setValue:forKey:
 
(void) - setValue:forKeyPath:
 
(void) - setValue:forUndefinedKey:
 
(void) - setValuesForKeysWithDictionary:
 
(void) - unbind:
 
(Class) - valueClassForBinding:
 
(id) - valueForKey:
 
(id) - valueForKeyPath:
 
(id) - valueForUndefinedKey:
 
(void) - willChange:valuesAtIndexes:forKey:
 
(void) - willChangeValueForKey:
 
(void) - willChangeValueForKey:withSetMutation:usingObjects:
 

Class Methods

(id) + alloc
 
(CPString+ JSONFromObject:
 
(CPDictionary+ metricsOfFont:
 
(CPString+ pathWithComponents:
 
(id) + string
 
(id) + stringWithFormat:
 
(id) + stringWithHash:
 
(id) + stringWithString:
 
(CPString+ UUID
 
- Class Methods inherited from CPObject
(BOOL) + accessInstanceVariablesDirectly
 
(id) + allocWithCoder:
 
(BOOL) + automaticallyNotifiesObserversForKey:
 
(Class) + class
 
(void) + exposeBinding:
 
(void) + initialize
 
(IMP) + instanceMethodForSelector:
 
(BOOL) + instancesRespondToSelector:
 
(BOOL) + isSubclassOfClass:
 
(CPSet+ keyPathsForValuesAffectingValueForKey:
 
(void) + load
 
(id) + new
 
(void) + setVersion:
 
(Class) + superclass
 
(int) + version
 

Additional Inherited Members

- Instance Variables inherited from CPObject
Class isa
 

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 2 of file CPString.h.

Method Documentation

+ (id) alloc
implementation

Allocates a new instance of the receiving class

Reimplemented from CPObject.

Definition at line 92 of file CPString.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 679 of file CPString.j.

- (CPString) capitalizedString
implementation

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
implementation

Definition at line 486 of file CPString.j.

- (CPString) characterAtIndex: (unsigned)  anIndex
implementation

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
implementation

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 
implementation

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
implementation

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 
implementation

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 
implementation

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
implementation

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@.nosp@m.tupu.nosp@m.x.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.

Provided by category CPString(CPCharacterSetAdditions).

Definition at line 422 of file CPCharacterSet.j.

- (CPArray) componentsSeparatedByString: (CPString aString
implementation

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
implementation

Returns the string

Provided by category CPString(CPStringDrawing).

Definition at line 43 of file CPStringDrawing.j.

- (CPString) description
implementation

Returns a description of this CPString object.

Reimplemented from CPObject.

Definition at line 183 of file CPString.j.

- (double) doubleValue
implementation

Returns the text as a floating point value.

Definition at line 670 of file CPString.j.

- (float) floatValue
implementation

Returns the text as a float point value.

Definition at line 688 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 543 of file CPString.j.

- (BOOL) hasSuffix: (CPString aString
implementation

Returns YES 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
,   ... 
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.

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

Definition at line 155 of file CPString.j.

- (id) initWithString: (CPString aString
implementation

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
implementation

Returns the text as an integer

Definition at line 696 of file CPString.j.

- (BOOL) isEqual: (id)  anObject
implementation

Determines if anObject is functionally equivalent to the receiver.

Returns
YES if anObject is functionally equivalent to the receiver.

Reimplemented from CPObject.

Definition at line 558 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 573 of file CPString.j.

+ (CPString) JSONFromObject: (JSObject)  anObject
implementation

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

Provided by category CPString(JSON).

Definition at line 899 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 797 of file CPString.j.

- (int) length
implementation

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

Definition at line 191 of file CPString.j.

- (CPString) lowercaseString
implementation

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
implementation

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

Provided by category CPString(CPStringDrawing).

Definition at line 35 of file CPStringDrawing.j.

- (JSObject) objectFromJSON
implementation

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

Provided by category CPString(JSON).

Definition at line 907 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. Multiple '/' separators between components are truncated to a single one.

Definition at line 707 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 784 of file CPString.j.

+ (CPString) pathWithComponents: (CPArray components
implementation

Returns a string built from the strings in a given array by concatenating them with a path separator between each pair. This method assumes that the string's content is a '/' separated file system path. Multiple '/' separators between components are truncated to a single one.

Definition at line 744 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.

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 
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
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 
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
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
implementation

Provided by category CPString(CPStringDrawing).

Definition at line 48 of file CPStringDrawing.j.

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

Provided by category CPString(CPStringDrawing).

Definition at line 53 of file CPStringDrawing.j.

+ (id) string
implementation

Returns a new string

Provided by category CPString(CPTextFieldAdditions).

Definition at line 103 of file CPString.j.

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

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) stringByAppendingPathComponent: (CPString aString
implementation

Returns a new string made by appending to the receiver a given string This method assumes that the string's content is a '/' separated file system path. Multiple '/' separators between components are truncated to a single one.

Definition at line 812 of file CPString.j.

- (CPString) stringByAppendingPathExtension: (CPString ext
implementation

Returns a new string made by appending to the receiver an extension separator followed by a given extension This method assumes that the extension separator is a '.' Extension can't include a '/' character, receiver can't be empty or be just a '/'. If so the result will be the receiver itself. Multiple '/' separators between components are truncated to a single one.

Definition at line 827 of file CPString.j.

- (CPString) stringByAppendingString: (CPString aString
implementation

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
implementation

Deletes the last path component of a string. This method assumes that the string's content is a '/' separated file system path. Multiple '/' separators between components are truncated to a single one.

Definition at line 849 of file CPString.j.

- (CPString) stringByDeletingPathExtension
implementation

Deletes the extension of a string. This method assumes that the string's content is a '/' separated file system path. Multiple '/' separators between components are truncated to a single one.

Definition at line 873 of file CPString.j.

- (CPString) stringByEscapingRegexControlCharacters
implementation

Definition at line 407 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.

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 
implementation

Definition at line 456 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 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 
implementation

Definition at line 433 of file CPString.j.

- (CPString) stringByStandardizingPath
implementation

Definition at line 885 of file CPString.j.

- (id) stringByTrimmingCharactersInSet: (CPCharacterSet set
implementation

Provided by category CPString(CPCharacterSetAdditions).

Definition at line 449 of file CPCharacterSet.j.

- (CPString) stringByTrimmingWhitespace
implementation

Returns a new string with leading and trailing whitespace trimmed

Definition at line 464 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.

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

Definition at line 171 of file CPString.j.

+ (id) stringWithHash: (unsigned)  aHash
implementation

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
implementation

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
implementation

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
implementation

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
implementation

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
implementation

Returns a hash of the string instance.

Reimplemented from CPObject.

Definition at line 581 of file CPString.j.

- (CPString) uppercaseString
implementation

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

Definition at line 662 of file CPString.j.

+ (CPString) UUID
implementation

Returns a randomly generated Universally Unique Identifier.

Provided by category CPString(UUID).

Definition at line 920 of file CPString.j.


The documentation for this class was generated from the following files: