@@ -52,72 +52,87 @@ #else typedef void OFString; #endif #if defined(__cplusplus) && __cplusplus >= 201103L -typedef char16_t of_char16_t; -typedef char32_t of_char32_t; +typedef char16_t OFChar16; +typedef char32_t OFChar32; #else -typedef uint_least16_t of_char16_t; -typedef uint_least32_t of_char32_t; +typedef uint_least16_t OFChar16; +typedef uint_least32_t OFChar32; #endif -typedef of_char32_t of_unichar_t; +typedef OFChar32 OFUnichar; /** * @brief The encoding of a string. */ -typedef enum of_string_encoding_t { +typedef enum { /* * UTF-8 *has* to be 0, so that if the current @ref OFLocale is * `nil`, `[OFLocale encoding]` returns UTF-8. */ /** UTF-8 */ - OF_STRING_ENCODING_UTF_8, + OFStringEncodingUTF8, /** ASCII */ - OF_STRING_ENCODING_ASCII, + OFStringEncodingASCII, /** ISO 8859-1 */ - OF_STRING_ENCODING_ISO_8859_1, + OFStringEncodingISO8859_1, /** ISO 8859-2 */ - OF_STRING_ENCODING_ISO_8859_2, + OFStringEncodingISO8859_2, /** ISO 8859-3 */ - OF_STRING_ENCODING_ISO_8859_3, + OFStringEncodingISO8859_3, /** ISO 8859-15 */ - OF_STRING_ENCODING_ISO_8859_15, + OFStringEncodingISO8859_15, /** Windows-1251 */ - OF_STRING_ENCODING_WINDOWS_1251, + OFStringEncodingWindows1251, /** Windows-1252 */ - OF_STRING_ENCODING_WINDOWS_1252, + OFStringEncodingWindows1252, /** Codepage 437 */ - OF_STRING_ENCODING_CODEPAGE_437, + OFStringEncodingCodepage437, /** Codepage 850 */ - OF_STRING_ENCODING_CODEPAGE_850, + OFStringEncodingCodepage850, /** Codepage 858 */ - OF_STRING_ENCODING_CODEPAGE_858, + OFStringEncodingCodepage858, /** Mac OS Roman */ - OF_STRING_ENCODING_MAC_ROMAN, + OFStringEncodingMacRoman, /** KOI8-R */ - OF_STRING_ENCODING_KOI8_R, + OFStringEncodingKOI8R, /** KOI8-U */ - OF_STRING_ENCODING_KOI8_U, + OFStringEncodingKOI8U, /** Try to automatically detect the encoding */ - OF_STRING_ENCODING_AUTODETECT = 0xFF -} of_string_encoding_t; + OFStringEncodingAutodetect = 0xFF +} OFStringEncoding; -enum { - OF_STRING_SEARCH_BACKWARDS = 1, - OF_STRING_SKIP_EMPTY = 2 -}; +/** + * @brief Options for searching in strings. + * + * This is a bit mask. + */ +typedef enum { + /** Search backwards in the string */ + OFStringSearchBackwards = 1 +} OFStringSearchOptions; + +/** + * @brief Options for separating strings. + * + * This is a bit mask. + */ +typedef enum { + /** Skip empty components */ + OFStringSkipEmptyComponents = 1 +} OFStringSeparationOptions; #ifdef OF_HAVE_BLOCKS /** * @brief A block for enumerating the lines of a string. * * @param line The current line * @param stop A pointer to a variable that can be set to true to stop the * enumeration */ -typedef void (^of_string_line_enumeration_block_t)(OFString *line, bool *stop); +typedef void (^OFStringLineEnumerationBlock)(OFString *line, bool *stop); #endif #ifdef __OBJC__ @class OFArray OF_GENERIC(ObjectType); @class OFCharacterSet; @@ -215,21 +230,21 @@ * * The result is valid until the autorelease pool is released. If you want to * use the result outside the scope of the current autorelease pool, you have to * copy it. */ -@property (readonly, nonatomic) const of_unichar_t *characters +@property (readonly, nonatomic) const OFUnichar *characters OF_RETURNS_INNER_POINTER; /** * @brief The string in UTF-16 encoding with native byte order. * * The result is valid until the autorelease pool is released. If you want to * use the result outside the scope of the current autorelease pool, you have to * copy it. */ -@property (readonly, nonatomic) const of_char16_t *UTF16String +@property (readonly, nonatomic) const OFChar16 *UTF16String OF_RETURNS_INNER_POINTER; /** * @brief The length of the string in UTF-16 characters. */ @@ -240,11 +255,11 @@ * * The result is valid until the autorelease pool is released. If you want to * use the result outside the scope of the current autorelease pool, you have to * copy it. */ -@property (readonly, nonatomic) const of_char32_t *UTF32String +@property (readonly, nonatomic) const OFChar32 *UTF32String OF_RETURNS_INNER_POINTER; /** * @brief The string with leading whitespaces deleted. */ @@ -349,11 +364,11 @@ * @param cString A C string to initialize the OFString with * @param encoding The encoding of the C string * @return A new autoreleased OFString */ + (instancetype)stringWithCString: (const char *)cString - encoding: (of_string_encoding_t)encoding; + encoding: (OFStringEncoding)encoding; /** * @brief Creates a new OFString from a C string with the specified encoding * and length. * @@ -361,11 +376,11 @@ * @param encoding The encoding of the C string * @param cStringLength The length of the C string * @return A new autoreleased OFString */ + (instancetype)stringWithCString: (const char *)cString - encoding: (of_string_encoding_t)encoding + encoding: (OFStringEncoding)encoding length: (size_t)cStringLength; /** * @brief Creates a new OFString from OFData with the specified encoding. * @@ -372,11 +387,11 @@ * @param data OFData with the contents of the string * @param encoding The encoding in which the string is stored in the OFData * @return An new autoreleased OFString */ + (instancetype)stringWithData: (OFData *)data - encoding: (of_string_encoding_t)encoding; + encoding: (OFStringEncoding)encoding; /** * @brief Creates a new OFString from another string. * * @param string A string to initialize the OFString with @@ -390,30 +405,30 @@ * * @param characters An array of Unicode characters * @param length The length of the Unicode character array * @return A new autoreleased OFString */ -+ (instancetype)stringWithCharacters: (const of_unichar_t *)characters ++ (instancetype)stringWithCharacters: (const OFUnichar *)characters length: (size_t)length; /** * @brief Creates a new OFString from a UTF-16 encoded string. * * @param string The UTF-16 string * @return A new autoreleased OFString */ -+ (instancetype)stringWithUTF16String: (const of_char16_t *)string; ++ (instancetype)stringWithUTF16String: (const OFChar16 *)string; /** * @brief Creates a new OFString from a UTF-16 encoded string with the * specified length. * * @param string The UTF-16 string * @param length The length of the UTF-16 string * @return A new autoreleased OFString */ -+ (instancetype)stringWithUTF16String: (const of_char16_t *)string ++ (instancetype)stringWithUTF16String: (const OFChar16 *)string length: (size_t)length; /** * @brief Creates a new OFString from a UTF-16 encoded string, assuming the * specified byte order if no byte order mark is found. @@ -420,12 +435,12 @@ * * @param string The UTF-16 string * @param byteOrder The byte order to assume if there is no byte order mark * @return A new autoreleased OFString */ -+ (instancetype)stringWithUTF16String: (const of_char16_t *)string - byteOrder: (of_byte_order_t)byteOrder; ++ (instancetype)stringWithUTF16String: (const OFChar16 *)string + byteOrder: (OFByteOrder)byteOrder; /** * @brief Creates a new OFString from a UTF-16 encoded string with the * specified length, assuming the specified byte order if no byte order * mark is found. @@ -433,31 +448,31 @@ * @param string The UTF-16 string * @param length The length of the UTF-16 string * @param byteOrder The byte order to assume if there is no byte order mark * @return A new autoreleased OFString */ -+ (instancetype)stringWithUTF16String: (const of_char16_t *)string ++ (instancetype)stringWithUTF16String: (const OFChar16 *)string length: (size_t)length - byteOrder: (of_byte_order_t)byteOrder; + byteOrder: (OFByteOrder)byteOrder; /** * @brief Creates a new OFString from a UTF-32 encoded string. * * @param string The UTF-32 string * @return A new autoreleased OFString */ -+ (instancetype)stringWithUTF32String: (const of_char32_t *)string; ++ (instancetype)stringWithUTF32String: (const OFChar32 *)string; /** * @brief Creates a new OFString from a UTF-32 encoded string with the * specified length. * * @param string The UTF-32 string * @param length The length of the UTF-32 string * @return A new autoreleased OFString */ -+ (instancetype)stringWithUTF32String: (const of_char32_t *)string ++ (instancetype)stringWithUTF32String: (const OFChar32 *)string length: (size_t)length; /** * @brief Creates a new OFString from a UTF-32 encoded string, assuming the * specified byte order if no byte order mark is found. @@ -464,12 +479,12 @@ * * @param string The UTF-32 string * @param byteOrder The byte order to assume if there is no byte order mark * @return A new autoreleased OFString */ -+ (instancetype)stringWithUTF32String: (const of_char32_t *)string - byteOrder: (of_byte_order_t)byteOrder; ++ (instancetype)stringWithUTF32String: (const OFChar32 *)string + byteOrder: (OFByteOrder)byteOrder; /** * @brief Creates a new OFString from a UTF-32 encoded string with the * specified length, assuming the specified byte order if no byte order * mark is found. @@ -477,20 +492,20 @@ * @param string The UTF-32 string * @param length The length of the UTF-32 string * @param byteOrder The byte order to assume if there is no byte order mark * @return A new autoreleased OFString */ -+ (instancetype)stringWithUTF32String: (const of_char32_t *)string ++ (instancetype)stringWithUTF32String: (const OFChar32 *)string length: (size_t)length - byteOrder: (of_byte_order_t)byteOrder; + byteOrder: (OFByteOrder)byteOrder; /** * @brief Creates a new OFString from a format string. * * See printf for the format syntax. As an addition, `%@` is available as - * format specifier for objects, `%C` for `of_unichar_t` and `%S` for - * `const of_unichar_t *`. + * format specifier for objects, `%C` for `OFUnichar` and `%S` for + * `const OFUnichar *`. * * @param format A string used as format to initialize the OFString * @return A new autoreleased OFString */ + (instancetype)stringWithFormat: (OFConstantString *)format, ...; @@ -512,14 +527,13 @@ * @param path The path to the file * @param encoding The encoding of the file * @return A new autoreleased OFString */ + (instancetype)stringWithContentsOfFile: (OFString *)path - encoding: (of_string_encoding_t)encoding; + encoding: (OFStringEncoding)encoding; # endif -# if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS) /** * @brief Creates a new OFString with the contents of the specified URL. * * If the URL's scheme is file, it tries UTF-8 encoding. * @@ -539,12 +553,11 @@ * @param URL The URL to the contents for the string * @param encoding The encoding to assume * @return A new autoreleased OFString */ + (instancetype)stringWithContentsOfURL: (OFURL *)URL - encoding: (of_string_encoding_t)encoding; -# endif + encoding: (OFStringEncoding)encoding; /** * @brief Initializes an already allocated OFString from a UTF-8 encoded C * string. * @@ -608,11 +621,11 @@ * @param cString A C string to initialize the OFString with * @param encoding The encoding of the C string * @return An initialized OFString */ - (instancetype)initWithCString: (const char *)cString - encoding: (of_string_encoding_t)encoding; + encoding: (OFStringEncoding)encoding; /** * @brief Initializes an already allocated OFString from a C string with the * specified encoding and length. * @@ -620,11 +633,11 @@ * @param encoding The encoding of the C string * @param cStringLength The length of the C string * @return An initialized OFString */ - (instancetype)initWithCString: (const char *)cString - encoding: (of_string_encoding_t)encoding + encoding: (OFStringEncoding)encoding length: (size_t)cStringLength; /** * @brief Initializes an already allocated OFString from OFData with the * specified encoding. @@ -632,11 +645,11 @@ * @param data OFData with the contents of the string * @param encoding The encoding in which the string is stored in the OFData * @return An initialized OFString */ - (instancetype)initWithData: (OFData *)data - encoding: (of_string_encoding_t)encoding; + encoding: (OFStringEncoding)encoding; /** * @brief Initializes an already allocated OFString with another string. * * @param string A string to initialize the OFString with @@ -650,30 +663,30 @@ * * @param characters An array of Unicode characters * @param length The length of the Unicode character array * @return An initialized OFString */ -- (instancetype)initWithCharacters: (const of_unichar_t *)characters +- (instancetype)initWithCharacters: (const OFUnichar *)characters length: (size_t)length; /** * @brief Initializes an already allocated OFString with a UTF-16 string. * * @param string The UTF-16 string * @return An initialized OFString */ -- (instancetype)initWithUTF16String: (const of_char16_t *)string; +- (instancetype)initWithUTF16String: (const OFChar16 *)string; /** * @brief Initializes an already allocated OFString with a UTF-16 string with * the specified length. * * @param string The UTF-16 string * @param length The length of the UTF-16 string * @return An initialized OFString */ -- (instancetype)initWithUTF16String: (const of_char16_t *)string +- (instancetype)initWithUTF16String: (const OFChar16 *)string length: (size_t)length; /** * @brief Initializes an already allocated OFString with a UTF-16 string, * assuming the specified byte order if no byte order mark is found. @@ -680,12 +693,12 @@ * * @param string The UTF-16 string * @param byteOrder The byte order to assume if there is no byte order mark * @return An initialized OFString */ -- (instancetype)initWithUTF16String: (const of_char16_t *)string - byteOrder: (of_byte_order_t)byteOrder; +- (instancetype)initWithUTF16String: (const OFChar16 *)string + byteOrder: (OFByteOrder)byteOrder; /** * @brief Initializes an already allocated OFString with a UTF-16 string with * the specified length, assuming the specified byte order if no byte * order mark is found. @@ -693,31 +706,31 @@ * @param string The UTF-16 string * @param length The length of the UTF-16 string * @param byteOrder The byte order to assume if there is no byte order mark * @return An initialized OFString */ -- (instancetype)initWithUTF16String: (const of_char16_t *)string +- (instancetype)initWithUTF16String: (const OFChar16 *)string length: (size_t)length - byteOrder: (of_byte_order_t)byteOrder; + byteOrder: (OFByteOrder)byteOrder; /** * @brief Initializes an already allocated OFString with a UTF-32 string. * * @param string The UTF-32 string * @return An initialized OFString */ -- (instancetype)initWithUTF32String: (const of_char32_t *)string; +- (instancetype)initWithUTF32String: (const OFChar32 *)string; /** * @brief Initializes an already allocated OFString with a UTF-32 string with * the specified length * * @param string The UTF-32 string * @param length The length of the UTF-32 string * @return An initialized OFString */ -- (instancetype)initWithUTF32String: (const of_char32_t *)string +- (instancetype)initWithUTF32String: (const OFChar32 *)string length: (size_t)length; /** * @brief Initializes an already allocated OFString with a UTF-32 string, * assuming the specified byte order if no byte order mark is found. @@ -724,12 +737,12 @@ * * @param string The UTF-32 string * @param byteOrder The byte order to assume if there is no byte order mark * @return An initialized OFString */ -- (instancetype)initWithUTF32String: (const of_char32_t *)string - byteOrder: (of_byte_order_t)byteOrder; +- (instancetype)initWithUTF32String: (const OFChar32 *)string + byteOrder: (OFByteOrder)byteOrder; /** * @brief Initializes an already allocated OFString with a UTF-32 string with * the specified length, assuming the specified byte order if no byte * order mark is found. @@ -737,20 +750,20 @@ * @param string The UTF-32 string * @param length The length of the UTF-32 string * @param byteOrder The byte order to assume if there is no byte order mark * @return An initialized OFString */ -- (instancetype)initWithUTF32String: (const of_char32_t *)string +- (instancetype)initWithUTF32String: (const OFChar32 *)string length: (size_t)length - byteOrder: (of_byte_order_t)byteOrder; + byteOrder: (OFByteOrder)byteOrder; /** * @brief Initializes an already allocated OFString with a format string. * * See printf for the format syntax. As an addition, `%@` is available as - * format specifier for objects, `%C` for `of_unichar_t` and `%S` for - * `const of_unichar_t *`. + * format specifier for objects, `%C` for `OFUnichar` and `%S` for + * `const OFUnichar *`. * * @param format A string used as format to initialize the OFString * @return An initialized OFString */ - (instancetype)initWithFormat: (OFConstantString *)format, ...; @@ -757,12 +770,12 @@ /** * @brief Initializes an already allocated OFString with a format string. * * See printf for the format syntax. As an addition, `%@` is available as - * format specifier for objects, `%C` for `of_unichar_t` and `%S` for - * `const of_unichar_t *`. + * format specifier for objects, `%C` for `OFUnichar` and `%S` for + * `const OFUnichar *`. * * @param format A string used as format to initialize the OFString * @param arguments The arguments used in the format string * @return An initialized OFString */ @@ -786,11 +799,11 @@ * @param path The path to the file * @param encoding The encoding of the file * @return An initialized OFString */ - (instancetype)initWithContentsOfFile: (OFString *)path - encoding: (of_string_encoding_t)encoding; + encoding: (OFStringEncoding)encoding; # endif /** * @brief Initializes an already allocated OFString with the contents of the * specified URL. @@ -813,11 +826,11 @@ * @param URL The URL to the contents for the string * @param encoding The encoding to assume * @return An initialized OFString */ - (instancetype)initWithContentsOfURL: (OFURL *)URL - encoding: (of_string_encoding_t)encoding; + encoding: (OFStringEncoding)encoding; /** * @brief Writes the OFString into the specified C string with the specified * encoding. * @@ -828,11 +841,11 @@ * @return The number of bytes written into the C string, without the * terminating zero */ - (size_t)getCString: (char *)cString maxLength: (size_t)maxLength - encoding: (of_string_encoding_t)encoding; + encoding: (OFStringEncoding)encoding; /** * @brief Writes the OFString into the specified C string with the specified * encoding, replacing characters that cannot be represented in the * specified encoding with a question mark. @@ -844,11 +857,11 @@ * @return The number of bytes written into the C string, without the * terminating zero */ - (size_t)getLossyCString: (char *)cString maxLength: (size_t)maxLength - encoding: (of_string_encoding_t)encoding; + encoding: (OFStringEncoding)encoding; /** * @brief Returns the OFString as a C string in the specified encoding. * * The result is valid until the autorelease pool is released. If you want to @@ -856,11 +869,11 @@ * copy it. * * @param encoding The encoding for the C string * @return The OFString as a C string in the specified encoding */ -- (const char *)cStringWithEncoding: (of_string_encoding_t)encoding +- (const char *)cStringWithEncoding: (OFStringEncoding)encoding OF_RETURNS_INNER_POINTER; /** * @brief Returns the OFString as a C string in the specified encoding, * replacing characters that cannot be represented in the specified @@ -871,130 +884,120 @@ * copy it. * * @param encoding The encoding for the C string * @return The OFString as a C string in the specified encoding */ -- (const char *)lossyCStringWithEncoding: (of_string_encoding_t)encoding +- (const char *)lossyCStringWithEncoding: (OFStringEncoding)encoding OF_RETURNS_INNER_POINTER; /** * @brief Returns the number of bytes the string needs in the specified * encoding. * * @param encoding The encoding for the string * @return The number of bytes the string needs in the specified encoding. */ -- (size_t)cStringLengthWithEncoding: (of_string_encoding_t)encoding; +- (size_t)cStringLengthWithEncoding: (OFStringEncoding)encoding; + +/** + * @brief Compares the string to another string. + * + * @param string The string to compare the string to + * @return The result of the comparison + */ +- (OFComparisonResult)compare: (OFString *)string; /** - * @brief Compares the OFString to another OFString without caring about the - * case. + * @brief Compares the string to another string without caring about the case. * - * @param otherString A string to compare with - * @return An of_comparison_result_t + * @param string The string to compare the string to + * @return The result of the comparison */ -- (of_comparison_result_t)caseInsensitiveCompare: (OFString *)otherString; +- (OFComparisonResult)caseInsensitiveCompare: (OFString *)string; /** * @brief Returns the Unicode character at the specified index. * * @param index The index of the Unicode character to return * @return The Unicode character at the specified index */ -- (of_unichar_t)characterAtIndex: (size_t)index; +- (OFUnichar)characterAtIndex: (size_t)index; /** * @brief Copies the Unicode characters in the specified range to the specified * buffer. * * @param buffer The buffer to store the Unicode characters * @param range The range of the Unicode characters to copy */ -- (void)getCharacters: (of_unichar_t *)buffer - inRange: (of_range_t)range; +- (void)getCharacters: (OFUnichar *)buffer inRange: (OFRange)range; /** * @brief Returns the range of the first occurrence of the string. * * @param string The string to search * @return The range of the first occurrence of the string or a range with - * `OF_NOT_FOUND` as start position if it was not found + * `OFNotFound` as start position if it was not found */ -- (of_range_t)rangeOfString: (OFString *)string; +- (OFRange)rangeOfString: (OFString *)string; /** * @brief Returns the range of the string. * * @param string The string to search - * @param options Options modifying search behavior.@n - * Possible values are: - * Value | Description - * -----------------------------|------------------------------- - * `OF_STRING_SEARCH_BACKWARDS` | Search backwards in the string + * @param options Options modifying search behavior * @return The range of the first occurrence of the string or a range with - * `OF_NOT_FOUND` as start position if it was not found + * `OFNotFound` as start position if it was not found */ -- (of_range_t)rangeOfString: (OFString *)string - options: (int)options; +- (OFRange)rangeOfString: (OFString *)string + options: (OFStringSearchOptions)options; /** * @brief Returns the range of the string in the specified range. * * @param string The string to search - * @param options Options modifying search behaviour.@n - * Possible values are: - * Value | Description - * -----------------------------|------------------------------- - * `OF_STRING_SEARCH_BACKWARDS` | Search backwards in the string + * @param options Options modifying search behaviour * @param range The range in which to search * @return The range of the first occurrence of the string or a range with - * `OF_NOT_FOUND` as start position if it was not found + * `OFNotFound` as start position if it was not found */ -- (of_range_t)rangeOfString: (OFString *)string - options: (int)options - range: (of_range_t)range; +- (OFRange)rangeOfString: (OFString *)string + options: (OFStringSearchOptions)options + range: (OFRange)range; /** * @brief Returns the index of the first character from the set. * * @param characterSet The set of characters to search for * @return The index of the first occurrence of a character from the set or - * `OF_NOT_FOUND` if it was not found + * `OFNotFound` if it was not found */ - (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet; /** * @brief Returns the index of the first character from the set. * * @param characterSet The set of characters to search for - * @param options Options modifying search behaviour.@n - * Possible values are: - * Value | Description - * -----------------------------|------------------------------- - * `OF_STRING_SEARCH_BACKWARDS` | Search backwards in the string + * @param options Options modifying search behaviour * @return The index of the first occurrence of a character from the set or - * `OF_NOT_FOUND` if it was not found + * `OFNotFound` if it was not found */ - (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet - options: (int)options; + options: (OFStringSearchOptions)options; /** * @brief Returns the index of the first character from the set. * * @param characterSet The set of characters to search for - * @param options Options modifying search behaviour.@n - * Possible values are: - * Value | Description - * -----------------------------|------------------------------- - * `OF_STRING_SEARCH_BACKWARDS` | Search backwards in the string + * @param options Options modifying search behaviour * @param range The range in which to search * @return The index of the first occurrence of a character from the set or - * `OF_NOT_FOUND` if it was not found + * `OFNotFound` if it was not found */ - (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet - options: (int)options - range: (of_range_t)range; + options: (OFStringSearchOptions)options + range: (OFRange)range; /** * @brief Returns whether the string contains the specified string. * * @param string The string to search @@ -1022,11 +1025,11 @@ * @brief Creates a substring with the specified range. * * @param range The range of the substring * @return The substring as a new autoreleased OFString */ -- (OFString *)substringWithRange: (of_range_t)range; +- (OFString *)substringWithRange: (OFRange)range; /** * @brief The value of the string in the specified base as a `long long`. * * Leading and trailing whitespaces are ignored. @@ -1123,11 +1126,11 @@ * @return A new string with the occurrences of the specified string replaced */ - (OFString *)stringByReplacingOccurrencesOfString: (OFString *)string withString: (OFString *)replacement options: (int)options - range: (of_range_t)range; + range: (OFRange)range; /** * @brief Checks whether the string has the specified prefix. * * @param prefix The prefix to check for @@ -1156,20 +1159,16 @@ /** * @brief Separates the string into an array of strings, split by the specified * delimiter. * * @param delimiter The delimiter for separating - * @param options Options according to which the string should be separated.@n - * Possible values are: - * Value | Description - * -----------------------|---------------------- - * `OF_STRING_SKIP_EMPTY` | Skip empty components + * @param options Options according to which the string should be separated * @return An autoreleased OFArray with the separated string */ - (OFArray OF_GENERIC(OFString *) *) componentsSeparatedByString: (OFString *)delimiter - options: (int)options; + options: (OFStringSeparationOptions)options; /** * @brief Separates the string into an array of strings, split by characters in * the specified set. * @@ -1182,20 +1181,16 @@ /** * @brief Separates the string into an array of strings, split by characters in * the specified set. * * @param characterSet The character set for separating - * @param options Options according to which the string should be separated.@n - * Possible values are: - * Value | Description - * -----------------------|---------------------- - * `OF_STRING_SKIP_EMPTY` | Skip empty components + * @param options Options according to which the string should be separated * @return An autoreleased OFArray with the separated string */ - (OFArray OF_GENERIC(OFString *) *) componentsSeparatedByCharactersInSet: (OFCharacterSet *)characterSet - options: (int)options; + options: (OFStringSeparationOptions)options; /** * @brief Returns the string in UTF-16 encoding with the specified byte order. * * The result is valid until the autorelease pool is released. If you want to @@ -1203,11 +1198,11 @@ * copy it. * * @param byteOrder The byte order for the UTF-16 encoding * @return The string in UTF-16 encoding with the specified byte order */ -- (const of_char16_t *)UTF16StringWithByteOrder: (of_byte_order_t)byteOrder +- (const OFChar16 *)UTF16StringWithByteOrder: (OFByteOrder)byteOrder OF_RETURNS_INNER_POINTER; /** * @brief Returns the string in UTF-32 encoding with the specified byte order. * @@ -1216,20 +1211,20 @@ * copy it. * * @param byteOrder The byte order for the UTF-32 encoding * @return The string in UTF-32 encoding with the specified byte order */ -- (const of_char32_t *)UTF32StringWithByteOrder: (of_byte_order_t)byteOrder +- (const OFChar32 *)UTF32StringWithByteOrder: (OFByteOrder)byteOrder OF_RETURNS_INNER_POINTER; /** * @brief Returns the string as OFData with the specified encoding. * * @param encoding The encoding to use for the returned OFData * @return The string as OFData with the specified encoding */ -- (OFData *)dataWithEncoding: (of_string_encoding_t)encoding; +- (OFData *)dataWithEncoding: (OFStringEncoding)encoding; # ifdef OF_HAVE_FILES /** * @brief Writes the string into the specified file using UTF-8 encoding. * @@ -1242,12 +1237,11 @@ * encoding. * * @param path The path of the file to write to * @param encoding The encoding to use to write the string into the file */ -- (void)writeToFile: (OFString *)path - encoding: (of_string_encoding_t)encoding; +- (void)writeToFile: (OFString *)path encoding: (OFStringEncoding)encoding; # endif /** * @brief Writes the string to the specified URL using UTF-8 encoding. * @@ -1259,43 +1253,61 @@ * @brief Writes the string to the specified URL using the specified encoding. * * @param URL The URL to write to * @param encoding The encoding to use to write the string to the URL */ -- (void)writeToURL: (OFURL *)URL - encoding: (of_string_encoding_t)encoding; +- (void)writeToURL: (OFURL *)URL encoding: (OFStringEncoding)encoding; # ifdef OF_HAVE_BLOCKS /** * Enumerates all lines in the receiver using the specified block. * * @brief block The block to call for each line */ -- (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block; +- (void)enumerateLinesUsingBlock: (OFStringLineEnumerationBlock)block; # endif @end #endif #ifdef __cplusplus extern "C" { #endif -extern of_string_encoding_t of_string_parse_encoding(OFString *); -extern OFString *_Nullable of_string_name_of_encoding(of_string_encoding_t); -extern size_t of_string_utf8_encode(of_unichar_t, char *); -extern ssize_t of_string_utf8_decode(const char *, size_t, of_unichar_t *); -extern size_t of_string_utf16_length(const of_char16_t *); -extern size_t of_string_utf32_length(const of_char32_t *); +/** + * @brief Parses the specified string encoding name and returns the + * OFStringEncoding for it. + * + * Throws @ref OFInvalidArgumentException if the specified name is not a valid + * encoding name. + * + * @param name The name to parse as a string encoding + * @return The OFStringEncoding for the specified name + */ +extern OFStringEncoding OFStringEncodingParseName(OFString *name); + +/** + * @brief Returns the name of the specified OFStringEncoding. + * + * @param encoding The encoding for which to return the name + * @return The name of the specified OFStringEncoding + */ +extern OFString *_Nullable OFStringEncodingName(OFStringEncoding encoding); + +extern char *_Nullable OFStrDup(const char *_Nonnull); +extern size_t OFUTF8StringEncode(OFUnichar, char *); +extern ssize_t OFUTF8StringDecode(const char *, size_t, OFUnichar *); +extern size_t OFUTF16StringLength(const OFChar16 *); +extern size_t OFUTF32StringLength(const OFChar32 *); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END #include "OFConstantString.h" #include "OFMutableString.h" #ifdef __OBJC__ -# import "OFString+CryptoHashing.h" +# import "OFString+CryptographicHashing.h" # import "OFString+JSONParsing.h" # ifdef OF_HAVE_FILES # import "OFString+PathAdditions.h" # endif # import "OFString+PropertyListParsing.h"