ObjFW
|
00001 /* 00002 * Copyright (c) 2008, 2009, 2010, 2011, 2012 00003 * Jonathan Schleifer <js@webkeks.org> 00004 * 00005 * All rights reserved. 00006 * 00007 * This file is part of ObjFW. It may be distributed under the terms of the 00008 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in 00009 * the packaging of this file. 00010 * 00011 * Alternatively, it may be distributed under the terms of the GNU General 00012 * Public License, either version 2 or 3, which can be found in the file 00013 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this 00014 * file. 00015 */ 00016 00017 #ifndef __STDC_LIMIT_MACROS 00018 # define __STDC_LIMIT_MACROS 00019 #endif 00020 #ifndef __STDC_CONSTANT_MACROS 00021 # define __STDC_CONSTANT_MACROS 00022 #endif 00023 00024 #include <stdarg.h> 00025 #include <inttypes.h> 00026 00027 #import "OFObject.h" 00028 #import "OFSerialization.h" 00029 #import "OFJSONEncoding.h" 00030 00031 #import "macros.h" 00032 00033 @class OFConstantString; 00034 00035 typedef uint32_t of_unichar_t; 00036 00040 typedef enum of_string_encoding_t { 00041 OF_STRING_ENCODING_UTF_8, 00042 OF_STRING_ENCODING_ASCII, 00043 OF_STRING_ENCODING_ISO_8859_1, 00044 OF_STRING_ENCODING_ISO_8859_15, 00045 OF_STRING_ENCODING_WINDOWS_1252, 00046 OF_STRING_ENCODING_AUTODETECT = 0xFF 00047 } of_string_encoding_t; 00048 00049 /* FIXME */ 00050 #define OF_STRING_ENCODING_NATIVE OF_STRING_ENCODING_UTF_8 00051 00052 #ifdef OF_HAVE_BLOCKS 00053 typedef void (^of_string_line_enumeration_block_t)(OFString *line, BOOL *stop); 00054 #endif 00055 00056 #ifdef __cplusplus 00057 extern "C" { 00058 #endif 00059 extern int of_string_check_utf8(const char*, size_t, size_t*); 00060 extern size_t of_string_unicode_to_utf8(of_unichar_t, char*); 00061 extern size_t of_string_utf8_to_unicode(const char*, size_t, of_unichar_t*); 00062 extern size_t of_string_position_to_index(const char*, size_t); 00063 extern size_t of_string_index_to_position(const char*, size_t, size_t); 00064 extern size_t of_unicode_string_length(const of_unichar_t*); 00065 extern size_t of_utf16_string_length(const uint16_t*); 00066 #ifdef __cplusplus 00067 } 00068 #endif 00069 00070 @class OFArray; 00071 @class OFURL; 00072 00082 @interface OFString: OFObject <OFCopying, OFMutableCopying, OFComparing, 00083 OFSerialization, OFJSON> 00084 #ifdef OF_HAVE_PROPERTIES 00085 @property (readonly) size_t length; 00086 #endif 00087 00093 + string; 00094 00101 + stringWithUTF8String: (const char*)UTF8String; 00102 00111 + stringWithUTF8String: (const char*)UTF8String 00112 length: (size_t)UTF8StringLength; 00113 00121 + stringWithCString: (const char*)cString 00122 encoding: (of_string_encoding_t)encoding; 00123 00133 + stringWithCString: (const char*)cString 00134 encoding: (of_string_encoding_t)encoding 00135 length: (size_t)cStringLength; 00136 00143 + stringWithString: (OFString*)string; 00144 00151 + stringWithUnicodeString: (const of_unichar_t*)string; 00152 00161 + stringWithUnicodeString: (const of_unichar_t*)string 00162 byteOrder: (of_endianess_t)byteOrder; 00163 00172 + stringWithUnicodeString: (const of_unichar_t*)string 00173 length: (size_t)length; 00174 00184 + stringWithUnicodeString: (const of_unichar_t*)string 00185 byteOrder: (of_endianess_t)byteOrder 00186 length: (size_t)length; 00187 00194 + stringWithUTF16String: (const uint16_t*)string; 00195 00204 + stringWithUTF16String: (const uint16_t*)string 00205 byteOrder: (of_endianess_t)byteOrder; 00206 00215 + stringWithUTF16String: (const uint16_t*)string 00216 length: (size_t)length; 00217 00228 + stringWithUTF16String: (const uint16_t*)string 00229 byteOrder: (of_endianess_t)byteOrder 00230 length: (size_t)length; 00231 00241 + stringWithFormat: (OFConstantString*)format, ...; 00242 00249 + stringWithPath: (OFString*)firstComponent, ...; 00250 00258 + stringWithContentsOfFile: (OFString*)path; 00259 00268 + stringWithContentsOfFile: (OFString*)path 00269 encoding: (of_string_encoding_t)encoding; 00270 00283 + stringWithContentsOfURL: (OFURL*)URL; 00284 00293 + stringWithContentsOfURL: (OFURL*)URL 00294 encoding: (of_string_encoding_t)encoding; 00295 00303 - initWithUTF8String: (const char*)UTF8String; 00304 00313 - initWithUTF8String: (const char*)UTF8String 00314 length: (size_t)UTF8StringLength; 00315 00324 - initWithCString: (const char*)cString 00325 encoding: (of_string_encoding_t)encoding; 00326 00336 - initWithCString: (const char*)cString 00337 encoding: (of_string_encoding_t)encoding 00338 length: (size_t)cStringLength; 00339 00346 - initWithString: (OFString*)string; 00347 00354 - initWithUnicodeString: (const of_unichar_t*)string; 00355 00364 - initWithUnicodeString: (const of_unichar_t*)string 00365 byteOrder: (of_endianess_t)byteOrder; 00366 00375 - initWithUnicodeString: (const of_unichar_t*)string 00376 length: (size_t)length; 00377 00388 - initWithUnicodeString: (const of_unichar_t*)string 00389 byteOrder: (of_endianess_t)byteOrder 00390 length: (size_t)length; 00391 00398 - initWithUTF16String: (const uint16_t*)string; 00399 00408 - initWithUTF16String: (const uint16_t*)string 00409 byteOrder: (of_endianess_t)byteOrder; 00410 00419 - initWithUTF16String: (const uint16_t*)string 00420 length: (size_t)length; 00421 00432 - initWithUTF16String: (const uint16_t*)string 00433 byteOrder: (of_endianess_t)byteOrder 00434 length: (size_t)length; 00435 00445 - initWithFormat: (OFConstantString*)format, ...; 00446 00457 - initWithFormat: (OFConstantString*)format 00458 arguments: (va_list)arguments; 00459 00467 - initWithPath: (OFString*)firstComponent, ...; 00468 00477 - initWithPath: (OFString*)firstComponent 00478 arguments: (va_list)arguments; 00479 00487 - initWithContentsOfFile: (OFString*)path; 00488 00497 - initWithContentsOfFile: (OFString*)path 00498 encoding: (of_string_encoding_t)encoding; 00499 00513 - initWithContentsOfURL: (OFURL*)URL; 00514 00523 - initWithContentsOfURL: (OFURL*)URL 00524 encoding: (of_string_encoding_t)encoding; 00525 00535 - (const char*)UTF8String; 00536 00547 - (const char*)cStringWithEncoding: (of_string_encoding_t)encoding;; 00548 00554 - (size_t)length; 00555 00561 - (size_t)UTF8StringLength; 00562 00570 - (size_t)cStringLengthWithEncoding: (of_string_encoding_t)encoding; 00571 00579 - (of_comparison_result_t)caseInsensitiveCompare: (OFString*)otherString; 00580 00587 - (of_unichar_t)characterAtIndex: (size_t)index; 00588 00596 - (void)getCharacters: (of_unichar_t*)buffer 00597 inRange: (of_range_t)range; 00598 00606 - (size_t)indexOfFirstOccurrenceOfString: (OFString*)string; 00607 00615 - (size_t)indexOfLastOccurrenceOfString: (OFString*)string; 00616 00623 - (BOOL)containsString: (OFString*)string; 00624 00631 - (OFString*)substringWithRange: (of_range_t)range; 00632 00639 - (OFString*)stringByAppendingString: (OFString*)string; 00640 00647 - (OFString*)stringByPrependingString: (OFString*)string; 00648 00657 - (OFString*)stringByReplacingOccurrencesOfString: (OFString*)string 00658 withString: (OFString*)replacement; 00659 00669 - (OFString*)stringByReplacingOccurrencesOfString: (OFString*)string 00670 withString: (OFString*)replacement 00671 inRange: (of_range_t)range; 00672 00678 - (OFString*)uppercaseString; 00679 00685 - (OFString*)lowercaseString; 00686 00692 - (OFString*)stringByDeletingLeadingWhitespaces; 00693 00699 - (OFString*)stringByDeletingTrailingWhitespaces; 00700 00707 - (OFString*)stringByDeletingEnclosingWhitespaces; 00708 00715 - (BOOL)hasPrefix: (OFString*)prefix; 00716 00723 - (BOOL)hasSuffix: (OFString*)suffix; 00724 00731 - (OFArray*)componentsSeparatedByString: (OFString*)delimiter; 00732 00738 - (OFArray*)pathComponents; 00739 00745 - (OFString*)lastPathComponent; 00746 00752 - (OFString*)stringByDeletingLastPathComponent; 00753 00767 - (intmax_t)decimalValue; 00768 00782 - (uintmax_t)hexadecimalValue; 00783 00792 - (float)floatValue; 00793 00802 - (double)doubleValue; 00803 00813 - (const of_unichar_t*)unicodeString; 00814 00824 - (const uint16_t*)UTF16String; 00825 00831 - (void)writeToFile: (OFString*)path; 00832 00833 #ifdef OF_HAVE_BLOCKS 00834 00839 - (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block; 00840 #endif 00841 @end 00842 00843 #import "OFConstantString.h" 00844 #import "OFMutableString.h" 00845 #import "OFString+Hashing.h" 00846 #import "OFString+JSONValue.h" 00847 #import "OFString+Serialization.h" 00848 #import "OFString+URLEncoding.h" 00849 #import "OFString+XMLEscaping.h" 00850 #import "OFString+XMLUnescaping.h"