17 #ifndef __STDC_LIMIT_MACROS
18 # define __STDC_LIMIT_MACROS
20 #ifndef __STDC_CONSTANT_MACROS
21 # define __STDC_CONSTANT_MACROS
28 #import "OFSerialization.h"
29 #import "OFJSONRepresentation.h"
30 #import "OFMessagePackRepresentation.h"
32 OF_ASSUME_NONNULL_BEGIN
38 #if defined(__cplusplus) && __cplusplus >= 201103L
39 typedef char16_t of_char16_t;
40 typedef char32_t of_char32_t;
42 typedef uint_least16_t of_char16_t;
43 typedef uint_least32_t of_char32_t;
45 typedef of_char32_t of_unichar_t;
68 OF_STRING_SEARCH_BACKWARDS = 1,
69 OF_STRING_SKIP_EMPTY = 2
83 @class OFArray OF_GENERIC(ObjectType);
93 #ifdef OF_HAVE_PROPERTIES
94 @property (readonly)
size_t length;
102 + (instancetype)
string;
110 + (instancetype)stringWithUTF8String: (
const char*)
UTF8String;
120 + (instancetype)stringWithUTF8String: (
const char*)
UTF8String
132 + (instancetype)stringWithUTF8StringNoCopy: (
char*)
UTF8String
133 freeWhenDone: (bool)freeWhenDone;
142 + (instancetype)stringWithCString: (
const char*)cString
154 + (instancetype)stringWithCString: (
const char*)cString
156 length: (
size_t)cStringLength;
174 + (instancetype)stringWithCharacters: (
const of_unichar_t*)
characters
183 + (instancetype)stringWithUTF16String: (
const of_char16_t*)
string;
193 + (instancetype)stringWithUTF16String: (
const of_char16_t*)
string
204 + (instancetype)stringWithUTF16String: (
const of_char16_t*)
string
217 + (instancetype)stringWithUTF16String: (
const of_char16_t*)
string
227 + (instancetype)stringWithUTF32String: (
const of_char32_t*)
string;
237 + (instancetype)stringWithUTF32String: (
const of_char32_t*)
string
248 + (instancetype)stringWithUTF32String: (
const of_char32_t*)
string
261 + (instancetype)stringWithUTF32String: (
const of_char32_t*)
string
284 + (instancetype)stringWithContentsOfFile: (
OFString*)path;
294 + (instancetype)stringWithContentsOfFile: (
OFString*)path
298 #if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS)
311 + (instancetype)stringWithContentsOfURL: (
OFURL*)URL;
321 + (instancetype)stringWithContentsOfURL: (
OFURL*)URL
340 - initWithUTF8String: (
const char*)
UTF8String;
365 freeWhenDone: (
bool)freeWhenDone;
375 - initWithCString: (
const char*)cString
387 - initWithCString: (
const char*)cString
389 length: (size_t)cStringLength;
397 - initWithString: (
OFString*)
string;
407 - initWithCharacters: (
const of_unichar_t*)
characters
416 - initWithUTF16String: (
const of_char16_t*)
string;
426 - initWithUTF16String: (
const of_char16_t*)
string
437 - initWithUTF16String: (
const of_char16_t*)
string
450 - initWithUTF16String: (
const of_char16_t*)
string
460 - initWithUTF32String: (
const of_char32_t*)
string;
470 - initWithUTF32String: (
const of_char32_t*)
string
481 - initWithUTF32String: (
const of_char32_t*)
string
494 - initWithUTF32String: (
const of_char32_t*)
string
520 arguments: (va_list)arguments;
530 - initWithContentsOfFile: (
OFString*)path;
540 - initWithContentsOfFile: (
OFString*)path
544 #if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS)
558 - initWithContentsOfURL: (
OFURL*)URL;
568 - initWithContentsOfURL: (
OFURL*)URL
583 - (size_t)getCString: (
char*)cString
584 maxLength: (size_t)maxLength
599 - (size_t)getLossyCString: (
char*)cString
600 maxLength: (size_t)maxLength
614 OF_RETURNS_INNER_POINTER;
629 OF_RETURNS_INNER_POINTER;
640 - (
const char*)
UTF8String OF_RETURNS_INNER_POINTER;
680 - (of_unichar_t)characterAtIndex: (
size_t)index;
689 - (void)getCharacters: (of_unichar_t*)buffer
714 options: (int)options;
730 options: (int)options
773 arguments: (va_list)arguments;
816 options: (
int)options
872 - (bool)hasPrefix: (
OFString*)prefix;
880 - (bool)hasSuffix: (
OFString*)suffix;
903 componentsSeparatedByString: (
OFString*)delimiter
904 options: (int)options;
1017 - (
const of_unichar_t*)
characters OF_RETURNS_INNER_POINTER;
1028 - (
const of_char16_t*)
UTF16String OF_RETURNS_INNER_POINTER;
1040 - (
const of_char16_t*)UTF16StringWithByteOrder: (
of_byte_order_t)byteOrder
1041 OF_RETURNS_INNER_POINTER;
1059 - (
const of_char32_t*)
UTF32String OF_RETURNS_INNER_POINTER;
1071 - (
const of_char32_t*)UTF32StringWithByteOrder: (
of_byte_order_t)byteOrder
1072 OF_RETURNS_INNER_POINTER;
1074 #ifdef OF_HAVE_FILES
1080 - (void)writeToFile: (
OFString*)path;
1089 - (void)writeToFile: (
OFString*)path
1093 #ifdef OF_HAVE_BLOCKS
1106 extern size_t of_string_utf8_encode(of_unichar_t,
char*);
1107 extern size_t of_string_utf8_decode(
const char*,
size_t, of_unichar_t*);
1108 extern size_t of_string_utf16_length(
const of_char16_t*);
1109 extern size_t of_string_utf32_length(
const of_char32_t*);
1114 OF_ASSUME_NONNULL_END
1116 #import "OFConstantString.h"
1117 #import "OFMutableString.h"
1118 #import "OFString+Hashing.h"
1119 #import "OFString+JSONValue.h"
1120 #import "OFString+Serialization.h"
1121 #import "OFString+URLEncoding.h"
1122 #import "OFString+XMLEscaping.h"
1125 #ifndef NSINTEGER_DEFINED
A protocol for serializing objects.
Definition: OFSerialization.h:30
double doubleValue()
Returns the double value of the string as a double.
Definition: OFString.m:2287
size_t UTF16StringLength()
Returns the length of the string in UTF-16 characters.
Definition: OFString.m:2385
Definition: OFString.h:60
An abstract class for storing objects in an array.
Definition: OFArray.h:95
of_string_encoding_t
The encoding of a string.
Definition: OFString.h:50
OFArray OF_GENERIC(OFString * pathComponents()
Returns the components of the path.
Definition: OFString.m:1953
OFString * lastPathComponent()
Returns the last component of the path.
Definition: OFString.m:1990
A protocol for comparing objects.
Definition: OFObject.h:933
of_byte_order_t
An enum for storing endianess.
Definition: OFObject.h:53
uintmax_t hexadecimalValue()
Returns the hexadecimal value of the string as an uintmax_t.
Definition: OFString.m:2193
Definition: OFString.h:64
A class for storing constant strings using the @"" literal.
Definition: OFConstantString.h:37
The root class for all other classes inside ObjFW.
Definition: OFObject.h:364
OFString * stringByStandardizingPath()
Returns the path with relative sub paths resolved.
Definition: OFString.m:2125
intmax_t decimalValue()
Returns the decimal value of the string as an intmax_t.
Definition: OFString.m:2138
OFString * stringByDeletingEnclosingWhitespaces()
Creates a new string by deleting leading and trailing whitespaces.
Definition: OFString.m:1824
const of_char32_t * UTF32String()
Returns the string in UTF-32 encoding with native byte order.
Definition: OFString.m:2399
const of_char16_t * UTF16String()
Returns the string in UTF-16 encoding with native byte order.
Definition: OFString.m:2327
Definition: OFString.h:62
A protocol implemented by classes that support encoding to a JSON representation. ...
Definition: OFJSONRepresentation.h:38
A class for handling strings.
Definition: OFString.h:91
Definition: OFString.h:56
const char * UTF8String()
Returns the OFString as a UTF-8 encoded C string.
Definition: OFString.m:1182
of_comparison_result_t
A result of a comparison.
Definition: OFObject.h:41
A protocol implemented by classes that support encoding to a MessagePack representation.
Definition: OFMessagePackRepresentation.h:30
void(^ of_string_line_enumeration_block_t)(OFString *line, bool *stop)
A block for enumerating the lines of a string.
Definition: OFString.h:80
OFString * stringByStandardizingURLPath()
Returns the URL path with relative sub paths resolved.
Definition: OFString.m:2132
Definition: OFString.h:58
Definition: OFString.h:52
A range.
Definition: OFObject.h:65
OFString * uppercaseString()
Returns the string in uppercase.
Definition: OFString.m:1769
size_t length()
Returns the length of the string in Unicode characters.
A protocol for the creation of mutable copies.
Definition: OFObject.h:917
A protocol for the creation of copies.
Definition: OFObject.h:896
const of_unichar_t * characters()
Returns the string as an array of Unicode characters.
Definition: OFString.m:2313
OFString * stringByDeletingLastPathComponent()
Returns the directory name of the path.
Definition: OFString.m:2055
OFString * capitalizedString()
Returns the string capitalized.
Definition: OFString.m:1791
size_t UTF8StringLength()
Returns the number of bytes the string needs in UTF-8 encoding.
Definition: OFString.m:1225
OFString * stringByDeletingLeadingWhitespaces()
Creates a new string by deleting leading whitespaces.
Definition: OFString.m:1802
Definition: OFString.h:54
A class for parsing URLs and accessing parts of it.
Definition: OFURL.h:29
OFString * lowercaseString()
Returns the string in lowercase.
Definition: OFString.m:1780
instancetype string()
Creates a new OFString.
Definition: OFString.m:505
float floatValue()
Returns the float value of the string as a float.
Definition: OFString.m:2261
OFString * stringByDeletingTrailingWhitespaces()
Creates a new string by deleting trailing whitespaces.
Definition: OFString.m:1813
OFString * pathExtension()
Returns the file extension of the path.
Definition: OFString.m:2035
OFString * stringByDeletingPathExtension()
Returns a new string with the file extension of the path removed.
Definition: OFString.m:2093