ObjFW
Public Member Functions | Static Public Member Functions | Protected Attributes
OFString Class Reference

A class for handling strings. More...

#include <OFString.h>

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

List of all members.

Public Member Functions

id initWithCString: (const char *str)
id initWithCString:encoding: (const char *str,[encoding] of_string_encoding_t encoding)
id initWithCString:encoding:length: (const char *str,[encoding] of_string_encoding_t encoding,[length] size_t len)
id initWithCString:length: (const char *str,[length] size_t len)
id initWithFormat: (OFString *fmt,[,]...)
id initWithFormat:arguments: (OFString *fmt,[arguments] va_list args)
id initWithPath: (OFString *first,[,]...)
id initWithPath:arguments: (OFString *first,[arguments] va_list args)
id initWithString: (OFString *str)
id initWithContentsOfFile: (OFString *path)
id initWithContentsOfFile:encoding: (OFString *path,[encoding] of_string_encoding_t encoding)
id initWithContentsOfURL: (OFURL *url)
id initWithContentsOfURL:encoding: (OFURL *url,[encoding] of_string_encoding_t encoding)
const char * cString ()
size_t length ()
size_t cStringLength ()
of_comparison_result_t caseInsensitiveCompare: (OFString *str)
of_unichar_t characterAtIndex: (size_t index)
size_t indexOfFirstOccurrenceOfString: (OFString *str)
size_t indexOfLastOccurrenceOfString: (OFString *str)
BOOL containsString: (OFString *str)
OFStringsubstringFromIndex:toIndex: (size_t start,[toIndex] size_t end)
OFStringsubstringWithRange: (of_range_t range)
OFStringstringByAppendingString: (OFString *str)
OFStringstringByDeletingLeadingWhitespaces ()
OFStringstringByDeletingTrailingWhitespaces ()
OFStringstringByDeletingLeadingAndTrailingWhitespaces ()
BOOL hasPrefix: (OFString *prefix)
BOOL hasSuffix: (OFString *suffix)
OFArraycomponentsSeparatedByString: (OFString *delimiter)
OFArraypathComponents ()
OFStringlastPathComponent ()
OFStringstringByDeletingLastPathComponent ()
intmax_t decimalValue ()
uintmax_t hexadecimalValue ()
float floatValue ()
double doubleValue ()
of_unichar_t * unicodeString ()
void writeToFile: (OFString *path)
OFStringMD5Hash ()
OFStringSHA1Hash ()
OFStringstringByURLEncoding ()
OFStringstringByURLDecoding ()
OFStringstringByXMLEscaping ()
OFStringstringByXMLUnescaping ()
OFStringstringByXMLUnescapingWithDelegate: (id< OFStringXMLUnescapingDelegate > delegate)
OFStringstringByXMLUnescapingWithBlock: (of_string_xml_unescaping_block_t block)

Static Public Member Functions

id string ()
id stringWithCString: (const char *str)
id stringWithCString:encoding: (const char *str,[encoding] of_string_encoding_t encoding)
id stringWithCString:encoding:length: (const char *str,[encoding] of_string_encoding_t encoding,[length] size_t len)
id stringWithCString:length: (const char *str,[length] size_t len)
id stringWithFormat: (OFString *fmt,[,]...)
id stringWithPath: (OFString *first,[,]...)
id stringWithString: (OFString *str)
id stringWithContentsOfFile: (OFString *path)
id stringWithContentsOfFile:encoding: (OFString *path,[encoding] of_string_encoding_t encoding)
id stringWithContentsOfURL: (OFURL *url)
id stringWithContentsOfURL:encoding: (OFURL *url,[encoding] of_string_encoding_t encoding)

Protected Attributes

char * string
size_t length
BOOL isUTF8

Detailed Description

A class for handling strings.


Member Function Documentation

of_comparison_result_t OFString::caseInsensitiveCompare: ( OFString str) [virtual]

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

Parameters:
strA string to compare with
Returns:
An of_comparison_result_t
of_unichar_t OFString::characterAtIndex: ( size_t  index) [virtual]
Parameters:
indexThe index of the Unicode character to return
Returns:
The Unicode character at the specified index
OFArray * OFString::componentsSeparatedByString: ( OFString delimiter) [virtual]

Splits an OFString into an OFArray of OFStrings.

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

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 OFString::doubleValue ( ) [virtual]

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 OFString::floatValue ( ) [virtual]

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 OFString::hasPrefix: ( OFString prefix) [virtual]

Checks whether the string has the specified prefix.

Parameters:
prefixThe prefix to check for
Returns:
A boolean whether the string has the specified prefix
BOOL OFString::hasSuffix: ( OFString suffix) [virtual]

Checks whether the string has the specified suffix.

Parameters:
suffixThe suffix to check for
Returns:
A boolean whether the string has the specified suffix
uintmax_t OFString::hexadecimalValue ( ) [virtual]

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 OFString::indexOfFirstOccurrenceOfString: ( OFString str) [virtual]
Parameters:
strThe string to search
Returns:
The index of the first occurrence of the string or OF_INVALID_INDEX if it was not found
size_t OFString::indexOfLastOccurrenceOfString: ( OFString str) [virtual]
Parameters:
strThe string to search
Returns:
The index of the last occurrence of the string or OF_INVALID_INDEX if it was not found
id OFString::initWithContentsOfFile: ( OFString path) [virtual]

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

Parameters:
pathThe path to the file
Returns:
An initialized OFString
id OFString::initWithContentsOfFile:encoding: ( OFString path,
[encoding] of_string_encoding_t  encoding 
) [virtual]

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

Parameters:
pathThe path to the file
encodingThe encoding of the file
Returns:
An initialized OFString
id OFString::initWithContentsOfURL: ( OFURL url) [virtual]

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

Parameters:
urlThe URL to the contents for the string
Returns:
An initialized OFString
id OFString::initWithContentsOfURL:encoding: ( OFURL url,
[encoding] of_string_encoding_t  encoding 
) [virtual]

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

Parameters:
urlThe URL to the contents for the string
encodingThe encoding to assume
Returns:
An initialized OFString
id OFString::initWithCString: ( const char*  str) [virtual]

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

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

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

Parameters:
strA C string to initialize the OFString with
encodingThe encoding of the C string
Returns:
An initialized OFString
id OFString::initWithCString:encoding:length: ( const char*  str,
[encoding] of_string_encoding_t  encoding,
[length] size_t  len 
) [virtual]

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

Parameters:
strA C string to initialize the OFString with
encodingThe encoding of the C string
lenThe length of the C string
Returns:
An initialized OFString
id OFString::initWithCString:length: ( const char*  str,
[length] size_t  len 
) [virtual]

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

Parameters:
strA UTF-8 encoded C string to initialize the OFString with
lenThe length of the UTF-8 encoded C string
Returns:
An initialized OFString
id OFString::initWithFormat: ( OFString fmt,
[,]   ... 
) [virtual]

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

Parameters:
fmtA string used as format to initialize the OFString
Returns:
An initialized OFString
id OFString::initWithFormat:arguments: ( OFString fmt,
[arguments] va_list  args 
) [virtual]

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

Parameters:
fmtA string used as format to initialize the OFString
argsThe arguments used in the format string
Returns:
An initialized OFString
id OFString::initWithPath: ( OFString first,
[,]   ... 
) [virtual]

Initializes an already allocated OFString with the constructed specified path.

Parameters:
firstThe first component of the path
Returns:
A new autoreleased OFString
id OFString::initWithPath:arguments: ( OFString first,
[arguments] va_list  args 
) [virtual]

Initializes an already allocated OFString with the constructed specified path.

Parameters:
firstThe first component of the path
argsA va_list with the other components of the path
Returns:
A new autoreleased OFString
id OFString::initWithString: ( OFString str) [virtual]

Initializes an already allocated OFString with another string.

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

Creates a new string by appending another string.

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

Creates a new string by deleting leading and trailing whitespaces.

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

Creates a new string by deleting leading whitespaces.

Returns:
A new autoreleased OFString with leading whitespaces deleted
OFString * OFString::stringByDeletingTrailingWhitespaces ( ) [virtual]

Creates a new string by deleting trailing whitespaces.

Returns:
A new autoreleased OFString with trailing whitespaces deleted
OFString* OFString(URLEncoding)::stringByURLDecoding ( ) [virtual]

Decodes a string used in a URL.

Returns:
A new autoreleased string
OFString* OFString(URLEncoding)::stringByURLEncoding ( ) [virtual]

Encodes a string for use in a URL.

Returns:
A new autoreleased string
OFString* OFString(XMLEscaping)::stringByXMLEscaping ( ) [virtual]

Escapes a string for use in an XML document.

Returns:
A new autoreleased string
OFString* OFString(XMLUnescaping)::stringByXMLUnescaping ( ) [virtual]

Unescapes XML in the string.

OFString* OFString(XMLUnescaping)::stringByXMLUnescapingWithBlock: ( of_string_xml_unescaping_block_t  block) [virtual]

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

Parameters:
blockA block which handles unknown entities
OFString* OFString(XMLUnescaping)::stringByXMLUnescapingWithDelegate: ( id< OFStringXMLUnescapingDelegate delegate) [virtual]

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

Parameters:
delegateAn OFXMLUnescapingDelegate as a handler for unknown entities
id OFString::stringWithContentsOfFile: ( OFString path) [static, virtual]

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

Parameters:
pathThe path to the file
Returns:
A new autoreleased OFString
id OFString::stringWithContentsOfFile:encoding: ( OFString path,
[encoding] of_string_encoding_t  encoding 
) [static, virtual]

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

Parameters:
pathThe path to the file
encodingThe encoding of the file
Returns:
A new autoreleased OFString
id OFString::stringWithContentsOfURL: ( OFURL url) [static, virtual]

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

Parameters:
urlThe URL to the contents for the string
Returns:
A new autoreleased OFString
id OFString::stringWithContentsOfURL:encoding: ( OFURL url,
[encoding] of_string_encoding_t  encoding 
) [static, virtual]

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

Parameters:
urlThe URL to the contents for the string
encodingThe encoding to assume
Returns:
A new autoreleased OFString
id OFString::stringWithCString: ( const char*  str) [static, virtual]

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

Parameters:
strA UTF-8 encoded C string to initialize the OFString with
Returns:
A new autoreleased OFString
id OFString::stringWithCString:encoding: ( const char*  str,
[encoding] of_string_encoding_t  encoding 
) [static, virtual]

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

Parameters:
strA C string to initialize the OFString with
encodingThe encoding of the C string
Returns:
A new autoreleased OFString
id OFString::stringWithCString:encoding:length: ( const char*  str,
[encoding] of_string_encoding_t  encoding,
[length] size_t  len 
) [static, virtual]

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

Parameters:
strA C string to initialize the OFString with
encodingThe encoding of the C string
lenThe length of the C string
Returns:
A new autoreleased OFString
id OFString::stringWithCString:length: ( const char*  str,
[length] size_t  len 
) [static, virtual]

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

Parameters:
strA UTF-8 encoded C string to initialize the OFString with
lenThe length of the UTF-8 encoded C string
Returns:
A new autoreleased OFString
id OFString::stringWithFormat: ( OFString fmt,
[,]   ... 
) [static, virtual]

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

Parameters:
fmtA string used as format to initialize the OFString
Returns:
A new autoreleased OFString
id OFString::stringWithPath: ( OFString first,
[,]   ... 
) [static, virtual]

Creates a new OFString containing the constructed specified path.

Parameters:
firstThe first component of the path
Returns:
A new autoreleased OFString
id OFString::stringWithString: ( OFString str) [static, virtual]

Creates a new OFString from another string.

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

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 OFString::writeToFile: ( OFString path) [virtual]

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

Parameters:
pathThe path of the file to write to

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