00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <stdio.h>
00018 #include <stdarg.h>
00019
00020 #import "OFObject.h"
00021
00022 typedef uint32_t of_unichar_t;
00023
00024 enum of_string_encoding {
00025 OF_STRING_ENCODING_UTF_8,
00026 OF_STRING_ENCODING_ISO_8859_1,
00027 OF_STRING_ENCODING_ISO_8859_15,
00028 OF_STRING_ENCODING_WINDOWS_1252
00029 };
00030
00031 extern int of_string_check_utf8(const char*, size_t);
00032 extern size_t of_string_unicode_to_utf8(of_unichar_t, char*);
00033 extern size_t of_string_utf8_to_unicode(const char*, size_t, of_unichar_t*);
00034 extern size_t of_string_position_to_index(const char*, size_t);
00035 extern size_t of_string_index_to_position(const char*, size_t, size_t);
00036
00037 @class OFArray;
00038
00042 @interface OFString: OFObject <OFCopying, OFMutableCopying, OFComparing>
00043 {
00044 char *string;
00045 unsigned int length;
00046 #if defined(OF_APPLE_RUNTIME) && __LP64__
00047 int _unused;
00048 #endif
00049 BOOL isUTF8;
00050 }
00051
00055 + string;
00056
00063 + stringWithCString: (const char*)str;
00064
00072 + stringWithCString: (const char*)str
00073 encoding: (enum of_string_encoding)encoding;
00074
00084 + stringWithCString: (const char*)str
00085 encoding: (enum of_string_encoding)encoding
00086 length: (size_t)len;
00087
00096 + stringWithCString: (const char*)str
00097 length: (size_t)len;
00098
00106 + stringWithFormat: (OFString*)fmt, ...;
00107
00114 + stringWithPath: (OFString*)first, ...;
00115
00122 + stringWithString: (OFString*)str;
00123
00130 + stringWithContentsOfFile: (OFString*)path;
00131
00140 + stringWithContentsOfFile: (OFString*)path
00141 encoding: (enum of_string_encoding)encoding;
00142
00149 - initWithCString: (const char*)str;
00150
00159 - initWithCString: (const char*)str
00160 encoding: (enum of_string_encoding)encoding;
00161
00171 - initWithCString: (const char*)str
00172 encoding: (enum of_string_encoding)encoding
00173 length: (size_t)len;
00174
00183 - initWithCString: (const char*)str
00184 length: (size_t)len;
00185
00193 - initWithFormat: (OFString*)fmt, ...;
00194
00203 - initWithFormat: (OFString*)fmt
00204 arguments: (va_list)args;
00205
00213 - initWithPath: (OFString*)first, ...;
00214
00223 - initWithPath: (OFString*)first
00224 arguments: (va_list)args;
00225
00232 - initWithString: (OFString*)str;
00233
00241 - initWithContentsOfFile: (OFString*)path;
00242
00251 - initWithContentsOfFile: (OFString*)path
00252 encoding: (enum of_string_encoding)encoding;
00253
00257 - (const char*)cString;
00258
00262 - (size_t)length;
00263
00267 - (size_t)cStringLength;
00268
00270 - (BOOL)isUTF8;
00272
00279 - (of_comparison_result_t)caseInsensitiveCompare: (OFString*)str;
00280
00285 - (of_unichar_t)characterAtIndex: (size_t)index;
00286
00292 - (size_t)indexOfFirstOccurrenceOfString: (OFString*)str;
00293
00299 - (size_t)indexOfLastOccurrenceOfString: (OFString*)str;
00300
00307 - (OFString*)substringFromIndex: (size_t)start
00308 toIndex: (size_t)end;
00309
00314 - (OFString*)substringWithRange: (of_range_t)range;
00315
00322 - (OFString*)stringByAppendingString: (OFString*)str;
00323
00330 - (BOOL)hasPrefix: (OFString*)prefix;
00331
00338 - (BOOL)hasSuffix: (OFString*)suffix;
00339
00346 - (OFArray*)componentsSeparatedByString: (OFString*)delimiter;
00347
00354 - (intmax_t)decimalValue;
00355
00362 - (uintmax_t)hexadecimalValue;
00363
00371 - (of_unichar_t*)unicodeString;
00372
00378 - (void)writeToFile: (OFString*)path;
00379 @end
00380
00381 #import "OFConstantString.h"
00382 #import "OFMutableString.h"
00383 #import "OFString+Hashing.h"
00384 #import "OFString+URLEncoding.h"
00385 #import "OFString+XMLEscaping.h"
00386 #import "OFString+XMLUnescaping.h"