Public Member Functions | Static Public Member Functions | Protected Attributes

OFString Class Reference

A class for handling strings. More...

#import <OFString.h>

Inheritance diagram for OFString:
OFObject <OFCopying> <OFMutableCopying> <OFComparing> <OFObject> OFConstantString OFMutableString

List of all members.

Public Member Functions

(id) - initWithCString:
(id) - initWithCString:encoding:
(id) - initWithCString:encoding:length:
(id) - initWithCString:length:
(id) - initWithFormat:
(id) - initWithFormat:arguments:
(id) - initWithPath:
(id) - initWithPath:arguments:
(id) - initWithString:
(id) - initWithContentsOfFile:
(id) - initWithContentsOfFile:encoding:
(id) - initWithContentsOfURL:
(id) - initWithContentsOfURL:encoding:
(const char *) - cString
(size_t) - length
(size_t) - cStringLength
(of_comparison_result_t) - caseInsensitiveCompare:
(of_unichar_t) - characterAtIndex:
(size_t) - indexOfFirstOccurrenceOfString:
(size_t) - indexOfLastOccurrenceOfString:
(BOOL) - containsString:
(OFString *) - substringFromIndex:toIndex:
(OFString *) - substringWithRange:
(OFString *) - stringByAppendingString:
(OFString *) - stringByDeletingLeadingWhitespaces
(OFString *) - stringByDeletingTrailingWhitespaces
(OFString *) - stringByDeletingLeadingAndTrailingWhitespaces
(BOOL) - hasPrefix:
(BOOL) - hasSuffix:
(OFArray *) - componentsSeparatedByString:
(OFArray *) - pathComponents
(OFString *) - lastPathComponent
(OFString *) - stringByDeletingLastPathComponent
(intmax_t) - decimalValue
(uintmax_t) - hexadecimalValue
(float) - floatValue
(double) - doubleValue
(of_unichar_t *) - unicodeString
(void) - writeToFile:
(OFString *) - MD5Hash
(OFString *) - SHA1Hash
(OFString *) - stringByURLEncoding
(OFString *) - stringByURLDecoding
(OFString *) - stringByXMLEscaping
(OFString *) - stringByXMLUnescaping
(OFString *) - stringByXMLUnescapingWithDelegate:
(OFString *) - stringByXMLUnescapingWithBlock:

Static Public Member Functions

(id) + string
(id) + stringWithCString:
(id) + stringWithCString:encoding:
(id) + stringWithCString:encoding:length:
(id) + stringWithCString:length:
(id) + stringWithFormat:
(id) + stringWithPath:
(id) + stringWithString:
(id) + stringWithContentsOfFile:
(id) + stringWithContentsOfFile:encoding:
(id) + stringWithContentsOfURL:
(id) + stringWithContentsOfURL:encoding:

Protected Attributes

char * string
size_t length
BOOL isUTF8

Detailed Description

A class for handling strings.


Member Function Documentation

- (of_comparison_result_t) caseInsensitiveCompare: (OFString*)  str  

Compares the OFString to another OFString without caring about the case.

Parameters:
str A string to compare with
Returns:
An of_comparison_result_t
- (of_unichar_t) characterAtIndex: (size_t)  index  
Parameters:
index The index of the Unicode character to return
Returns:
The Unicode character at the specified index
- (OFArray *) componentsSeparatedByString: (OFString*)  delimiter  

Splits an OFString into an OFArray of OFStrings.

Parameters:
delimiter The delimiter for splitting
Returns:
An autoreleased OFArray with the splitted string
- (BOOL) containsString: (OFString*)  str  
Parameters:
str The string to search
Returns:
Whether the string contains the specified string
- (const char *) cString  
Returns:
The OFString as a UTF-8 encoded C string
- (size_t) cStringLength  
Returns:
The length of the string which cString would return
- (intmax_t) decimalValue  

Returns the decimal value of the string as an intmax_t or throws an OFInvalidEncodingException if the string contains any non-number characters. Leading and trailing whitespaces are ignored.

If the number is too big to fit into an intmax_t, an OFOutOfRangeException is thrown.

Returns:
An intmax_t with the value of the string
- (double) doubleValue  

Returns the double value of the string as a float or throws an OFInvalidEncodingException if the string contains any non-number characters.

Returns:
A double with the value of the string
- (float) floatValue  

Returns the float value of the string as a float or throws an OFInvalidEncodingException if the string contains any non-number characters.

Returns:
A float with the value of the string
- (BOOL) hasPrefix: (OFString*)  prefix  

Checks whether the string has the specified prefix.

Parameters:
prefix The prefix to check for
Returns:
A boolean whether the string has the specified prefix
- (BOOL) hasSuffix: (OFString*)  suffix  

Checks whether the string has the specified suffix.

Parameters:
suffix The suffix to check for
Returns:
A boolean whether the string has the specified suffix
- (uintmax_t) hexadecimalValue  

Returns the hexadecimal value of the string as an uintmax_t or throws an OFInvalidEncodingException if the string contains any non-number characters. Leading and trailing whitespaces are ignored.

If the number is too big to fit into an uintmax_t, an OFOutOfRangeException is thrown.

Returns:
A uintmax_t with the value of the string
- (size_t) indexOfFirstOccurrenceOfString: (OFString*)  str  
Parameters:
str The string to search
Returns:
The index of the first occurrence of the string or OF_INVALID_INDEX if it was not found
- (size_t) indexOfLastOccurrenceOfString: (OFString*)  str  
Parameters:
str The string to search
Returns:
The index of the last occurrence of the string or OF_INVALID_INDEX if it was not found
- (id) initWithContentsOfFile: (OFString*)  path  

Initializes an already allocated OFString with the contents of the specified file in the specified encoding.

Parameters:
path The path to the file
Returns:
An initialized OFString
- (id) initWithContentsOfFile: (OFString*)  path
encoding: (of_string_encoding_t)  encoding 

Initializes an already allocated OFString with the contents of the specified file in the specified encoding.

Parameters:
path The path to the file
encoding The encoding of the file
Returns:
An initialized OFString
- (id) initWithContentsOfURL: (OFURL*)  url  

Initializes an already allocated OFString with the contents of the specified URL, assuming UTF-8 encoding.

Parameters:
url The URL to the contents for the string
Returns:
An initialized OFString
- (id) initWithContentsOfURL: (OFURL*)  url
encoding: (of_string_encoding_t)  encoding 

Initializes an already allocated OFString with the contents of the specified URL in the specified encoding.

Parameters:
url The URL to the contents for the string
encoding The encoding to assume
Returns:
An initialized OFString
- (id) initWithCString: (const char*)  str  

Initializes an already allocated OFString from a UTF-8 encoded C string.

Parameters:
str A UTF-8 encoded C string to initialize the OFString with
Returns:
An initialized OFString
- (id) initWithCString: (const char*)  str
encoding: (of_string_encoding_t)  encoding 

Initializes an already allocated OFString from a C string with the specified encoding.

Parameters:
str A C string to initialize the OFString with
encoding The encoding of the C string
Returns:
An initialized OFString
- (id) initWithCString: (const char*)  str
encoding: (of_string_encoding_t)  encoding
length: (size_t)  len 

Initializes an already allocated OFString from a C string with the specified encoding and length.

Parameters:
str A C string to initialize the OFString with
encoding The encoding of the C string
len The length of the C string
Returns:
An initialized OFString
- (id) initWithCString: (const char*)  str
length: (size_t)  len 

Initializes an already allocated OFString from a UTF-8 encoded C string with the specified length.

Parameters:
str A UTF-8 encoded C string to initialize the OFString with
len The length of the UTF-8 encoded C string
Returns:
An initialized OFString
- (id) initWithFormat: (OFString*)  fmt
,   ... 

Initializes an already allocated OFString with a format string. See printf for the format syntax.

Parameters:
fmt A string used as format to initialize the OFString
Returns:
An initialized OFString
- (id) initWithFormat: (OFString*)  fmt
arguments: (va_list)  args 

Initializes an already allocated OFString with a format string. See printf for the format syntax.

Parameters:
fmt A string used as format to initialize the OFString
args The arguments used in the format string
Returns:
An initialized OFString
- (id) initWithPath: (OFString*)  first
,   ... 

Initializes an already allocated OFString with the constructed specified path.

Parameters:
first The first component of the path
Returns:
A new autoreleased OFString
- (id) initWithPath: (OFString*)  first
arguments: (va_list)  args 

Initializes an already allocated OFString with the constructed specified path.

Parameters:
first The first component of the path
args A va_list with the other components of the path
Returns:
A new autoreleased OFString
- (id) initWithString: (OFString*)  str  

Initializes an already allocated OFString with another string.

Parameters:
str A string to initialize the OFString with
Returns:
An initialized OFString
- (OFString *) lastPathComponent  
Returns:
The last component of the path
- (size_t) length  
Returns:
The length of the string in Unicode characters
- (OFString*) MD5Hash  
Returns:
The MD5 hash of the string as an autoreleased OFString
- (OFArray *) pathComponents  
Returns:
The components of the path
- (OFString*) SHA1Hash  
Returns:
The SHA1 hash of the string as an autoreleased OFString
+ (id) string  
Returns:
A new autoreleased OFString
- (OFString *) stringByAppendingString: (OFString*)  str  

Creates a new string by appending another string.

Parameters:
str The string to append
Returns:
A new autoreleased OFString with the specified string appended
- (OFString *) stringByDeletingLastPathComponent  
Returns:
The directory name of the path
- (OFString *) stringByDeletingLeadingAndTrailingWhitespaces  

Creates a new string by deleting leading and trailing whitespaces.

Returns:
A new autoreleased OFString with leading and trailing whitespaces deleted
- (OFString *) stringByDeletingLeadingWhitespaces  

Creates a new string by deleting leading whitespaces.

Returns:
A new autoreleased OFString with leading whitespaces deleted
- (OFString *) stringByDeletingTrailingWhitespaces  

Creates a new string by deleting trailing whitespaces.

Returns:
A new autoreleased OFString with trailing whitespaces deleted
- (OFString*) stringByURLDecoding  

Decodes a string used in a URL.

Returns:
A new autoreleased string
- (OFString*) stringByURLEncoding  

Encodes a string for use in a URL.

Returns:
A new autoreleased string
- (OFString*) stringByXMLEscaping  

Escapes a string for use in an XML document.

Returns:
A new autoreleased string
- (OFString*) stringByXMLUnescaping  

Unescapes XML in the string.

- (OFString*) stringByXMLUnescapingWithBlock: (of_string_xml_unescaping_block_t)  block  

Unescapes XML in the string and uses the specified block for unknown entities.

Parameters:
block A block which handles unknown entities
- (OFString*) stringByXMLUnescapingWithDelegate: (id< OFStringXMLUnescapingDelegate >)  delegate  

Unescapes XML in the string and uses the specified delegate for unknown entities.

Parameters:
delegate An OFXMLUnescapingDelegate as a handler for unknown entities
+ (id) stringWithContentsOfFile: (OFString*)  path  

Creates a new OFString with the contents of the specified UTF-8 encoded file.

Parameters:
path The path to the file
Returns:
A new autoreleased OFString
+ (id) stringWithContentsOfFile: (OFString*)  path
encoding: (of_string_encoding_t)  encoding 

Creates a new OFString with the contents of the specified file in the specified encoding.

Parameters:
path The path to the file
encoding The encoding of the file
Returns:
A new autoreleased OFString
+ (id) stringWithContentsOfURL: (OFURL*)  url  

Creates a new OFString with the contents of the specified URL, assuming UTF-8 encoding.

Parameters:
url The URL to the contents for the string
Returns:
A new autoreleased OFString
+ (id) stringWithContentsOfURL: (OFURL*)  url
encoding: (of_string_encoding_t)  encoding 

Creates a new OFString with the contents of the specified URL in the specified encoding.

Parameters:
url The URL to the contents for the string
encoding The encoding to assume
Returns:
A new autoreleased OFString
+ (id) stringWithCString: (const char*)  str  

Creates a new OFString from a UTF-8 encoded C string.

Parameters:
str A UTF-8 encoded C string to initialize the OFString with
Returns:
A new autoreleased OFString
+ (id) stringWithCString: (const char*)  str
encoding: (of_string_encoding_t)  encoding 

Creates a new OFString from a C string with the specified encoding.

Parameters:
str A C string to initialize the OFString with
encoding The encoding of the C string
Returns:
A new autoreleased OFString
+ (id) stringWithCString: (const char*)  str
encoding: (of_string_encoding_t)  encoding
length: (size_t)  len 

Creates a new OFString from a C string with the specified encoding and length.

Parameters:
str A C string to initialize the OFString with
encoding The encoding of the C string
len The length of the C string
Returns:
A new autoreleased OFString
+ (id) stringWithCString: (const char*)  str
length: (size_t)  len 

Creates a new OFString from a UTF-8 encoded C string with the specified length.

Parameters:
str A UTF-8 encoded C string to initialize the OFString with
len The length of the UTF-8 encoded C string
Returns:
A new autoreleased OFString
+ (id) stringWithFormat: (OFString*)  fmt
,   ... 

Creates a new OFString from a format string. See printf for the format syntax.

Parameters:
fmt A string used as format to initialize the OFString
Returns:
A new autoreleased OFString
+ (id) stringWithPath: (OFString*)  first
,   ... 

Creates a new OFString containing the constructed specified path.

Parameters:
first The first component of the path
Returns:
A new autoreleased OFString
+ (id) stringWithString: (OFString*)  str  

Creates a new OFString from another string.

Parameters:
str A string to initialize the OFString with
Returns:
A new autoreleased OFString
- (OFString *) substringFromIndex: (size_t)  start
toIndex: (size_t)  end 
Parameters:
start The index where the substring starts
end The index where the substring ends. This points BEHIND the last character!
Returns:
The substring as a new autoreleased OFString
- (OFString *) substringWithRange: (of_range_t range  
Parameters:
range The range of the substring
Returns:
The substring as a new autoreleased OFString
- (of_unichar_t *) unicodeString  

Returns the string as an array of of_unichar_t. The result needs to be free()'d by the caller, as the memory is not marked as belonging to the object.

Returns:
The string as an array of Unicode characters
- (void) writeToFile: (OFString*)  path  

Writes the string into the specified file using UTF-8 encoding.

Parameters:
path The path of the file to write to

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