API  1.0.0
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) - integerValue
 
(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- stripDiacritics
 
(CPString- substringFromIndex:
 
(CPString- substringToIndex:
 
(CPString- substringWithRange:
 
(CPString- 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:
 
(void) - performSelector:withObject:afterDelay:
 
(void) - performSelector:withObject:afterDelay:inModes:
 
(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
 
(void) + initialize
 
(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:
 
(void) + cancelPreviousPerformRequestsWithTarget:
 
(void) + cancelPreviousPerformRequestsWithTarget:selector:object:
 
(Class) + class
 
(BOOL) + conformsToProtocol:
 
(void) + exposeBinding:
 
(IMP) + instanceMethodForSelector:
 
(BOOL) + instancesImplementSelector:
 
(BOOL) + instancesRespondToSelector:
 
(BOOL) + isBindingExclusive:
 
(BOOL) + isSubclassOfClass:
 
(CPSet) + keyPathsForValuesAffectingValueForKey:
 
(void) + load
 
(id) + new
 
(void) + object:performSelector:withObject:afterDelay:inModes:
 
(void) + setVersion:
 
(Class) + superclass
 
(int) + version
 

Detailed Description

An immutable string (collection of characters).

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

◆ alloc()

+ (id) alloc
implementation

Allocates a new instance of the receiving class

Reimplemented from CPObject.

Definition at line 87 of file CPString.j.

◆ boolValue()

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

◆ capitalizedString()

- (CPString) capitalizedString
implementation

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

Definition at line 646 of file CPString.j.

◆ caseInsensitiveCompare:()

- (CPComparisonResult) caseInsensitiveCompare: (CPString aString
implementation

Definition at line 488 of file CPString.j.

◆ characterAtIndex:()

- (CPString) characterAtIndex: (CPUInteger)  anIndex
implementation

Returns the character at the specified index.

Parameters
anIndexthe index of the desired character

Definition at line 195 of file CPString.j.

◆ commonPrefixWithString:()

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

◆ commonPrefixWithString:options:()

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

◆ compare:()

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

◆ compare:options:()

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

◆ compare:options:range:()

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

◆ componentsSeparatedByCharactersInSet:()

- (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 435 of file CPCharacterSet.j.

◆ componentsSeparatedByString:()

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

◆ cssString()

- (CPString) cssString
implementation

Returns the string

Provided by category CPString(CPStringDrawing).

Definition at line 45 of file CPStringDrawing.j.

◆ description()

- (CPString) description
implementation

Returns a description of this CPString object.

Reimplemented from CPObject.

Definition at line 178 of file CPString.j.

◆ doubleValue()

- (double) doubleValue
implementation

Returns the text as a floating point value.

Definition at line 689 of file CPString.j.

◆ floatValue()

- (float) floatValue
implementation

Returns the text as a float point value.

Definition at line 707 of file CPString.j.

◆ hasPrefix:()

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

◆ hasSuffix:()

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

◆ initialize()

+ (void) initialize
implementation

Reimplemented from CPObject.

Provided by category CPString(CPStringDrawing).

Definition at line 55 of file CPStringDrawing.j.

◆ initWithFormat:()

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

◆ initWithString:()

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

◆ integerValue()

- (int) integerValue
implementation

Returns the text as an integer

Definition at line 723 of file CPString.j.

◆ intValue()

- (int) intValue
implementation

Returns the text as an integer

Definition at line 715 of file CPString.j.

◆ isEqual:()

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

◆ isEqualToString:()

- (BOOL) isEqualToString: (CPString aString
implementation

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

Definition at line 584 of file CPString.j.

◆ JSONFromObject:()

+ (CPString) JSONFromObject: (JSObject)  anObject
implementation

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

Provided by category CPString(JSON).

Definition at line 926 of file CPString.j.

◆ lastPathComponent()

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

◆ length()

- (int) length
implementation

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

Definition at line 186 of file CPString.j.

◆ lowercaseString()

- (CPString) lowercaseString
implementation

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

Definition at line 665 of file CPString.j.

◆ metricsOfFont:()

+ (CPDictionary) metricsOfFont: (CPFont aFont
implementation

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

Provided by category CPString(CPStringDrawing).

Definition at line 37 of file CPStringDrawing.j.

◆ objectFromJSON()

- (JSObject) objectFromJSON
implementation

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

Provided by category CPString(JSON).

Definition at line 934 of file CPString.j.

◆ pathComponents()

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

◆ pathExtension()

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

◆ pathWithComponents:()

+ (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 771 of file CPString.j.

◆ rangeOfString:()

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

◆ rangeOfString:options:()

- (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
CPDiacriticInsensitiveSearch
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 345 of file CPString.j.

◆ rangeOfString:options:range:()

- (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
CPDiacriticInsensitiveSearch
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 370 of file CPString.j.

◆ sizeWithFont:()

- (CGSize) sizeWithFont: (CPFont aFont
implementation

Provided by category CPString(CPStringDrawing).

Definition at line 50 of file CPStringDrawing.j.

◆ sizeWithFont:inWidth:()

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

Provided by category CPString(CPStringDrawing).

Definition at line 112 of file CPStringDrawing.j.

◆ string()

+ (id) string
implementation

Returns a new string

Provided by category CPString(CPTextFieldAdditions).

Definition at line 98 of file CPString.j.

◆ stringByAppendingFormat:()

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

◆ stringByAppendingPathComponent:()

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

◆ stringByAppendingPathExtension:()

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

◆ stringByAppendingString:()

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

◆ stringByDeletingLastPathComponent()

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

◆ stringByDeletingPathExtension()

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

◆ stringByEscapingRegexControlCharacters()

- (CPString) stringByEscapingRegexControlCharacters
implementation

Definition at line 409 of file CPString.j.

◆ stringByPaddingToLength:withString:startingAtIndex:()

- (CPString) stringByPaddingToLength: (unsigned)  aLength
withString: (CPString aString
startingAtIndex: (CPUInteger)  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 238 of file CPString.j.

◆ stringByReplacingCharactersInRange:withString:()

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

Definition at line 458 of file CPString.j.

◆ stringByReplacingOccurrencesOfString:withString:()

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

◆ stringByReplacingOccurrencesOfString:withString:options:range:()

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

Definition at line 435 of file CPString.j.

◆ stringByStandardizingPath()

- (CPString) stringByStandardizingPath
implementation

Definition at line 912 of file CPString.j.

◆ stringByTrimmingCharactersInSet:()

- (id) stringByTrimmingCharactersInSet: (CPCharacterSet set
implementation

Provided by category CPString(CPCharacterSetAdditions).

Definition at line 462 of file CPCharacterSet.j.

◆ stringByTrimmingWhitespace()

- (CPString) stringByTrimmingWhitespace
implementation

Returns a new string with leading and trailing whitespace trimmed

Definition at line 466 of file CPString.j.

◆ stringWithFormat:()

+ (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 166 of file CPString.j.

◆ stringWithHash:()

+ (id) stringWithHash: (unsigned)  aHash
implementation

Returns a CPString containing the specified hash.

Parameters
aHashthe hash to represent as a string

Definition at line 107 of file CPString.j.

◆ stringWithString:()

+ (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 119 of file CPString.j.

◆ stripDiacritics()

- (CPString) stripDiacritics
implementation

Returns a copy of the string stripped of diacritical marks.

Definition at line 681 of file CPString.j.

◆ substringFromIndex:()

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

◆ substringToIndex:()

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

◆ substringWithRange:()

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

◆ UID()

- (CPString) UID
implementation

Returns a hash of the string instance.

Reimplemented from CPObject.

Definition at line 592 of file CPString.j.

◆ uppercaseString()

- (CPString) uppercaseString
implementation

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

Definition at line 673 of file CPString.j.

◆ UUID()

+ (CPString) UUID
implementation

Returns a randomly generated Universally Unique Identifier.

Provided by category CPString(UUID).

Definition at line 947 of file CPString.j.


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