ObjFW  Diff

Differences From Artifact [70879a2fc2]:

To Artifact [47bba28c27]:

  • File src/OFString.h — part of check-in [7a488c3062] at 2018-03-11 00:37:56 on branch trunk — OFString: Move path handling into a category

    This is the first step to have different versions of those for different
    operating systems, rather than #ifdefs everywhere.

    This also has the nice side-effect of not having one implementation in
    OFString and another one in OFString_UTF8 anymore. The one in OFString
    was a generic version, while the one in OFString_UTF8 was one optimized
    for UTF-8 strings. Now only the version optimized for UTF-8 strings
    exists, as this is by far the most common string implementation used,
    and the overhead of converting from something else to UTF-8 is not more
    than converting to UTF-32. (user: js, size: 40414) [annotate] [blame] [check-ins using]


134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
@property (readonly, nonatomic) const char *UTF8String OF_RETURNS_INNER_POINTER;

/*!
 * @brief The number of bytes the string needs in UTF-8 encoding.
 */
@property (readonly, nonatomic) size_t UTF8StringLength;

/*!
 * @brief The components of the string when interpreted as a path.
 */
@property (readonly, nonatomic) OFArray OF_GENERIC(OFString *) *pathComponents;

/*!
 * @brief The last path component of the string when interpreted as a path.
 */
@property (readonly, nonatomic) OFString *lastPathComponent;

/*!
 * @brief The file extension of string when interpreted as a path.
 */
@property (readonly, nonatomic) OFString *pathExtension;

/*!
 * @brief The string in uppercase.
 */
@property (readonly, nonatomic) OFString *uppercaseString;

/*!
 * @brief The string in lowercase.







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







134
135
136
137
138
139
140















141
142
143
144
145
146
147
@property (readonly, nonatomic) const char *UTF8String OF_RETURNS_INNER_POINTER;

/*!
 * @brief The number of bytes the string needs in UTF-8 encoding.
 */
@property (readonly, nonatomic) size_t UTF8StringLength;
















/*!
 * @brief The string in uppercase.
 */
@property (readonly, nonatomic) OFString *uppercaseString;

/*!
 * @brief The string in lowercase.
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
 * @brief The double value of the string as a double.
 *
 * If the string contains any non-number characters, an
 * OFInvalidEncodingException is thrown.
 */
@property (readonly, nonatomic) double doubleValue;

/*!
 * @brief The directory name of the string when interpreted as a path.
 */
@property (readonly, nonatomic) OFString *stringByDeletingLastPathComponent;

/*!
 * @brief The string with the file extension of the path removed.
 */
@property (readonly, nonatomic) OFString *stringByDeletingPathExtension;

/*!
 * @brief The string interpreted as a path with relative sub paths resolved.
 */
@property (readonly, nonatomic) OFString *stringByStandardizingPath;

/*!
 * @brief The string interpreted as a URL path with relative sub paths resolved.
 *
 * This works similar to @ref stringByStandardizingPath, but is intended for
 * standardization of paths that are part of a URL.
 */
@property (readonly, nonatomic) OFString *stringByStandardizingURLPath;







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







208
209
210
211
212
213
214















215
216
217
218
219
220
221
 * @brief The double value of the string as a double.
 *
 * If the string contains any non-number characters, an
 * OFInvalidEncodingException is thrown.
 */
@property (readonly, nonatomic) double doubleValue;
















/*!
 * @brief The string interpreted as a URL path with relative sub paths resolved.
 *
 * This works similar to @ref stringByStandardizingPath, but is intended for
 * standardization of paths that are part of a URL.
 */
@property (readonly, nonatomic) OFString *stringByStandardizingURLPath;
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
 * @param encoding The encoding to assume
 * @return A new autoreleased OFString
 */
+ (instancetype)stringWithContentsOfURL: (OFURL *)URL
			       encoding: (of_string_encoding_t)encoding;
#endif

/*!
 * @brief Creates a path from the specified path components.
 *
 * @param components An array of components for the path
 * @return A new autoreleased OFString
 */
+ (OFString *)pathWithComponents: (OFArray OF_GENERIC(OFString *) *)components;

/*!
 * @brief Initializes an already allocated OFString from a UTF-8 encoded C
 *	  string.
 *
 * @param UTF8String A UTF-8 encoded C string to initialize the OFString with
 * @return An initialized OFString
 */







<
<
<
<
<
<
<
<







542
543
544
545
546
547
548








549
550
551
552
553
554
555
 * @param encoding The encoding to assume
 * @return A new autoreleased OFString
 */
+ (instancetype)stringWithContentsOfURL: (OFURL *)URL
			       encoding: (of_string_encoding_t)encoding;
#endif









/*!
 * @brief Initializes an already allocated OFString from a UTF-8 encoded C
 *	  string.
 *
 * @param UTF8String A UTF-8 encoded C string to initialize the OFString with
 * @return An initialized OFString
 */
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
 * @param format A format string which generates the string to append
 * @param arguments The arguments used in the format string
 * @return A new, autoreleased OFString with the specified format appended
 */
- (OFString *)stringByAppendingFormat: (OFConstantString *)format
			    arguments: (va_list)arguments;

/*!
 * @brief Creates a new string by appending a path component.
 *
 * @param component The path component to append
 * @return A new, autoreleased OFString with the path component appended
 */
- (OFString *)stringByAppendingPathComponent: (OFString *)component;

/*!
 * @brief Creates a new string by appending a URL path component.
 *
 * @param component The URL path component to append
 * @return A new, autoreleased OFString with the URL path component appended
 */
- (OFString *)stringByAppendingURLPathComponent: (OFString *)component;







<
<
<
<
<
<
<
<







1034
1035
1036
1037
1038
1039
1040








1041
1042
1043
1044
1045
1046
1047
 * @param format A format string which generates the string to append
 * @param arguments The arguments used in the format string
 * @return A new, autoreleased OFString with the specified format appended
 */
- (OFString *)stringByAppendingFormat: (OFConstantString *)format
			    arguments: (va_list)arguments;









/*!
 * @brief Creates a new string by appending a URL path component.
 *
 * @param component The URL path component to append
 * @return A new, autoreleased OFString with the URL path component appended
 */
- (OFString *)stringByAppendingURLPathComponent: (OFString *)component;
1261
1262
1263
1264
1265
1266
1267



1268
1269
1270
1271
1272
1273
1274

OF_ASSUME_NONNULL_END

#import "OFConstantString.h"
#import "OFMutableString.h"
#import "OFString+CryptoHashing.h"
#import "OFString+JSONValue.h"



#import "OFString+Serialization.h"
#import "OFString+URLEncoding.h"
#import "OFString+XMLEscaping.h"
#import "OFString+XMLUnescaping.h"

#if !defined(NSINTEGER_DEFINED) && !__has_feature(modules)
/*







>
>
>







1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231

OF_ASSUME_NONNULL_END

#import "OFConstantString.h"
#import "OFMutableString.h"
#import "OFString+CryptoHashing.h"
#import "OFString+JSONValue.h"
#ifdef OF_HAVE_FILES
# import "OFString+PathAdditions.h"
#endif
#import "OFString+Serialization.h"
#import "OFString+URLEncoding.h"
#import "OFString+XMLEscaping.h"
#import "OFString+XMLUnescaping.h"

#if !defined(NSINTEGER_DEFINED) && !__has_feature(modules)
/*