Mercurial > projects > dstep
comparison dstep/foundation/NSString.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | 89f3c3ef1fd2 |
children | b9de51448c6b |
comparison
equal
deleted
inserted
replaced
15:7ff919f595d5 | 16:19885b43130e |
---|---|
6 */ | 6 */ |
7 module dstep.foundation.NSString; | 7 module dstep.foundation.NSString; |
8 | 8 |
9 import dstep.foundation.NSArray; | 9 import dstep.foundation.NSArray; |
10 import dstep.foundation.NSCharacterSet; | 10 import dstep.foundation.NSCharacterSet; |
11 import dstep.foundation.NSCoder; | |
11 import dstep.foundation.NSData; | 12 import dstep.foundation.NSData; |
12 import dstep.foundation.NSDictionary; | 13 import dstep.foundation.NSDictionary; |
13 import dstep.foundation.NSError; | 14 import dstep.foundation.NSError; |
14 import dstep.foundation.NSLocale; | 15 import dstep.foundation.NSLocale; |
16 import dstep.foundation.NSObjCRuntime; | |
15 import dstep.foundation.NSObject; | 17 import dstep.foundation.NSObject; |
18 import dstep.foundation.NSPathUtilities; | |
16 import dstep.foundation.NSRange; | 19 import dstep.foundation.NSRange; |
17 import dstep.foundation.NSURL; | 20 import dstep.foundation.NSURL; |
18 import dstep.limits; | 21 import dstep.foundation.NSZone; |
22 import dstep.internal.String; | |
23 import dstep.internal.Version; | |
24 import dstep.objc.bridge.Wrapper; | |
19 import dstep.objc.bridge.Bridge; | 25 import dstep.objc.bridge.Bridge; |
20 import dstep.objc.objc : id; | 26 import dstep.objc.objc; |
21 import dstep.stdarg; | |
22 | 27 |
23 import bindings = dstep.foundation.NSString_bindings; | 28 import bindings = dstep.foundation.NSString_bindings; |
24 | 29 |
25 alias ushort unichar; | 30 alias wchar unichar; |
26 alias NSUInteger NSStringCompareOptions; | 31 alias NSUInteger NSStringCompareOptions; |
27 alias NSUInteger NSStringEncoding; | 32 alias NSUInteger NSStringEncoding; |
28 alias NSUInteger NSStringEncodingConversionOptions; | 33 alias NSUInteger NSStringEncodingConversionOptions; |
29 | 34 |
30 const NSString NSParseErrorException; | 35 private |
31 const NSString NSCharacterConversionException; | 36 { |
37 NSString NSParseErrorException_; | |
38 NSString NSCharacterConversionException_; | |
39 } | |
40 | |
41 NSString NSParseErrorException () | |
42 { | |
43 if (NSParseErrorException_) | |
44 return NSParseErrorException_; | |
45 | |
46 return NSParseErrorException_ = new NSString(bindings.NSParseErrorException); | |
47 } | |
48 | |
49 NSString NSCharacterConversionException () | |
50 { | |
51 if (NSCharacterConversionException_) | |
52 return NSCharacterConversionException_; | |
53 | |
54 return NSCharacterConversionException_ = new NSString(bindings.NSCharacterConversionException); | |
55 } | |
32 | 56 |
33 enum | 57 enum |
34 { | 58 { |
35 NSCaseInsensitiveSearch = 1, | 59 NSCaseInsensitiveSearch = 1, |
36 NSLiteralSearch = 2, | 60 NSLiteralSearch = 2, |
73 { | 97 { |
74 NSStringEncodingConversionAllowLossy = 1, | 98 NSStringEncodingConversionAllowLossy = 1, |
75 NSStringEncodingConversionExternalRepresentation = 2 | 99 NSStringEncodingConversionExternalRepresentation = 2 |
76 } | 100 } |
77 | 101 |
78 static this () | 102 const TNSExtendedStringPropertyListParsing = ` |
79 { | 103 |
80 NSParseErrorException = new NSString(bindings.NSParseErrorException); | 104 Object propertyList () |
81 NSCharacterConversionException = new NSString(bindings.NSCharacterConversionException); | 105 { |
82 } | 106 return invokeObjcSelf!(Object, "propertyList"); |
107 } | |
108 | |
109 NSDictionary propertyListFromStringsFileFormat () | |
110 { | |
111 return invokeObjcSelf!(NSDictionary, "propertyListFromStringsFileFormat"); | |
112 } | |
113 `; | |
114 | |
115 const TNSMutableStringExtensionMethods = ` | |
116 | |
117 void insertString (NSString aString, NSUInteger loc) | |
118 { | |
119 return invokeObjcSelf!(void, "insertString:atIndex:", NSString, NSUInteger)(aString, loc); | |
120 } | |
121 | |
122 void deleteCharactersInRange (NSRange range) | |
123 { | |
124 return invokeObjcSelf!(void, "deleteCharactersInRange:", NSRange)(range); | |
125 } | |
126 | |
127 void appendString (NSString aString) | |
128 { | |
129 return invokeObjcSelf!(void, "appendString:", NSString)(aString); | |
130 } | |
131 | |
132 void appendFormat (NSString appendFormat, ...) | |
133 { | |
134 return invokeObjcSelf!(void, "appendFormat:", NSString)(appendFormat); | |
135 } | |
136 | |
137 void setString (NSString aString) | |
138 { | |
139 return invokeObjcSelf!(void, "setString:", NSString)(aString); | |
140 } | |
141 | |
142 NSString initWithCapacity (NSUInteger capacity) | |
143 { | |
144 return invokeObjcSelf!(Object, "initWithCapacity:", NSUInteger)(capacity); | |
145 } | |
146 | |
147 /*this (NSUInteger capacity) | |
148 { | |
149 typeof(this).alloc.initWithCapacity(capacity); | |
150 }*/ | |
151 | |
152 static Object stringWithCapacity (NSUInteger capacity) | |
153 { | |
154 return invokeObjcSuperClass!(Object, "stringWithCapacity:", NSUInteger)(capacity); | |
155 } | |
156 | |
157 NSUInteger replaceOccurrencesOfString (NSString target, NSString replacement, uint options, NSRange searchRange) | |
158 { | |
159 return invokeObjcSelf!(NSUInteger, "replaceOccurrencesOfString:withString:options:range:", NSString, NSString, uint, NSRange)(target, replacement, options, searchRange); | |
160 } | |
161 `; | |
162 | |
163 const TNSStringExtensionMethods = ` | |
164 | |
165 void getCharacters (unichar* buffer) | |
166 { | |
167 return invokeObjcSelf!(void, "getCharacters:", unichar*)(buffer); | |
168 } | |
169 | |
170 void getCharacters (unichar* buffer, NSRange aRange) | |
171 { | |
172 return invokeObjcSelf!(void, "getCharacters:range:", unichar*, NSRange)(buffer, aRange); | |
173 } | |
174 | |
175 NSString substringFromIndex (NSUInteger from) | |
176 { | |
177 return invokeObjcSelf!(NSString, "substringFromIndex:", NSUInteger)(from); | |
178 } | |
179 | |
180 NSString substringToIndex (NSUInteger to) | |
181 { | |
182 return invokeObjcSelf!(NSString, "substringToIndex:", NSUInteger)(to); | |
183 } | |
184 | |
185 NSString substringWithRange (NSRange range) | |
186 { | |
187 return invokeObjcSelf!(NSString, "substringWithRange:", NSRange)(range); | |
188 } | |
189 | |
190 int compare (NSString string) | |
191 { | |
192 return invokeObjcSelf!(int, "compare:", NSString)(string); | |
193 } | |
194 | |
195 int compare (NSString string, uint mask) | |
196 { | |
197 return invokeObjcSelf!(int, "compare:options:", NSString, uint)(string, mask); | |
198 } | |
199 | |
200 int compare (NSString string, uint mask, NSRange compareRange) | |
201 { | |
202 return invokeObjcSelf!(int, "compare:options:range:", NSString, uint, NSRange)(string, mask, compareRange); | |
203 } | |
204 | |
205 int compare (NSString string, uint mask, NSRange compareRange, Object locale) | |
206 { | |
207 return invokeObjcSelf!(int, "compare:options:range:locale:", NSString, uint, NSRange, Object)(string, mask, compareRange, locale); | |
208 } | |
209 | |
210 int caseInsensitiveCompare (NSString string) | |
211 { | |
212 return invokeObjcSelf!(int, "caseInsensitiveCompare:", NSString)(string); | |
213 } | |
214 | |
215 int localizedCompare (NSString string) | |
216 { | |
217 return invokeObjcSelf!(int, "localizedCompare:", NSString)(string); | |
218 } | |
219 | |
220 int localizedCaseInsensitiveCompare (NSString string) | |
221 { | |
222 return invokeObjcSelf!(int, "localizedCaseInsensitiveCompare:", NSString)(string); | |
223 } | |
224 | |
225 bool isEqualToString (NSString aString) | |
226 { | |
227 return invokeObjcSelf!(bool, "isEqualToString:", NSString)(aString); | |
228 } | |
229 | |
230 bool hasPrefix (NSString aString) | |
231 { | |
232 return invokeObjcSelf!(bool, "hasPrefix:", NSString)(aString); | |
233 } | |
234 | |
235 bool hasSuffix (NSString aString) | |
236 { | |
237 return invokeObjcSelf!(bool, "hasSuffix:", NSString)(aString); | |
238 } | |
239 | |
240 NSRange rangeOfString (NSString aString) | |
241 { | |
242 return invokeObjcSelf!(NSRange, "rangeOfString:", NSString)(aString); | |
243 } | |
244 | |
245 NSRange rangeOfString (NSString aString, uint mask) | |
246 { | |
247 return invokeObjcSelf!(NSRange, "rangeOfString:options:", NSString, uint)(aString, mask); | |
248 } | |
249 | |
250 NSRange rangeOfString (NSString aString, uint mask, NSRange searchRange) | |
251 { | |
252 return invokeObjcSelf!(NSRange, "rangeOfString:options:range:", NSString, uint, NSRange)(aString, mask, searchRange); | |
253 } | |
254 | |
255 NSRange rangeOfString (NSString aString, uint mask, NSRange searchRange, NSLocale locale) | |
256 { | |
257 return invokeObjcSelf!(NSRange, "rangeOfString:options:range:locale:", NSString, uint, NSRange, NSLocale)(aString, mask, searchRange, locale); | |
258 } | |
259 | |
260 NSRange rangeOfCharacterFromSet (NSCharacterSet aSet) | |
261 { | |
262 return invokeObjcSelf!(NSRange, "rangeOfCharacterFromSet:", NSCharacterSet)(aSet); | |
263 } | |
264 | |
265 NSRange rangeOfCharacterFromSet (NSCharacterSet aSet, uint mask) | |
266 { | |
267 return invokeObjcSelf!(NSRange, "rangeOfCharacterFromSet:options:", NSCharacterSet, uint)(aSet, mask); | |
268 } | |
269 | |
270 NSRange rangeOfCharacterFromSet (NSCharacterSet aSet, uint mask, NSRange searchRange) | |
271 { | |
272 return invokeObjcSelf!(NSRange, "rangeOfCharacterFromSet:options:range:", NSCharacterSet, uint, NSRange)(aSet, mask, searchRange); | |
273 } | |
274 | |
275 NSRange rangeOfComposedCharacterSequenceAtIndex (NSUInteger index) | |
276 { | |
277 return invokeObjcSelf!(NSRange, "rangeOfComposedCharacterSequenceAtIndex:", NSUInteger)(index); | |
278 } | |
279 | |
280 NSRange rangeOfComposedCharacterSequencesForRange (NSRange range) | |
281 { | |
282 return invokeObjcSelf!(NSRange, "rangeOfComposedCharacterSequencesForRange:", NSRange)(range); | |
283 } | |
284 | |
285 NSString stringByAppendingString (NSString aString) | |
286 { | |
287 return invokeObjcSelf!(NSString, "stringByAppendingString:", NSString)(aString); | |
288 } | |
289 | |
290 NSString stringByAppendingFormat (NSString stringByAppendingFormat, ...) | |
291 { | |
292 return invokeObjcSelf!(NSString, "stringByAppendingFormat:", NSString)(stringByAppendingFormat); | |
293 } | |
294 | |
295 double doubleValue () | |
296 { | |
297 return invokeObjcSelf!(double, "doubleValue"); | |
298 } | |
299 | |
300 float floatValue () | |
301 { | |
302 return invokeObjcSelf!(float, "floatValue"); | |
303 } | |
304 | |
305 int intValue () | |
306 { | |
307 return invokeObjcSelf!(int, "intValue"); | |
308 } | |
309 | |
310 NSInteger integerValue () | |
311 { | |
312 return invokeObjcSelf!(NSInteger, "integerValue"); | |
313 } | |
314 | |
315 long longLongValue () | |
316 { | |
317 return invokeObjcSelf!(long, "longLongValue"); | |
318 } | |
319 | |
320 bool boolValue () | |
321 { | |
322 return invokeObjcSelf!(bool, "boolValue"); | |
323 } | |
324 | |
325 NSArray componentsSeparatedByString (NSString separator) | |
326 { | |
327 return invokeObjcSelf!(NSArray, "componentsSeparatedByString:", NSString)(separator); | |
328 } | |
329 | |
330 NSArray componentsSeparatedByCharactersInSet (NSCharacterSet separator) | |
331 { | |
332 return invokeObjcSelf!(NSArray, "componentsSeparatedByCharactersInSet:", NSCharacterSet)(separator); | |
333 } | |
334 | |
335 NSString commonPrefixWithString (NSString aString, uint mask) | |
336 { | |
337 return invokeObjcSelf!(NSString, "commonPrefixWithString:options:", NSString, uint)(aString, mask); | |
338 } | |
339 | |
340 NSString uppercaseString () | |
341 { | |
342 return invokeObjcSelf!(NSString, "uppercaseString"); | |
343 } | |
344 | |
345 NSString lowercaseString () | |
346 { | |
347 return invokeObjcSelf!(NSString, "lowercaseString"); | |
348 } | |
349 | |
350 NSString capitalizedString () | |
351 { | |
352 return invokeObjcSelf!(NSString, "capitalizedString"); | |
353 } | |
354 | |
355 NSString stringByTrimmingCharactersInSet (NSCharacterSet set) | |
356 { | |
357 return invokeObjcSelf!(NSString, "stringByTrimmingCharactersInSet:", NSCharacterSet)(set); | |
358 } | |
359 | |
360 NSString stringByPaddingToLength (NSUInteger newLength, NSString padString, NSUInteger padIndex) | |
361 { | |
362 return invokeObjcSelf!(NSString, "stringByPaddingToLength:withString:startingAtIndex:", NSUInteger, NSString, NSUInteger)(newLength, padString, padIndex); | |
363 } | |
364 | |
365 void getLineStart (NSUInteger* startPtr, NSUInteger* lineEndPtr, NSUInteger* contentsEndPtr, NSRange range) | |
366 { | |
367 return invokeObjcSelf!(void, "getLineStart:end:contentsEnd:forRange:", NSUInteger*, NSUInteger*, NSUInteger*, NSRange)(startPtr, lineEndPtr, contentsEndPtr, range); | |
368 } | |
369 | |
370 NSRange lineRangeForRange (NSRange range) | |
371 { | |
372 return invokeObjcSelf!(NSRange, "lineRangeForRange:", NSRange)(range); | |
373 } | |
374 | |
375 void getParagraphStart (NSUInteger* startPtr, NSUInteger* parEndPtr, NSUInteger* contentsEndPtr, NSRange range) | |
376 { | |
377 return invokeObjcSelf!(void, "getParagraphStart:end:contentsEnd:forRange:", NSUInteger*, NSUInteger*, NSUInteger*, NSRange)(startPtr, parEndPtr, contentsEndPtr, range); | |
378 } | |
379 | |
380 NSRange paragraphRangeForRange (NSRange range) | |
381 { | |
382 return invokeObjcSelf!(NSRange, "paragraphRangeForRange:", NSRange)(range); | |
383 } | |
384 | |
385 NSString description () | |
386 { | |
387 return invokeObjcSelf!(NSString, "description"); | |
388 } | |
389 | |
390 NSUInteger hash () | |
391 { | |
392 return invokeObjcSelf!(NSUInteger, "hash"); | |
393 } | |
394 | |
395 uint fastestEncoding () | |
396 { | |
397 return invokeObjcSelf!(uint, "fastestEncoding"); | |
398 } | |
399 | |
400 uint smallestEncoding () | |
401 { | |
402 return invokeObjcSelf!(uint, "smallestEncoding"); | |
403 } | |
404 | |
405 NSData dataUsingEncoding (uint encoding, bool lossy) | |
406 { | |
407 return invokeObjcSelf!(NSData, "dataUsingEncoding:allowLossyConversion:", uint, bool)(encoding, lossy); | |
408 } | |
409 | |
410 NSData dataUsingEncoding (uint encoding) | |
411 { | |
412 return invokeObjcSelf!(NSData, "dataUsingEncoding:", uint)(encoding); | |
413 } | |
414 | |
415 bool canBeConvertedToEncoding (uint encoding) | |
416 { | |
417 return invokeObjcSelf!(bool, "canBeConvertedToEncoding:", uint)(encoding); | |
418 } | |
419 | |
420 char* cStringUsingEncoding (uint encoding) | |
421 { | |
422 return invokeObjcSelf!(char*, "cStringUsingEncoding:", uint)(encoding); | |
423 } | |
424 | |
425 bool getCString (char* buffer, NSUInteger maxBufferCount, uint encoding) | |
426 { | |
427 return invokeObjcSelf!(bool, "getCString:maxLength:encoding:", char*, NSUInteger, uint)(buffer, maxBufferCount, encoding); | |
428 } | |
429 | |
430 bool getBytes (void* buffer, NSUInteger maxBufferCount, NSUInteger* usedBufferCount, uint encoding, uint options, NSRange range, NSRangePointer leftover) | |
431 { | |
432 return invokeObjcSelf!(bool, "getBytes:maxLength:usedLength:encoding:options:range:remainingRange:", void*, NSUInteger, NSUInteger*, uint, uint, NSRange, NSRangePointer)(buffer, maxBufferCount, usedBufferCount, encoding, options, range, leftover); | |
433 } | |
434 | |
435 NSUInteger maximumLengthOfBytesUsingEncoding (uint enc) | |
436 { | |
437 return invokeObjcSelf!(NSUInteger, "maximumLengthOfBytesUsingEncoding:", uint)(enc); | |
438 } | |
439 | |
440 NSUInteger lengthOfBytesUsingEncoding (uint enc) | |
441 { | |
442 return invokeObjcSelf!(NSUInteger, "lengthOfBytesUsingEncoding:", uint)(enc); | |
443 } | |
444 | |
445 NSString decomposedStringWithCanonicalMapping () | |
446 { | |
447 return invokeObjcSelf!(NSString, "decomposedStringWithCanonicalMapping"); | |
448 } | |
449 | |
450 NSString precomposedStringWithCanonicalMapping () | |
451 { | |
452 return invokeObjcSelf!(NSString, "precomposedStringWithCanonicalMapping"); | |
453 } | |
454 | |
455 NSString decomposedStringWithCompatibilityMapping () | |
456 { | |
457 return invokeObjcSelf!(NSString, "decomposedStringWithCompatibilityMapping"); | |
458 } | |
459 | |
460 NSString precomposedStringWithCompatibilityMapping () | |
461 { | |
462 return invokeObjcSelf!(NSString, "precomposedStringWithCompatibilityMapping"); | |
463 } | |
464 | |
465 NSString stringByFoldingWithOptions (uint options, NSLocale locale) | |
466 { | |
467 return invokeObjcSelf!(NSString, "stringByFoldingWithOptions:locale:", uint, NSLocale)(options, locale); | |
468 } | |
469 | |
470 NSString stringByReplacingOccurrencesOfString (NSString target, NSString replacement, uint options, NSRange searchRange) | |
471 { | |
472 return invokeObjcSelf!(NSString, "stringByReplacingOccurrencesOfString:withString:options:range:", NSString, NSString, uint, NSRange)(target, replacement, options, searchRange); | |
473 } | |
474 | |
475 NSString stringByReplacingOccurrencesOfString (NSString target, NSString replacement) | |
476 { | |
477 return invokeObjcSelf!(NSString, "stringByReplacingOccurrencesOfString:withString:", NSString, NSString)(target, replacement); | |
478 } | |
479 | |
480 NSString stringByReplacingCharactersInRange (NSRange range, NSString replacement) | |
481 { | |
482 return invokeObjcSelf!(NSString, "stringByReplacingCharactersInRange:withString:", NSRange, NSString)(range, replacement); | |
483 } | |
484 | |
485 char* UTF8String () | |
486 { | |
487 return invokeObjcSelf!(char*, "UTF8String"); | |
488 } | |
489 | |
490 static uint defaultCStringEncoding () | |
491 { | |
492 return invokeObjcSuperClass!(uint, "defaultCStringEncoding"); | |
493 } | |
494 | |
495 static NSStringEncoding* availableStringEncodings () | |
496 { | |
497 return invokeObjcSuperClass!(NSStringEncoding*, "availableStringEncodings"); | |
498 } | |
499 | |
500 static NSString localizedNameOfStringEncoding (uint encoding) | |
501 { | |
502 return invokeObjcSuperClass!(NSString, "localizedNameOfStringEncoding:", uint)(encoding); | |
503 } | |
504 | |
505 NSString initWithCharactersNoCopy (unichar* characters, NSUInteger length, bool freeBuffer) | |
506 { | |
507 return invokeObjcSelf!(Object, "initWithCharactersNoCopy:length:freeWhenDone:", unichar*, NSUInteger, bool)(characters, length, freeBuffer); | |
508 } | |
509 | |
510 /*this (unichar* characters, NSUInteger length, bool freeBuffer) | |
511 { | |
512 typeof(this).alloc.initWithCharactersNoCopy(characters, length, freeBuffer); | |
513 }*/ | |
514 | |
515 NSString initWithCharacters (unichar* characters, NSUInteger length) | |
516 { | |
517 return invokeObjcSelf!(Object, "initWithCharacters:length:", unichar*, NSUInteger)(characters, length); | |
518 } | |
519 | |
520 /*this (unichar* characters, NSUInteger length) | |
521 { | |
522 typeof(this).alloc.initWithCharacters(characters, length); | |
523 }*/ | |
524 | |
525 NSString initWithUTF8String (char* nullTerminatedCString) | |
526 { | |
527 return invokeObjcSelf!(Object, "initWithUTF8String:", char*)(nullTerminatedCString); | |
528 } | |
529 | |
530 /*this (char* nullTerminatedCString) | |
531 { | |
532 typeof(this).alloc.initWithUTF8String(nullTerminatedCString); | |
533 }*/ | |
534 | |
535 NSString initWithString (NSString aString) | |
536 { | |
537 return invokeObjcSelf!(Object, "initWithString:", NSString)(aString); | |
538 } | |
539 | |
540 /*this (NSString aString) | |
541 { | |
542 typeof(this).alloc.initWithString(aString); | |
543 }*/ | |
544 | |
545 NSString initWithFormat (NSString initWithFormat, ...) | |
546 { | |
547 return invokeObjcSelf!(Object, "initWithFormat:", NSString)(initWithFormat); | |
548 } | |
549 | |
550 /*this (NSString initWithFormat, ...) | |
551 { | |
552 typeof(this).alloc.initWithFormat(initWithFormat); | |
553 }*/ | |
554 | |
555 NSString initWithFormat (NSString format, char* argList) | |
556 { | |
557 return invokeObjcSelf!(Object, "initWithFormat:arguments:", NSString, char*)(format, argList); | |
558 } | |
559 | |
560 /*this (NSString format, char* argList) | |
561 { | |
562 typeof(this).alloc.initWithFormat(format, argList); | |
563 }*/ | |
564 | |
565 NSString initWithFormat (NSString format, Object locale, ...) | |
566 { | |
567 return invokeObjcSelf!(Object, "initWithFormat:locale:", NSString, Object)(format, locale); | |
568 } | |
569 | |
570 /*this (NSString format, Object locale, ...) | |
571 { | |
572 typeof(this).alloc.initWithFormat(format, locale); | |
573 }*/ | |
574 | |
575 NSString initWithFormat (NSString format, Object locale, char* argList) | |
576 { | |
577 return invokeObjcSelf!(Object, "initWithFormat:locale:arguments:", NSString, Object, char*)(format, locale, argList); | |
578 } | |
579 | |
580 /*this (NSString format, Object locale, char* argList) | |
581 { | |
582 typeof(this).alloc.initWithFormat(format, locale, argList); | |
583 }*/ | |
584 | |
585 NSString initWithData (NSData data, uint encoding) | |
586 { | |
587 return invokeObjcSelf!(Object, "initWithData:encoding:", NSData, uint)(data, encoding); | |
588 } | |
589 | |
590 /*this (NSData data, uint encoding) | |
591 { | |
592 typeof(this).alloc.initWithData(data, encoding); | |
593 }*/ | |
594 | |
595 NSString initWithBytes (void* bytes, NSUInteger len, uint encoding) | |
596 { | |
597 return invokeObjcSelf!(Object, "initWithBytes:length:encoding:", void*, NSUInteger, uint)(bytes, len, encoding); | |
598 } | |
599 | |
600 /*this (void* bytes, NSUInteger len, uint encoding) | |
601 { | |
602 typeof(this).alloc.initWithBytes(bytes, len, encoding); | |
603 }*/ | |
604 | |
605 NSString initWithBytesNoCopy (void* bytes, NSUInteger len, NSStringEncoding encoding, bool freeBuffer) | |
606 { | |
607 return invokeObjcSelf!(Object, "initWithBytesNoCopy:length:encoding:freeWhenDone:", void*, NSUInteger, NSStringEncoding, bool)(bytes, len, encoding, freeBuffer); | |
608 } | |
609 | |
610 /*this (void* bytes, NSUInteger len, uint encoding, bool freeBuffer) | |
611 { | |
612 typeof(this).alloc.initWithBytesNoCopy(bytes, len, encoding, freeBuffer); | |
613 }*/ | |
614 | |
615 static Object string () | |
616 { | |
617 return invokeObjcSuperClass!(Object, "string"); | |
618 } | |
619 | |
620 static Object stringWithString (NSString string) | |
621 { | |
622 return invokeObjcSuperClass!(Object, "stringWithString:", NSString)(string); | |
623 } | |
624 | |
625 static Object stringWithCharacters (unichar* characters, NSUInteger length) | |
626 { | |
627 return invokeObjcSuperClass!(Object, "stringWithCharacters:length:", unichar*, NSUInteger)(characters, length); | |
628 } | |
629 | |
630 static NSString stringWithUTF8String (char* nullTerminatedCString) | |
631 { | |
632 return invokeObjcSuperClass!(NSString, "stringWithUTF8String:", char*)(nullTerminatedCString); | |
633 } | |
634 | |
635 static Object stringWithFormat (NSString stringWithFormat, ...) | |
636 { | |
637 return invokeObjcSuperClass!(Object, "stringWithFormat:", NSString)(stringWithFormat); | |
638 } | |
639 | |
640 static Object localizedStringWithFormat (NSString localizedStringWithFormat, ...) | |
641 { | |
642 return invokeObjcSuperClass!(Object, "localizedStringWithFormat:", NSString)(localizedStringWithFormat); | |
643 } | |
644 | |
645 static Object stringWithCString (char* cString, uint enc) | |
646 { | |
647 return invokeObjcSuperClass!(Object, "stringWithCString:encoding:", char*, uint)(cString, enc); | |
648 } | |
649 | |
650 NSString initWithContentsOfURL (NSURL url, NSStringEncoding enc, ref NSError error) | |
651 { | |
652 id err; | |
653 | |
654 if (error) | |
655 err = new objc_object; | |
656 | |
657 Object result = invokeObjcSelf!(Object, "initWithContentsOfURL:encoding:error:", NSURL, NSStringEncoding, id*)(url, enc, &err); | |
658 | |
659 if (err) | |
660 error = new NSError(err); | |
661 | |
662 return result; | |
663 } | |
664 | |
665 /*this (NSURL url, NSStringEncoding enc, ref NSError error) | |
666 { | |
667 typeof(this).alloc.initWithContentsOfURL(url, enc, error); | |
668 }*/ | |
669 | |
670 NSString initWithContentsOfFile (NSString path, NSStringEncoding enc, ref NSError error) | |
671 { | |
672 id err; | |
673 | |
674 if (error) | |
675 err = new objc_object; | |
676 | |
677 Object result = invokeObjcSelf!(Object, "initWithContentsOfFile:encoding:error:", NSString, NSStringEncoding, id*)(path, enc, &err); | |
678 | |
679 if (err) | |
680 error = new NSError(err); | |
681 | |
682 return result; | |
683 } | |
684 | |
685 /*this (NSString path, NSStringEncoding enc, ref NSError error) | |
686 { | |
687 typeof(this).alloc.initWithContentsOfFile(path, enc, error); | |
688 }*/ | |
689 | |
690 static Object stringWithContentsOfURL (NSURL url, NSStringEncoding enc, ref NSError error) | |
691 { | |
692 id err; | |
693 | |
694 if (error) | |
695 err = new objc_object; | |
696 | |
697 Object result = invokeObjcSuperClass!(Object, "stringWithContentsOfURL:encoding:error:", NSURL, NSStringEncoding, id*)(url, enc, &err); | |
698 | |
699 if (err) | |
700 error = new NSError(err); | |
701 | |
702 return result; | |
703 } | |
704 | |
705 static Object stringWithContentsOfFile (NSString path, NSStringEncoding enc, ref NSError error) | |
706 { | |
707 id err; | |
708 | |
709 if (error) | |
710 err = new objc_object; | |
711 | |
712 Object result = invokeObjcSuperClass!(Object, "stringWithContentsOfFile:encoding:error:", NSString, NSStringEncoding, id*)(path, enc, &err); | |
713 | |
714 if (err) | |
715 error = new NSError(err); | |
716 | |
717 return result; | |
718 } | |
719 | |
720 NSString initWithContentsOfURL (NSURL url, NSStringEncoding* enc, ref NSError error) | |
721 { | |
722 id err; | |
723 | |
724 if (error) | |
725 err = new objc_object; | |
726 | |
727 Object result = invokeObjcSelf!(Object, "initWithContentsOfURL:usedEncoding:error:", NSURL, NSStringEncoding*, id*)(url, enc, &err); | |
728 | |
729 if (err) | |
730 error = new NSError(err); | |
731 | |
732 return result; | |
733 } | |
734 | |
735 /*this (NSURL url, NSStringEncoding* enc, ref NSError error) | |
736 { | |
737 typeof(this).alloc.initWithContentsOfURL(url, enc, error); | |
738 }*/ | |
739 | |
740 NSString initWithContentsOfFile (NSString path, NSStringEncoding* enc, ref NSError error) | |
741 { | |
742 id err; | |
743 | |
744 if (error) | |
745 err = new objc_object; | |
746 | |
747 Object result = invokeObjcSelf!(Object, "initWithContentsOfFile:usedEncoding:error:", NSString, NSStringEncoding*, id*)(path, enc, &err); | |
748 | |
749 if (err) | |
750 error = new NSError(err); | |
751 | |
752 return result; | |
753 } | |
754 | |
755 /*this (NSString path, NSStringEncoding* enc, ref NSError error) | |
756 { | |
757 typeof(this).alloc.initWithContentsOfFile(path, enc, error); | |
758 }*/ | |
759 | |
760 static Object stringWithContentsOfURL (NSURL url, NSStringEncoding* enc, ref NSError error) | |
761 { | |
762 id err; | |
763 | |
764 if (error) | |
765 err = new objc_object; | |
766 | |
767 Object result = invokeObjcSuperClass!(Object, "stringWithContentsOfURL:usedEncoding:error:", NSURL, NSStringEncoding*, id*)(url, enc, &err); | |
768 | |
769 if (err) | |
770 error = new NSError(err); | |
771 | |
772 return result; | |
773 } | |
774 | |
775 static Object stringWithContentsOfFile (NSString path, NSStringEncoding* enc, ref NSError error) | |
776 { | |
777 id err; | |
778 | |
779 if (error) | |
780 err = new objc_object; | |
781 | |
782 Object result = invokeObjcSuperClass!(Object, "stringWithContentsOfFile:usedEncoding:error:", NSString, NSStringEncoding*, id*)(path, enc, &err); | |
783 | |
784 if (err) | |
785 error = new NSError(err); | |
786 | |
787 return result; | |
788 } | |
789 | |
790 bool writeToURL (NSURL url, bool useAuxiliaryFile, uint enc, ref NSError error) | |
791 { | |
792 id err; | |
793 | |
794 if (error) | |
795 err = new objc_object; | |
796 | |
797 bool result = invokeObjcSelf!(bool, "writeToURL:atomically:encoding:error:", NSURL, bool, uint, id*)(url, useAuxiliaryFile, enc, &err); | |
798 | |
799 if (err) | |
800 error = new NSError(err); | |
801 | |
802 return result; | |
803 } | |
804 | |
805 bool writeToFile (NSString path, bool useAuxiliaryFile, uint enc, ref NSError error) | |
806 { | |
807 id err; | |
808 | |
809 if (error) | |
810 err = new objc_object; | |
811 | |
812 bool result = invokeObjcSelf!(bool, "writeToFile:atomically:encoding:error:", NSString, bool, uint, id*)(path, useAuxiliaryFile, enc, &err); | |
813 | |
814 if (err) | |
815 error = new NSError(err); | |
816 | |
817 return result; | |
818 } | |
819 `; | |
820 | |
821 const TNSStringDeprecated = ` | |
822 | |
823 char* cString () | |
824 { | |
825 return invokeObjcSelf!(char*, "cString"); | |
826 } | |
827 | |
828 char* lossyCString () | |
829 { | |
830 return invokeObjcSelf!(char*, "lossyCString"); | |
831 } | |
832 | |
833 NSUInteger cStringLength () | |
834 { | |
835 return invokeObjcSelf!(NSUInteger, "cStringLength"); | |
836 } | |
837 | |
838 void getCString (char* bytes) | |
839 { | |
840 return invokeObjcSelf!(void, "getCString:", char*)(bytes); | |
841 } | |
842 | |
843 void getCString (char* bytes, NSUInteger maxLength) | |
844 { | |
845 return invokeObjcSelf!(void, "getCString:maxLength:", char*, NSUInteger)(bytes, maxLength); | |
846 } | |
847 | |
848 void getCString (char* bytes, NSUInteger maxLength, NSRange aRange, NSRangePointer leftoverRange) | |
849 { | |
850 return invokeObjcSelf!(void, "getCString:maxLength:range:remainingRange:", char*, NSUInteger, NSRange, NSRangePointer)(bytes, maxLength, aRange, leftoverRange); | |
851 } | |
852 | |
853 bool writeToFile (NSString path, bool useAuxiliaryFile) | |
854 { | |
855 return invokeObjcSelf!(bool, "writeToFile:atomically:", NSString, bool)(path, useAuxiliaryFile); | |
856 } | |
857 | |
858 bool writeToURL (NSURL url, bool atomically) | |
859 { | |
860 return invokeObjcSelf!(bool, "writeToURL:atomically:", NSURL, bool)(url, atomically); | |
861 } | |
862 | |
863 /*NSString initWithContentsOfFile (NSString path) | |
864 { | |
865 return invokeObjcSelf!(Object, "initWithContentsOfFile:", NSString)(path); | |
866 } | |
867 | |
868 this (NSString path) | |
869 { | |
870 typeof(this).alloc.initWithContentsOfFile(path); | |
871 } | |
872 | |
873 NSString initWithContentsOfURL (NSURL url) | |
874 { | |
875 return invokeObjcSelf!(Object, "initWithContentsOfURL:", NSURL)(url); | |
876 } | |
877 | |
878 this (NSURL url) | |
879 { | |
880 typeof(this).alloc.initWithContentsOfURL(url); | |
881 }*/ | |
882 | |
883 static Object stringWithContentsOfFile (NSString path) | |
884 { | |
885 return invokeObjcSuperClass!(Object, "stringWithContentsOfFile:", NSString)(path); | |
886 } | |
887 | |
888 static Object stringWithContentsOfURL (NSURL url) | |
889 { | |
890 return invokeObjcSuperClass!(Object, "stringWithContentsOfURL:", NSURL)(url); | |
891 } | |
892 | |
893 NSString initWithCStringNoCopy (char* bytes, NSUInteger length, bool freeBuffer) | |
894 { | |
895 return invokeObjcSelf!(Object, "initWithCStringNoCopy:length:freeWhenDone:", char*, NSUInteger, bool)(bytes, length, freeBuffer); | |
896 } | |
897 | |
898 this (char* bytes, NSUInteger length, bool freeBuffer) | |
899 { | |
900 typeof(this).alloc.initWithCStringNoCopy(bytes, length, freeBuffer); | |
901 } | |
902 | |
903 NSString initWithCString (char* bytes, NSUInteger length) | |
904 { | |
905 return invokeObjcSelf!(Object, "initWithCString:length:", char*, NSUInteger)(bytes, length); | |
906 } | |
907 | |
908 this (char* bytes, NSUInteger length) | |
909 { | |
910 typeof(this).alloc.initWithCString(bytes, length); | |
911 } | |
912 | |
913 NSString initWithCString (char* bytes) | |
914 { | |
915 return invokeObjcSelf!(Object, "initWithCString:", char*)(bytes); | |
916 } | |
917 | |
918 this (char* bytes) | |
919 { | |
920 typeof(this).alloc.initWithCString(bytes); | |
921 } | |
922 | |
923 static Object stringWithCString (char* bytes, NSUInteger length) | |
924 { | |
925 return invokeObjcSuperClass!(Object, "stringWithCString:length:", char*, NSUInteger)(bytes, length); | |
926 } | |
927 | |
928 static Object stringWithCString (char* bytes) | |
929 { | |
930 return invokeObjcSuperClass!(Object, "stringWithCString:", char*)(bytes); | |
931 } | |
932 `; | |
83 | 933 |
84 class NSMutableString : NSString | 934 class NSMutableString : NSString |
85 { | 935 { |
86 mixin ObjcWrap; | 936 mixin (ObjcClusterWrap); |
87 mixin TNSMutableStringExtensionMethods; | 937 |
88 | 938 this () |
939 { | |
940 super(typeof(this).alloc.init.objcObject); | |
941 } | |
942 | |
943 typeof(this) init () | |
944 { | |
945 return invokeObjcSelf!(typeof(this), "init"); | |
946 } | |
947 | |
89 void replaceCharactersInRange (NSRange range, NSString aString) | 948 void replaceCharactersInRange (NSRange range, NSString aString) |
90 { | 949 { |
91 return invokeObjcSelf!(void, "replaceCharactersInRange:withString:", NSRange, NSString)(range, aString); | 950 return invokeObjcSelf!(void, "replaceCharactersInRange:withString:", NSRange, NSString)(range, aString); |
951 } | |
952 | |
953 // TNSMutableStringExtensionMethods | |
954 void insertString (NSString aString, NSUInteger loc) | |
955 { | |
956 return invokeObjcSelf!(void, "insertString:atIndex:", NSString, NSUInteger)(aString, loc); | |
957 } | |
958 | |
959 void deleteCharactersInRange (NSRange range) | |
960 { | |
961 return invokeObjcSelf!(void, "deleteCharactersInRange:", NSRange)(range); | |
962 } | |
963 | |
964 void appendString (NSString aString) | |
965 { | |
966 return invokeObjcSelf!(void, "appendString:", NSString)(aString); | |
967 } | |
968 | |
969 void appendFormat (NSString appendFormat, ...) | |
970 { | |
971 return invokeObjcSelf!(void, "appendFormat:", NSString)(appendFormat); | |
972 } | |
973 | |
974 void setString (NSString aString) | |
975 { | |
976 return invokeObjcSelf!(void, "setString:", NSString)(aString); | |
977 } | |
978 | |
979 NSMutableString initWithCapacity (NSUInteger capacity) | |
980 { | |
981 return invokeObjcSelf!(NSMutableString, "initWithCapacity:", NSUInteger)(capacity); | |
982 } | |
983 | |
984 /*this (NSUInteger capacity) | |
985 { | |
986 typeof(this).alloc.initWithCapacity(capacity); | |
987 }*/ | |
988 | |
989 static NSMutableString stringWithCapacity (NSUInteger capacity) | |
990 { | |
991 return invokeObjcSuperClass!(NSMutableString, "stringWithCapacity:", NSUInteger)(capacity); | |
992 } | |
993 | |
994 NSUInteger replaceOccurrencesOfString (NSString target, NSString replacement, uint options, NSRange searchRange) | |
995 { | |
996 return invokeObjcSelf!(NSUInteger, "replaceOccurrencesOfString:withString:options:range:", NSString, NSString, uint, NSRange)(target, replacement, options, searchRange); | |
92 } | 997 } |
93 } | 998 } |
94 | 999 |
95 class NSString : NSObject, INSCopying, INSMutableCopying, INSCoding | 1000 class NSString : NSObject, INSCopying, INSMutableCopying, INSCoding |
96 { | 1001 { |
97 mixin ObjcWrap; | 1002 mixin (ObjcClusterWrap); |
98 mixin TNSExtendedStringPropertyListParsing; | 1003 |
99 mixin TNSStringExtensionMethods; | 1004 this () |
100 mixin TNSStringPathExtensions; | 1005 { |
101 mixin TNSURLUtilities; | 1006 super(typeof(this).alloc.init.objcObject); |
102 mixin TNSStringDeprecated; | 1007 } |
103 | 1008 |
1009 typeof(this) init () | |
1010 { | |
1011 return invokeObjcSelf!(typeof(this), "init"); | |
1012 } | |
1013 | |
104 NSUInteger length () | 1014 NSUInteger length () |
105 { | 1015 { |
106 return invokeObjcSelf!(NSUInteger, "length"); | 1016 return invokeObjcSelf!(NSUInteger, "length"); |
107 } | 1017 } |
108 | 1018 |
109 ushort characterAtIndex (NSUInteger index) | 1019 unichar characterAtIndex (NSUInteger index) |
110 { | 1020 { |
111 return invokeObjcSelf!(ushort, "characterAtIndex:", NSUInteger)(index); | 1021 return invokeObjcSelf!(unichar, "characterAtIndex:", NSUInteger)(index); |
112 } | 1022 } |
113 | 1023 |
114 Object copyWithZone (NSZone* zone) | 1024 NSString copyWithZone (NSZone* zone) |
115 { | 1025 { |
116 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | 1026 return invokeObjcSelf!(NSString, "copyWithZone:", NSZone*)(zone); |
117 } | 1027 } |
118 | 1028 |
119 Object mutableCopyWithZone (NSZone* zone) | 1029 NSString mutableCopyWithZone (NSZone* zone) |
120 { | 1030 { |
121 return invokeObjcSelf!(Object, "mutableCopyWithZone:", NSZone*)(zone); | 1031 return invokeObjcSelf!(NSString, "mutableCopyWithZone:", NSZone*)(zone); |
122 } | 1032 } |
123 | 1033 |
124 void encodeWithCoder (NSCoder aCoder) | 1034 void encodeWithCoder (NSCoder aCoder) |
125 { | 1035 { |
126 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | 1036 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); |
127 } | 1037 } |
128 | 1038 |
129 Object initWithCoder (NSCoder aDecoder) | 1039 NSString initWithCoder (NSCoder aDecoder) |
130 { | 1040 { |
131 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | 1041 return invokeObjcSelf!(NSString, "initWithCoder:", NSCoder)(aDecoder); |
132 } | 1042 } |
133 | 1043 |
134 this (NSCoder aDecoder) | 1044 this (NSCoder aDecoder) |
135 { | 1045 { |
136 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 1046 typeof(this).alloc.initWithCoder(aDecoder); |
137 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); | 1047 } |
138 | 1048 |
139 if (result) | 1049 // TNSExtendedStringPropertyListParsing |
140 objcObject = ret; | 1050 Object propertyList () |
141 | 1051 { |
142 dObject = this; | 1052 return invokeObjcSelf!(Object, "propertyList"); |
1053 } | |
1054 | |
1055 NSDictionary propertyListFromStringsFileFormat () | |
1056 { | |
1057 return invokeObjcSelf!(NSDictionary, "propertyListFromStringsFileFormat"); | |
1058 } | |
1059 | |
1060 // TNSStringExtensionMethods | |
1061 void getCharacters (unichar* buffer) | |
1062 { | |
1063 return invokeObjcSelf!(void, "getCharacters:", unichar*)(buffer); | |
1064 } | |
1065 | |
1066 void getCharacters (unichar* buffer, NSRange aRange) | |
1067 { | |
1068 return invokeObjcSelf!(void, "getCharacters:range:", unichar*, NSRange)(buffer, aRange); | |
1069 } | |
1070 | |
1071 NSString substringFromIndex (NSUInteger from) | |
1072 { | |
1073 return invokeObjcSelf!(NSString, "substringFromIndex:", NSUInteger)(from); | |
1074 } | |
1075 | |
1076 NSString substringToIndex (NSUInteger to) | |
1077 { | |
1078 return invokeObjcSelf!(NSString, "substringToIndex:", NSUInteger)(to); | |
1079 } | |
1080 | |
1081 NSString substringWithRange (NSRange range) | |
1082 { | |
1083 return invokeObjcSelf!(NSString, "substringWithRange:", NSRange)(range); | |
1084 } | |
1085 | |
1086 int compare (NSString string) | |
1087 { | |
1088 return invokeObjcSelf!(int, "compare:", NSString)(string); | |
1089 } | |
1090 | |
1091 int compare (NSString string, uint mask) | |
1092 { | |
1093 return invokeObjcSelf!(int, "compare:options:", NSString, uint)(string, mask); | |
1094 } | |
1095 | |
1096 int compare (NSString string, uint mask, NSRange compareRange) | |
1097 { | |
1098 return invokeObjcSelf!(int, "compare:options:range:", NSString, uint, NSRange)(string, mask, compareRange); | |
1099 } | |
1100 | |
1101 int compare (NSString string, uint mask, NSRange compareRange, Object locale) | |
1102 { | |
1103 return invokeObjcSelf!(int, "compare:options:range:locale:", NSString, uint, NSRange, Object)(string, mask, compareRange, locale); | |
1104 } | |
1105 | |
1106 int caseInsensitiveCompare (NSString string) | |
1107 { | |
1108 return invokeObjcSelf!(int, "caseInsensitiveCompare:", NSString)(string); | |
1109 } | |
1110 | |
1111 int localizedCompare (NSString string) | |
1112 { | |
1113 return invokeObjcSelf!(int, "localizedCompare:", NSString)(string); | |
1114 } | |
1115 | |
1116 int localizedCaseInsensitiveCompare (NSString string) | |
1117 { | |
1118 return invokeObjcSelf!(int, "localizedCaseInsensitiveCompare:", NSString)(string); | |
1119 } | |
1120 | |
1121 bool isEqualToString (NSString aString) | |
1122 { | |
1123 return invokeObjcSelf!(bool, "isEqualToString:", NSString)(aString); | |
1124 } | |
1125 | |
1126 bool hasPrefix (NSString aString) | |
1127 { | |
1128 return invokeObjcSelf!(bool, "hasPrefix:", NSString)(aString); | |
1129 } | |
1130 | |
1131 bool hasSuffix (NSString aString) | |
1132 { | |
1133 return invokeObjcSelf!(bool, "hasSuffix:", NSString)(aString); | |
1134 } | |
1135 | |
1136 NSRange rangeOfString (NSString aString) | |
1137 { | |
1138 return invokeObjcSelf!(NSRange, "rangeOfString:", NSString)(aString); | |
1139 } | |
1140 | |
1141 NSRange rangeOfString (NSString aString, uint mask) | |
1142 { | |
1143 return invokeObjcSelf!(NSRange, "rangeOfString:options:", NSString, uint)(aString, mask); | |
1144 } | |
1145 | |
1146 NSRange rangeOfString (NSString aString, uint mask, NSRange searchRange) | |
1147 { | |
1148 return invokeObjcSelf!(NSRange, "rangeOfString:options:range:", NSString, uint, NSRange)(aString, mask, searchRange); | |
1149 } | |
1150 | |
1151 NSRange rangeOfString (NSString aString, uint mask, NSRange searchRange, NSLocale locale) | |
1152 { | |
1153 return invokeObjcSelf!(NSRange, "rangeOfString:options:range:locale:", NSString, uint, NSRange, NSLocale)(aString, mask, searchRange, locale); | |
1154 } | |
1155 | |
1156 NSRange rangeOfCharacterFromSet (NSCharacterSet aSet) | |
1157 { | |
1158 return invokeObjcSelf!(NSRange, "rangeOfCharacterFromSet:", NSCharacterSet)(aSet); | |
1159 } | |
1160 | |
1161 NSRange rangeOfCharacterFromSet (NSCharacterSet aSet, uint mask) | |
1162 { | |
1163 return invokeObjcSelf!(NSRange, "rangeOfCharacterFromSet:options:", NSCharacterSet, uint)(aSet, mask); | |
1164 } | |
1165 | |
1166 NSRange rangeOfCharacterFromSet (NSCharacterSet aSet, uint mask, NSRange searchRange) | |
1167 { | |
1168 return invokeObjcSelf!(NSRange, "rangeOfCharacterFromSet:options:range:", NSCharacterSet, uint, NSRange)(aSet, mask, searchRange); | |
1169 } | |
1170 | |
1171 NSRange rangeOfComposedCharacterSequenceAtIndex (NSUInteger index) | |
1172 { | |
1173 return invokeObjcSelf!(NSRange, "rangeOfComposedCharacterSequenceAtIndex:", NSUInteger)(index); | |
1174 } | |
1175 | |
1176 NSRange rangeOfComposedCharacterSequencesForRange (NSRange range) | |
1177 { | |
1178 return invokeObjcSelf!(NSRange, "rangeOfComposedCharacterSequencesForRange:", NSRange)(range); | |
1179 } | |
1180 | |
1181 NSString stringByAppendingString (NSString aString) | |
1182 { | |
1183 return invokeObjcSelf!(NSString, "stringByAppendingString:", NSString)(aString); | |
1184 } | |
1185 | |
1186 NSString stringByAppendingFormat (NSString stringByAppendingFormat, ...) | |
1187 { | |
1188 return invokeObjcSelf!(NSString, "stringByAppendingFormat:", NSString)(stringByAppendingFormat); | |
1189 } | |
1190 | |
1191 double doubleValue () | |
1192 { | |
1193 return invokeObjcSelf!(double, "doubleValue"); | |
1194 } | |
1195 | |
1196 float floatValue () | |
1197 { | |
1198 return invokeObjcSelf!(float, "floatValue"); | |
1199 } | |
1200 | |
1201 int intValue () | |
1202 { | |
1203 return invokeObjcSelf!(int, "intValue"); | |
1204 } | |
1205 | |
1206 NSInteger integerValue () | |
1207 { | |
1208 return invokeObjcSelf!(NSInteger, "integerValue"); | |
1209 } | |
1210 | |
1211 long longLongValue () | |
1212 { | |
1213 return invokeObjcSelf!(long, "longLongValue"); | |
1214 } | |
1215 | |
1216 bool boolValue () | |
1217 { | |
1218 return invokeObjcSelf!(bool, "boolValue"); | |
1219 } | |
1220 | |
1221 NSArray componentsSeparatedByString (NSString separator) | |
1222 { | |
1223 return invokeObjcSelf!(NSArray, "componentsSeparatedByString:", NSString)(separator); | |
1224 } | |
1225 | |
1226 NSArray componentsSeparatedByCharactersInSet (NSCharacterSet separator) | |
1227 { | |
1228 return invokeObjcSelf!(NSArray, "componentsSeparatedByCharactersInSet:", NSCharacterSet)(separator); | |
1229 } | |
1230 | |
1231 NSString commonPrefixWithString (NSString aString, uint mask) | |
1232 { | |
1233 return invokeObjcSelf!(NSString, "commonPrefixWithString:options:", NSString, uint)(aString, mask); | |
1234 } | |
1235 | |
1236 NSString uppercaseString () | |
1237 { | |
1238 return invokeObjcSelf!(NSString, "uppercaseString"); | |
1239 } | |
1240 | |
1241 NSString lowercaseString () | |
1242 { | |
1243 return invokeObjcSelf!(NSString, "lowercaseString"); | |
1244 } | |
1245 | |
1246 NSString capitalizedString () | |
1247 { | |
1248 return invokeObjcSelf!(NSString, "capitalizedString"); | |
1249 } | |
1250 | |
1251 NSString stringByTrimmingCharactersInSet (NSCharacterSet set) | |
1252 { | |
1253 return invokeObjcSelf!(NSString, "stringByTrimmingCharactersInSet:", NSCharacterSet)(set); | |
1254 } | |
1255 | |
1256 NSString stringByPaddingToLength (NSUInteger newLength, NSString padString, NSUInteger padIndex) | |
1257 { | |
1258 return invokeObjcSelf!(NSString, "stringByPaddingToLength:withString:startingAtIndex:", NSUInteger, NSString, NSUInteger)(newLength, padString, padIndex); | |
1259 } | |
1260 | |
1261 void getLineStart (NSUInteger* startPtr, NSUInteger* lineEndPtr, NSUInteger* contentsEndPtr, NSRange range) | |
1262 { | |
1263 return invokeObjcSelf!(void, "getLineStart:end:contentsEnd:forRange:", NSUInteger*, NSUInteger*, NSUInteger*, NSRange)(startPtr, lineEndPtr, contentsEndPtr, range); | |
1264 } | |
1265 | |
1266 NSRange lineRangeForRange (NSRange range) | |
1267 { | |
1268 return invokeObjcSelf!(NSRange, "lineRangeForRange:", NSRange)(range); | |
1269 } | |
1270 | |
1271 void getParagraphStart (NSUInteger* startPtr, NSUInteger* parEndPtr, NSUInteger* contentsEndPtr, NSRange range) | |
1272 { | |
1273 return invokeObjcSelf!(void, "getParagraphStart:end:contentsEnd:forRange:", NSUInteger*, NSUInteger*, NSUInteger*, NSRange)(startPtr, parEndPtr, contentsEndPtr, range); | |
1274 } | |
1275 | |
1276 NSRange paragraphRangeForRange (NSRange range) | |
1277 { | |
1278 return invokeObjcSelf!(NSRange, "paragraphRangeForRange:", NSRange)(range); | |
1279 } | |
1280 | |
1281 NSString description () | |
1282 { | |
1283 return invokeObjcSelf!(NSString, "description"); | |
1284 } | |
1285 | |
1286 NSUInteger hash () | |
1287 { | |
1288 return invokeObjcSelf!(NSUInteger, "hash"); | |
1289 } | |
1290 | |
1291 uint fastestEncoding () | |
1292 { | |
1293 return invokeObjcSelf!(uint, "fastestEncoding"); | |
1294 } | |
1295 | |
1296 uint smallestEncoding () | |
1297 { | |
1298 return invokeObjcSelf!(uint, "smallestEncoding"); | |
1299 } | |
1300 | |
1301 NSData dataUsingEncoding (uint encoding, bool lossy) | |
1302 { | |
1303 return invokeObjcSelf!(NSData, "dataUsingEncoding:allowLossyConversion:", uint, bool)(encoding, lossy); | |
1304 } | |
1305 | |
1306 NSData dataUsingEncoding (uint encoding) | |
1307 { | |
1308 return invokeObjcSelf!(NSData, "dataUsingEncoding:", uint)(encoding); | |
1309 } | |
1310 | |
1311 bool canBeConvertedToEncoding (uint encoding) | |
1312 { | |
1313 return invokeObjcSelf!(bool, "canBeConvertedToEncoding:", uint)(encoding); | |
1314 } | |
1315 | |
1316 char* cStringUsingEncoding (uint encoding) | |
1317 { | |
1318 return invokeObjcSelf!(char*, "cStringUsingEncoding:", uint)(encoding); | |
1319 } | |
1320 | |
1321 bool getCString (char* buffer, NSUInteger maxBufferCount, uint encoding) | |
1322 { | |
1323 return invokeObjcSelf!(bool, "getCString:maxLength:encoding:", char*, NSUInteger, uint)(buffer, maxBufferCount, encoding); | |
1324 } | |
1325 | |
1326 bool getBytes (void* buffer, NSUInteger maxBufferCount, NSUInteger* usedBufferCount, uint encoding, uint options, NSRange range, NSRangePointer leftover) | |
1327 { | |
1328 return invokeObjcSelf!(bool, "getBytes:maxLength:usedLength:encoding:options:range:remainingRange:", void*, NSUInteger, NSUInteger*, uint, uint, NSRange, NSRangePointer)(buffer, maxBufferCount, usedBufferCount, encoding, options, range, leftover); | |
1329 } | |
1330 | |
1331 NSUInteger maximumLengthOfBytesUsingEncoding (uint enc) | |
1332 { | |
1333 return invokeObjcSelf!(NSUInteger, "maximumLengthOfBytesUsingEncoding:", uint)(enc); | |
1334 } | |
1335 | |
1336 NSUInteger lengthOfBytesUsingEncoding (uint enc) | |
1337 { | |
1338 return invokeObjcSelf!(NSUInteger, "lengthOfBytesUsingEncoding:", uint)(enc); | |
1339 } | |
1340 | |
1341 NSString decomposedStringWithCanonicalMapping () | |
1342 { | |
1343 return invokeObjcSelf!(NSString, "decomposedStringWithCanonicalMapping"); | |
1344 } | |
1345 | |
1346 NSString precomposedStringWithCanonicalMapping () | |
1347 { | |
1348 return invokeObjcSelf!(NSString, "precomposedStringWithCanonicalMapping"); | |
1349 } | |
1350 | |
1351 NSString decomposedStringWithCompatibilityMapping () | |
1352 { | |
1353 return invokeObjcSelf!(NSString, "decomposedStringWithCompatibilityMapping"); | |
1354 } | |
1355 | |
1356 NSString precomposedStringWithCompatibilityMapping () | |
1357 { | |
1358 return invokeObjcSelf!(NSString, "precomposedStringWithCompatibilityMapping"); | |
1359 } | |
1360 | |
1361 NSString stringByFoldingWithOptions (uint options, NSLocale locale) | |
1362 { | |
1363 return invokeObjcSelf!(NSString, "stringByFoldingWithOptions:locale:", uint, NSLocale)(options, locale); | |
1364 } | |
1365 | |
1366 NSString stringByReplacingOccurrencesOfString (NSString target, NSString replacement, uint options, NSRange searchRange) | |
1367 { | |
1368 return invokeObjcSelf!(NSString, "stringByReplacingOccurrencesOfString:withString:options:range:", NSString, NSString, uint, NSRange)(target, replacement, options, searchRange); | |
1369 } | |
1370 | |
1371 NSString stringByReplacingOccurrencesOfString (NSString target, NSString replacement) | |
1372 { | |
1373 return invokeObjcSelf!(NSString, "stringByReplacingOccurrencesOfString:withString:", NSString, NSString)(target, replacement); | |
1374 } | |
1375 | |
1376 NSString stringByReplacingCharactersInRange (NSRange range, NSString replacement) | |
1377 { | |
1378 return invokeObjcSelf!(NSString, "stringByReplacingCharactersInRange:withString:", NSRange, NSString)(range, replacement); | |
1379 } | |
1380 | |
1381 char* UTF8String () | |
1382 { | |
1383 return invokeObjcSelf!(char*, "UTF8String"); | |
1384 } | |
1385 | |
1386 static uint defaultCStringEncoding () | |
1387 { | |
1388 return invokeObjcSuperClass!(uint, "defaultCStringEncoding"); | |
1389 } | |
1390 | |
1391 static NSStringEncoding* availableStringEncodings () | |
1392 { | |
1393 return invokeObjcSuperClass!(NSStringEncoding*, "availableStringEncodings"); | |
1394 } | |
1395 | |
1396 static NSString localizedNameOfStringEncoding (uint encoding) | |
1397 { | |
1398 return invokeObjcSuperClass!(NSString, "localizedNameOfStringEncoding:", uint)(encoding); | |
1399 } | |
1400 | |
1401 NSString initWithCharactersNoCopy (unichar* characters, NSUInteger length, bool freeBuffer) | |
1402 { | |
1403 return invokeObjcSelf!(NSString, "initWithCharactersNoCopy:length:freeWhenDone:", unichar*, NSUInteger, bool)(characters, length, freeBuffer); | |
1404 } | |
1405 | |
1406 /*this (unichar* characters, NSUInteger length, bool freeBuffer) | |
1407 { | |
1408 typeof(this).alloc.initWithCharactersNoCopy(characters, length, freeBuffer); | |
1409 }*/ | |
1410 | |
1411 NSString initWithCharacters (unichar* characters, NSUInteger length) | |
1412 { | |
1413 return invokeObjcSelf!(NSString, "initWithCharacters:length:", unichar*, NSUInteger)(characters, length); | |
1414 } | |
1415 | |
1416 /*this (unichar* characters, NSUInteger length) | |
1417 { | |
1418 typeof(this).alloc.initWithCharacters(characters, length); | |
1419 }*/ | |
1420 | |
1421 NSString initWithUTF8String (char* nullTerminatedCString) | |
1422 { | |
1423 return invokeObjcSelf!(NSString, "initWithUTF8String:", char*)(nullTerminatedCString); | |
1424 } | |
1425 | |
1426 /*this (char* nullTerminatedCString) | |
1427 { | |
1428 typeof(this).alloc.initWithUTF8String(nullTerminatedCString); | |
1429 }*/ | |
1430 | |
1431 NSString initWithString (NSString aString) | |
1432 { | |
1433 return invokeObjcSelf!(NSString, "initWithString:", NSString)(aString); | |
1434 } | |
1435 | |
1436 /*this (NSString aString) | |
1437 { | |
1438 typeof(this).alloc.initWithString(aString); | |
1439 }*/ | |
1440 | |
1441 NSString initWithFormat (NSString initWithFormat, ...) | |
1442 { | |
1443 return invokeObjcSelf!(NSString, "initWithFormat:", NSString)(initWithFormat); | |
1444 } | |
1445 | |
1446 /*this (NSString initWithFormat, ...) | |
1447 { | |
1448 typeof(this).alloc.initWithFormat(initWithFormat); | |
1449 }*/ | |
1450 | |
1451 NSString initWithFormat (NSString format, char* argList) | |
1452 { | |
1453 return invokeObjcSelf!(NSString, "initWithFormat:arguments:", NSString, char*)(format, argList); | |
1454 } | |
1455 | |
1456 /*this (NSString format, char* argList) | |
1457 { | |
1458 typeof(this).alloc.initWithFormat(format, argList); | |
1459 }*/ | |
1460 | |
1461 NSString initWithFormat (NSString format, Object locale, ...) | |
1462 { | |
1463 return invokeObjcSelf!(NSString, "initWithFormat:locale:", NSString, Object)(format, locale); | |
1464 } | |
1465 | |
1466 /*this (NSString format, Object locale, ...) | |
1467 { | |
1468 typeof(this).alloc.initWithFormat(format, locale); | |
1469 }*/ | |
1470 | |
1471 NSString initWithFormat (NSString format, Object locale, char* argList) | |
1472 { | |
1473 return invokeObjcSelf!(NSString, "initWithFormat:locale:arguments:", NSString, Object, char*)(format, locale, argList); | |
1474 } | |
1475 | |
1476 /*this (NSString format, Object locale, char* argList) | |
1477 { | |
1478 typeof(this).alloc.initWithFormat(format, locale, argList); | |
1479 }*/ | |
1480 | |
1481 NSString initWithData (NSData data, uint encoding) | |
1482 { | |
1483 return invokeObjcSelf!(NSString, "initWithData:encoding:", NSData, uint)(data, encoding); | |
1484 } | |
1485 | |
1486 /*this (NSData data, uint encoding) | |
1487 { | |
1488 typeof(this).alloc.initWithData(data, encoding); | |
1489 }*/ | |
1490 | |
1491 NSString initWithBytes (void* bytes, NSUInteger len, uint encoding) | |
1492 { | |
1493 return invokeObjcSelf!(NSString, "initWithBytes:length:encoding:", void*, NSUInteger, uint)(bytes, len, encoding); | |
1494 } | |
1495 | |
1496 /*this (void* bytes, NSUInteger len, uint encoding) | |
1497 { | |
1498 typeof(this).alloc.initWithBytes(bytes, len, encoding); | |
1499 }*/ | |
1500 | |
1501 NSString initWithBytesNoCopy (void* bytes, NSUInteger len, NSStringEncoding encoding, bool freeBuffer) | |
1502 { | |
1503 return invokeObjcSelf!(NSString, "initWithBytesNoCopy:length:encoding:freeWhenDone:", void*, NSUInteger, NSStringEncoding, bool)(bytes, len, encoding, freeBuffer); | |
1504 } | |
1505 | |
1506 /*this (void* bytes, NSUInteger len, uint encoding, bool freeBuffer) | |
1507 { | |
1508 typeof(this).alloc.initWithBytesNoCopy(bytes, len, encoding, freeBuffer); | |
1509 }*/ | |
1510 | |
1511 static NSString string () | |
1512 { | |
1513 return invokeObjcSuperClass!(NSString, "string"); | |
1514 } | |
1515 | |
1516 static NSString stringWithString (NSString string) | |
1517 { | |
1518 return invokeObjcSuperClass!(NSString, "stringWithString:", NSString)(string); | |
1519 } | |
1520 | |
1521 static NSString stringWithCharacters (unichar* characters, NSUInteger length) | |
1522 { | |
1523 return invokeObjcSuperClass!(NSString, "stringWithCharacters:length:", unichar*, NSUInteger)(characters, length); | |
1524 } | |
1525 | |
1526 static NSString stringWithUTF8String (char* nullTerminatedCString) | |
1527 { | |
1528 return invokeObjcSuperClass!(NSString, "stringWithUTF8String:", char*)(nullTerminatedCString); | |
1529 } | |
1530 | |
1531 static NSString stringWithFormat (NSString stringWithFormat, ...) | |
1532 { | |
1533 return invokeObjcSuperClass!(NSString, "stringWithFormat:", NSString)(stringWithFormat); | |
1534 } | |
1535 | |
1536 static NSString localizedStringWithFormat (NSString localizedStringWithFormat, ...) | |
1537 { | |
1538 return invokeObjcSuperClass!(NSString, "localizedStringWithFormat:", NSString)(localizedStringWithFormat); | |
1539 } | |
1540 | |
1541 static NSString stringWithCString (char* cString, uint enc) | |
1542 { | |
1543 return invokeObjcSuperClass!(NSString, "stringWithCString:encoding:", char*, uint)(cString, enc); | |
1544 } | |
1545 | |
1546 NSString initWithContentsOfURL (NSURL url, NSStringEncoding enc, ref NSError error) | |
1547 { | |
1548 id err; | |
1549 | |
1550 if (error) | |
1551 err = new objc_object; | |
1552 | |
1553 NSString result = invokeObjcSelf!(NSString, "initWithContentsOfURL:encoding:error:", NSURL, NSStringEncoding, id*)(url, enc, &err); | |
1554 | |
1555 if (err) | |
1556 error = new NSError(err); | |
1557 | |
1558 return result; | |
1559 } | |
1560 | |
1561 /*this (NSURL url, NSStringEncoding enc, ref NSError error) | |
1562 { | |
1563 typeof(this).alloc.initWithContentsOfURL(url, enc, error); | |
1564 }*/ | |
1565 | |
1566 NSString initWithContentsOfFile (NSString path, NSStringEncoding enc, ref NSError error) | |
1567 { | |
1568 id err; | |
1569 | |
1570 if (error) | |
1571 err = new objc_object; | |
1572 | |
1573 NSString result = invokeObjcSelf!(NSString, "initWithContentsOfFile:encoding:error:", NSString, NSStringEncoding, id*)(path, enc, &err); | |
1574 | |
1575 if (err) | |
1576 error = new NSError(err); | |
1577 | |
1578 return result; | |
1579 } | |
1580 | |
1581 /*this (NSString path, NSStringEncoding enc, ref NSError error) | |
1582 { | |
1583 typeof(this).alloc.initWithContentsOfFile(path, enc, error); | |
1584 }*/ | |
1585 | |
1586 static NSString stringWithContentsOfURL (NSURL url, NSStringEncoding enc, ref NSError error) | |
1587 { | |
1588 id err; | |
1589 | |
1590 if (error) | |
1591 err = new objc_object; | |
1592 | |
1593 NSString result = invokeObjcSuperClass!(NSString, "stringWithContentsOfURL:encoding:error:", NSURL, NSStringEncoding, id*)(url, enc, &err); | |
1594 | |
1595 if (err) | |
1596 error = new NSError(err); | |
1597 | |
1598 return result; | |
1599 } | |
1600 | |
1601 static NSString stringWithContentsOfFile (NSString path, NSStringEncoding enc, ref NSError error) | |
1602 { | |
1603 id err; | |
1604 | |
1605 if (error) | |
1606 err = new objc_object; | |
1607 | |
1608 NSString result = invokeObjcSuperClass!(NSString, "stringWithContentsOfFile:encoding:error:", NSString, NSStringEncoding, id*)(path, enc, &err); | |
1609 | |
1610 if (err) | |
1611 error = new NSError(err); | |
1612 | |
1613 return result; | |
1614 } | |
1615 | |
1616 NSString initWithContentsOfURL (NSURL url, NSStringEncoding* enc, ref NSError error) | |
1617 { | |
1618 id err; | |
1619 | |
1620 if (error) | |
1621 err = new objc_object; | |
1622 | |
1623 NSString result = invokeObjcSelf!(NSString, "initWithContentsOfURL:usedEncoding:error:", NSURL, NSStringEncoding*, id*)(url, enc, &err); | |
1624 | |
1625 if (err) | |
1626 error = new NSError(err); | |
1627 | |
1628 return result; | |
1629 } | |
1630 | |
1631 /*this (NSURL url, NSStringEncoding* enc, ref NSError error) | |
1632 { | |
1633 typeof(this).alloc.initWithContentsOfURL(url, enc, error); | |
1634 }*/ | |
1635 | |
1636 NSString initWithContentsOfFile (NSString path, NSStringEncoding* enc, ref NSError error) | |
1637 { | |
1638 id err; | |
1639 | |
1640 if (error) | |
1641 err = new objc_object; | |
1642 | |
1643 NSString result = invokeObjcSelf!(NSString, "initWithContentsOfFile:usedEncoding:error:", NSString, NSStringEncoding*, id*)(path, enc, &err); | |
1644 | |
1645 if (err) | |
1646 error = new NSError(err); | |
1647 | |
1648 return result; | |
1649 } | |
1650 | |
1651 /*this (NSString path, NSStringEncoding* enc, ref NSError error) | |
1652 { | |
1653 typeof(this).alloc.initWithContentsOfFile(path, enc, error); | |
1654 }*/ | |
1655 | |
1656 static NSString stringWithContentsOfURL (NSURL url, NSStringEncoding* enc, ref NSError error) | |
1657 { | |
1658 id err; | |
1659 | |
1660 if (error) | |
1661 err = new objc_object; | |
1662 | |
1663 NSString result = invokeObjcSuperClass!(NSString, "stringWithContentsOfURL:usedEncoding:error:", NSURL, NSStringEncoding*, id*)(url, enc, &err); | |
1664 | |
1665 if (err) | |
1666 error = new NSError(err); | |
1667 | |
1668 return result; | |
1669 } | |
1670 | |
1671 static NSString stringWithContentsOfFile (NSString path, NSStringEncoding* enc, ref NSError error) | |
1672 { | |
1673 id err; | |
1674 | |
1675 if (error) | |
1676 err = new objc_object; | |
1677 | |
1678 NSString result = invokeObjcSuperClass!(NSString, "stringWithContentsOfFile:usedEncoding:error:", NSString, NSStringEncoding*, id*)(path, enc, &err); | |
1679 | |
1680 if (err) | |
1681 error = new NSError(err); | |
1682 | |
1683 return result; | |
1684 } | |
1685 | |
1686 bool writeToURL (NSURL url, bool useAuxiliaryFile, uint enc, ref NSError error) | |
1687 { | |
1688 id err; | |
1689 | |
1690 if (error) | |
1691 err = new objc_object; | |
1692 | |
1693 bool result = invokeObjcSelf!(bool, "writeToURL:atomically:encoding:error:", NSURL, bool, uint, id*)(url, useAuxiliaryFile, enc, &err); | |
1694 | |
1695 if (err) | |
1696 error = new NSError(err); | |
1697 | |
1698 return result; | |
1699 } | |
1700 | |
1701 bool writeToFile (NSString path, bool useAuxiliaryFile, uint enc, ref NSError error) | |
1702 { | |
1703 id err; | |
1704 | |
1705 if (error) | |
1706 err = new objc_object; | |
1707 | |
1708 bool result = invokeObjcSelf!(bool, "writeToFile:atomically:encoding:error:", NSString, bool, uint, id*)(path, useAuxiliaryFile, enc, &err); | |
1709 | |
1710 if (err) | |
1711 error = new NSError(err); | |
1712 | |
1713 return result; | |
1714 } | |
1715 | |
1716 // TNSStringPathExtensions | |
1717 static NSString pathWithComponents (NSArray components) | |
1718 { | |
1719 return invokeObjcSuperClass!(NSString, "pathWithComponents:", NSArray)(components); | |
1720 } | |
1721 | |
1722 NSArray pathComponents () | |
1723 { | |
1724 return invokeObjcSelf!(NSArray, "pathComponents"); | |
1725 } | |
1726 | |
1727 bool isAbsolutePath () | |
1728 { | |
1729 return invokeObjcSelf!(bool, "isAbsolutePath"); | |
1730 } | |
1731 | |
1732 NSString lastPathComponent () | |
1733 { | |
1734 return invokeObjcSelf!(NSString, "lastPathComponent"); | |
1735 } | |
1736 | |
1737 NSString stringByDeletingLastPathComponent () | |
1738 { | |
1739 return invokeObjcSelf!(NSString, "stringByDeletingLastPathComponent"); | |
1740 } | |
1741 | |
1742 NSString stringByAppendingPathComponent (NSString str) | |
1743 { | |
1744 return invokeObjcSelf!(NSString, "stringByAppendingPathComponent:", NSString)(str); | |
1745 } | |
1746 | |
1747 NSString pathExtension () | |
1748 { | |
1749 return invokeObjcSelf!(NSString, "pathExtension"); | |
1750 } | |
1751 | |
1752 NSString stringByDeletingPathExtension () | |
1753 { | |
1754 return invokeObjcSelf!(NSString, "stringByDeletingPathExtension"); | |
1755 } | |
1756 | |
1757 NSString stringByAppendingPathExtension (NSString str) | |
1758 { | |
1759 return invokeObjcSelf!(NSString, "stringByAppendingPathExtension:", NSString)(str); | |
1760 } | |
1761 | |
1762 NSString stringByAbbreviatingWithTildeInPath () | |
1763 { | |
1764 return invokeObjcSelf!(NSString, "stringByAbbreviatingWithTildeInPath"); | |
1765 } | |
1766 | |
1767 NSString stringByExpandingTildeInPath () | |
1768 { | |
1769 return invokeObjcSelf!(NSString, "stringByExpandingTildeInPath"); | |
1770 } | |
1771 | |
1772 NSString stringByStandardizingPath () | |
1773 { | |
1774 return invokeObjcSelf!(NSString, "stringByStandardizingPath"); | |
1775 } | |
1776 | |
1777 NSString stringByResolvingSymlinksInPath () | |
1778 { | |
1779 return invokeObjcSelf!(NSString, "stringByResolvingSymlinksInPath"); | |
1780 } | |
1781 | |
1782 NSArray stringsByAppendingPaths (NSArray paths) | |
1783 { | |
1784 return invokeObjcSelf!(NSArray, "stringsByAppendingPaths:", NSArray)(paths); | |
1785 } | |
1786 | |
1787 NSUInteger completePathIntoString (NSString** outputName, bool flag, NSArray** outputArray, NSArray filterTypes) | |
1788 { | |
1789 return invokeObjcSelf!(NSUInteger, "completePathIntoString:caseSensitive:matchesIntoArray:filterTypes:", NSString**, bool, NSArray**, NSArray)(outputName, flag, outputArray, filterTypes); | |
1790 } | |
1791 | |
1792 char* fileSystemRepresentation () | |
1793 { | |
1794 return invokeObjcSelf!(char*, "fileSystemRepresentation"); | |
1795 } | |
1796 | |
1797 bool getFileSystemRepresentation (char* cname, NSUInteger max) | |
1798 { | |
1799 return invokeObjcSelf!(bool, "getFileSystemRepresentation:maxLength:", char*, NSUInteger)(cname, max); | |
1800 } | |
1801 | |
1802 // TNSURLUtilities | |
1803 NSString stringByAddingPercentEscapesUsingEncoding (uint enc) | |
1804 { | |
1805 return invokeObjcSelf!(NSString, "stringByAddingPercentEscapesUsingEncoding:", uint)(enc); | |
1806 } | |
1807 | |
1808 NSString stringByReplacingPercentEscapesUsingEncoding (uint enc) | |
1809 { | |
1810 return invokeObjcSelf!(NSString, "stringByReplacingPercentEscapesUsingEncoding:", uint)(enc); | |
1811 } | |
1812 | |
1813 // TNSStringDeprecated | |
1814 char* cString () | |
1815 { | |
1816 return invokeObjcSelf!(char*, "cString"); | |
1817 } | |
1818 | |
1819 char* lossyCString () | |
1820 { | |
1821 return invokeObjcSelf!(char*, "lossyCString"); | |
1822 } | |
1823 | |
1824 NSUInteger cStringLength () | |
1825 { | |
1826 return invokeObjcSelf!(NSUInteger, "cStringLength"); | |
1827 } | |
1828 | |
1829 void getCString (char* bytes) | |
1830 { | |
1831 return invokeObjcSelf!(void, "getCString:", char*)(bytes); | |
1832 } | |
1833 | |
1834 void getCString (char* bytes, NSUInteger maxLength) | |
1835 { | |
1836 return invokeObjcSelf!(void, "getCString:maxLength:", char*, NSUInteger)(bytes, maxLength); | |
1837 } | |
1838 | |
1839 void getCString (char* bytes, NSUInteger maxLength, NSRange aRange, NSRangePointer leftoverRange) | |
1840 { | |
1841 return invokeObjcSelf!(void, "getCString:maxLength:range:remainingRange:", char*, NSUInteger, NSRange, NSRangePointer)(bytes, maxLength, aRange, leftoverRange); | |
1842 } | |
1843 | |
1844 bool writeToFile (NSString path, bool useAuxiliaryFile) | |
1845 { | |
1846 return invokeObjcSelf!(bool, "writeToFile:atomically:", NSString, bool)(path, useAuxiliaryFile); | |
1847 } | |
1848 | |
1849 bool writeToURL (NSURL url, bool atomically) | |
1850 { | |
1851 return invokeObjcSelf!(bool, "writeToURL:atomically:", NSURL, bool)(url, atomically); | |
1852 } | |
1853 | |
1854 NSString initWithContentsOfFile (NSString path) | |
1855 { | |
1856 return invokeObjcSelf!(NSString, "initWithContentsOfFile:", NSString)(path); | |
1857 } | |
1858 | |
1859 NSString initWithContentsOfURL (NSURL url) | |
1860 { | |
1861 return invokeObjcSelf!(NSString, "initWithContentsOfURL:", NSURL)(url); | |
1862 } | |
1863 | |
1864 static NSString stringWithContentsOfFile (NSString path) | |
1865 { | |
1866 return invokeObjcSuperClass!(NSString, "stringWithContentsOfFile:", NSString)(path); | |
1867 } | |
1868 | |
1869 static NSString stringWithContentsOfURL (NSURL url) | |
1870 { | |
1871 return invokeObjcSuperClass!(NSString, "stringWithContentsOfURL:", NSURL)(url); | |
1872 } | |
1873 | |
1874 NSString initWithCStringNoCopy (char* bytes, NSUInteger length, bool freeBuffer) | |
1875 { | |
1876 return invokeObjcSelf!(NSString, "initWithCStringNoCopy:length:freeWhenDone:", char*, NSUInteger, bool)(bytes, length, freeBuffer); | |
1877 } | |
1878 | |
1879 /*this (char* bytes, NSUInteger length, bool freeBuffer) | |
1880 { | |
1881 typeof(this).alloc.initWithCStringNoCopy(bytes, length, freeBuffer); | |
1882 }*/ | |
1883 | |
1884 NSString initWithCString (char* bytes, NSUInteger length) | |
1885 { | |
1886 return invokeObjcSelf!(NSString, "initWithCString:length:", char*, NSUInteger)(bytes, length); | |
1887 } | |
1888 | |
1889 /*this (char* bytes, NSUInteger length) | |
1890 { | |
1891 typeof(this).alloc.initWithCString(bytes, length); | |
1892 }*/ | |
1893 | |
1894 NSString initWithCString (char* bytes) | |
1895 { | |
1896 return invokeObjcSelf!(NSString, "initWithCString:", char*)(bytes); | |
1897 } | |
1898 | |
1899 /*this (char* bytes) | |
1900 { | |
1901 typeof(this).alloc.initWithCString(bytes); | |
1902 }*/ | |
1903 | |
1904 static NSString stringWithCString_length (char* bytes, NSUInteger length) | |
1905 { | |
1906 return invokeObjcSuperClass!(NSString, "stringWithCString:length:", char*, NSUInteger)(bytes, length); | |
1907 } | |
1908 | |
1909 static NSString stringWithCString (char* bytes) | |
1910 { | |
1911 return invokeObjcSuperClass!(NSString, "stringWithCString:", char*)(bytes); | |
1912 } | |
1913 | |
1914 // D extensions | |
1915 static NSString opCall (.string str) | |
1916 { | |
1917 return stringWithUTF8String((str ~ '\0').ptr); | |
1918 } | |
1919 | |
1920 equals_t opEquals (Object object) | |
1921 { | |
1922 if (auto str = cast(NSString) object) | |
1923 return isEqual(object); | |
1924 | |
1925 return false; | |
1926 } | |
1927 | |
1928 final equals_t opEquals (.string str) | |
1929 { | |
1930 return str == cStringUsingEncoding(NSUTF8StringEncoding)[0 .. lengthOfBytesUsingEncoding(NSUTF8StringEncoding)]; | |
1931 } | |
1932 | |
1933 NSString opCatAssign (NSString str) | |
1934 { | |
1935 objcObject = stringByAppendingString(str).objcObject; | |
1936 return this; | |
1937 } | |
1938 | |
1939 NSString opCatAssign (.string str) | |
1940 { | |
1941 objcObject = stringByAppendingString(NSString(str)).objcObject; | |
1942 return this; | |
1943 } | |
1944 | |
1945 NSString opCat (NSString str) | |
1946 { | |
1947 return stringByAppendingString(str); | |
1948 } | |
1949 | |
1950 NSString opCat (.string str) | |
1951 { | |
1952 return stringByAppendingString(NSString(str)); | |
1953 } | |
1954 | |
1955 .string toString () | |
1956 { | |
1957 return cStringUsingEncoding(NSUTF8StringEncoding)[0 .. lengthOfBytesUsingEncoding(NSUTF8StringEncoding)]; | |
1958 } | |
1959 | |
1960 wchar opIndex (size_t index) | |
1961 { | |
1962 return characterAtIndex(index); | |
143 } | 1963 } |
144 } | 1964 } |
145 | |
146 template TNSExtendedStringPropertyListParsing () | |
147 { | |
148 Object propertyList () | |
149 { | |
150 return invokeObjcSelf!(Object, "propertyList"); | |
151 } | |
152 | |
153 NSDictionary propertyListFromStringsFileFormat () | |
154 { | |
155 return invokeObjcSelf!(NSDictionary, "propertyListFromStringsFileFormat"); | |
156 } | |
157 } | |
158 | |
159 template TNSMutableStringExtensionMethods () | |
160 { | |
161 void insertString (NSString aString, NSUInteger loc) | |
162 { | |
163 return invokeObjcSelf!(void, "insertString:atIndex:", NSString, NSUInteger)(aString, loc); | |
164 } | |
165 | |
166 void deleteCharactersInRange (NSRange range) | |
167 { | |
168 return invokeObjcSelf!(void, "deleteCharactersInRange:", NSRange)(range); | |
169 } | |
170 | |
171 void appendString (NSString aString) | |
172 { | |
173 return invokeObjcSelf!(void, "appendString:", NSString)(aString); | |
174 } | |
175 | |
176 void appendFormat (NSString appendFormat, ...) | |
177 { | |
178 return invokeObjcSelf!(void, "appendFormat:", NSString)(appendFormat); | |
179 } | |
180 | |
181 void setString (NSString aString) | |
182 { | |
183 return invokeObjcSelf!(void, "setString:", NSString)(aString); | |
184 } | |
185 | |
186 Object initWithCapacity (NSUInteger capacity) | |
187 { | |
188 return invokeObjcSelf!(Object, "initWithCapacity:", NSUInteger)(capacity); | |
189 } | |
190 | |
191 this (NSUInteger capacity) | |
192 { | |
193 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
194 id result = Bridge.invokeObjcMethod!(id, "initWithCapacity:", NSUInteger)(objcObject, capacity); | |
195 | |
196 if (result) | |
197 objcObject = ret; | |
198 | |
199 dObject = this; | |
200 } | |
201 | |
202 static Object stringWithCapacity (NSUInteger capacity) | |
203 { | |
204 return invokeObjcSelfClass!(Object, "stringWithCapacity:", NSUInteger)(capacity); | |
205 } | |
206 | |
207 NSUInteger replaceOccurrencesOfString (NSString target, NSString replacement, uint options, NSRange searchRange) | |
208 { | |
209 return invokeObjcSelf!(NSUInteger, "replaceOccurrencesOfString:withString:options:range:", NSString, NSString, uint, NSRange)(target, replacement, options, searchRange); | |
210 } | |
211 } | |
212 | |
213 template TNSStringExtensionMethods () | |
214 { | |
215 void getCharacters (unichar* buffer) | |
216 { | |
217 return invokeObjcSelf!(void, "getCharacters:", unichar*)(buffer); | |
218 } | |
219 | |
220 void getCharacters (unichar* buffer, NSRange aRange) | |
221 { | |
222 return invokeObjcSelf!(void, "getCharacters:range:", unichar*, NSRange)(buffer, aRange); | |
223 } | |
224 | |
225 NSString substringFromIndex (NSUInteger from) | |
226 { | |
227 return invokeObjcSelf!(NSString, "substringFromIndex:", NSUInteger)(from); | |
228 } | |
229 | |
230 NSString substringToIndex (NSUInteger to) | |
231 { | |
232 return invokeObjcSelf!(NSString, "substringToIndex:", NSUInteger)(to); | |
233 } | |
234 | |
235 NSString substringWithRange (NSRange range) | |
236 { | |
237 return invokeObjcSelf!(NSString, "substringWithRange:", NSRange)(range); | |
238 } | |
239 | |
240 int compare (NSString string) | |
241 { | |
242 return invokeObjcSelf!(int, "compare:", NSString)(string); | |
243 } | |
244 | |
245 int compare (NSString string, uint mask) | |
246 { | |
247 return invokeObjcSelf!(int, "compare:options:", NSString, uint)(string, mask); | |
248 } | |
249 | |
250 int compare (NSString string, uint mask, NSRange compareRange) | |
251 { | |
252 return invokeObjcSelf!(int, "compare:options:range:", NSString, uint, NSRange)(string, mask, compareRange); | |
253 } | |
254 | |
255 int compare (NSString string, uint mask, NSRange compareRange, Object locale) | |
256 { | |
257 return invokeObjcSelf!(int, "compare:options:range:locale:", NSString, uint, NSRange, Object)(string, mask, compareRange, locale); | |
258 } | |
259 | |
260 int caseInsensitiveCompare (NSString string) | |
261 { | |
262 return invokeObjcSelf!(int, "caseInsensitiveCompare:", NSString)(string); | |
263 } | |
264 | |
265 int localizedCompare (NSString string) | |
266 { | |
267 return invokeObjcSelf!(int, "localizedCompare:", NSString)(string); | |
268 } | |
269 | |
270 int localizedCaseInsensitiveCompare (NSString string) | |
271 { | |
272 return invokeObjcSelf!(int, "localizedCaseInsensitiveCompare:", NSString)(string); | |
273 } | |
274 | |
275 bool isEqualToString (NSString aString) | |
276 { | |
277 return invokeObjcSelf!(bool, "isEqualToString:", NSString)(aString); | |
278 } | |
279 | |
280 bool hasPrefix (NSString aString) | |
281 { | |
282 return invokeObjcSelf!(bool, "hasPrefix:", NSString)(aString); | |
283 } | |
284 | |
285 bool hasSuffix (NSString aString) | |
286 { | |
287 return invokeObjcSelf!(bool, "hasSuffix:", NSString)(aString); | |
288 } | |
289 | |
290 NSRange rangeOfString (NSString aString) | |
291 { | |
292 return invokeObjcSelf!(NSRange, "rangeOfString:", NSString)(aString); | |
293 } | |
294 | |
295 NSRange rangeOfString (NSString aString, uint mask) | |
296 { | |
297 return invokeObjcSelf!(NSRange, "rangeOfString:options:", NSString, uint)(aString, mask); | |
298 } | |
299 | |
300 NSRange rangeOfString (NSString aString, uint mask, NSRange searchRange) | |
301 { | |
302 return invokeObjcSelf!(NSRange, "rangeOfString:options:range:", NSString, uint, NSRange)(aString, mask, searchRange); | |
303 } | |
304 | |
305 NSRange rangeOfString (NSString aString, uint mask, NSRange searchRange, NSLocale locale) | |
306 { | |
307 return invokeObjcSelf!(NSRange, "rangeOfString:options:range:locale:", NSString, uint, NSRange, NSLocale)(aString, mask, searchRange, locale); | |
308 } | |
309 | |
310 NSRange rangeOfCharacterFromSet (NSCharacterSet aSet) | |
311 { | |
312 return invokeObjcSelf!(NSRange, "rangeOfCharacterFromSet:", NSCharacterSet)(aSet); | |
313 } | |
314 | |
315 NSRange rangeOfCharacterFromSet (NSCharacterSet aSet, uint mask) | |
316 { | |
317 return invokeObjcSelf!(NSRange, "rangeOfCharacterFromSet:options:", NSCharacterSet, uint)(aSet, mask); | |
318 } | |
319 | |
320 NSRange rangeOfCharacterFromSet (NSCharacterSet aSet, uint mask, NSRange searchRange) | |
321 { | |
322 return invokeObjcSelf!(NSRange, "rangeOfCharacterFromSet:options:range:", NSCharacterSet, uint, NSRange)(aSet, mask, searchRange); | |
323 } | |
324 | |
325 NSRange rangeOfComposedCharacterSequenceAtIndex (NSUInteger index) | |
326 { | |
327 return invokeObjcSelf!(NSRange, "rangeOfComposedCharacterSequenceAtIndex:", NSUInteger)(index); | |
328 } | |
329 | |
330 NSRange rangeOfComposedCharacterSequencesForRange (NSRange range) | |
331 { | |
332 return invokeObjcSelf!(NSRange, "rangeOfComposedCharacterSequencesForRange:", NSRange)(range); | |
333 } | |
334 | |
335 NSString stringByAppendingString (NSString aString) | |
336 { | |
337 return invokeObjcSelf!(NSString, "stringByAppendingString:", NSString)(aString); | |
338 } | |
339 | |
340 NSString stringByAppendingFormat (NSString stringByAppendingFormat, ...) | |
341 { | |
342 return invokeObjcSelf!(NSString, "stringByAppendingFormat:", NSString)(stringByAppendingFormat); | |
343 } | |
344 | |
345 double doubleValue () | |
346 { | |
347 return invokeObjcSelf!(double, "doubleValue"); | |
348 } | |
349 | |
350 float floatValue () | |
351 { | |
352 return invokeObjcSelf!(float, "floatValue"); | |
353 } | |
354 | |
355 int intValue () | |
356 { | |
357 return invokeObjcSelf!(int, "intValue"); | |
358 } | |
359 | |
360 NSInteger integerValue () | |
361 { | |
362 return invokeObjcSelf!(NSInteger, "integerValue"); | |
363 } | |
364 | |
365 long longLongValue () | |
366 { | |
367 return invokeObjcSelf!(long, "longLongValue"); | |
368 } | |
369 | |
370 bool boolValue () | |
371 { | |
372 return invokeObjcSelf!(bool, "boolValue"); | |
373 } | |
374 | |
375 NSArray componentsSeparatedByString (NSString separator) | |
376 { | |
377 return invokeObjcSelf!(NSArray, "componentsSeparatedByString:", NSString)(separator); | |
378 } | |
379 | |
380 NSArray componentsSeparatedByCharactersInSet (NSCharacterSet separator) | |
381 { | |
382 return invokeObjcSelf!(NSArray, "componentsSeparatedByCharactersInSet:", NSCharacterSet)(separator); | |
383 } | |
384 | |
385 NSString commonPrefixWithString (NSString aString, uint mask) | |
386 { | |
387 return invokeObjcSelf!(NSString, "commonPrefixWithString:options:", NSString, uint)(aString, mask); | |
388 } | |
389 | |
390 NSString uppercaseString () | |
391 { | |
392 return invokeObjcSelf!(NSString, "uppercaseString"); | |
393 } | |
394 | |
395 NSString lowercaseString () | |
396 { | |
397 return invokeObjcSelf!(NSString, "lowercaseString"); | |
398 } | |
399 | |
400 NSString capitalizedString () | |
401 { | |
402 return invokeObjcSelf!(NSString, "capitalizedString"); | |
403 } | |
404 | |
405 NSString stringByTrimmingCharactersInSet (NSCharacterSet set) | |
406 { | |
407 return invokeObjcSelf!(NSString, "stringByTrimmingCharactersInSet:", NSCharacterSet)(set); | |
408 } | |
409 | |
410 NSString stringByPaddingToLength (NSUInteger newLength, NSString padString, NSUInteger padIndex) | |
411 { | |
412 return invokeObjcSelf!(NSString, "stringByPaddingToLength:withString:startingAtIndex:", NSUInteger, NSString, NSUInteger)(newLength, padString, padIndex); | |
413 } | |
414 | |
415 void getLineStart (NSUInteger* startPtr, NSUInteger* lineEndPtr, NSUInteger* contentsEndPtr, NSRange range) | |
416 { | |
417 return invokeObjcSelf!(void, "getLineStart:end:contentsEnd:forRange:", NSUInteger*, NSUInteger*, NSUInteger*, NSRange)(startPtr, lineEndPtr, contentsEndPtr, range); | |
418 } | |
419 | |
420 NSRange lineRangeForRange (NSRange range) | |
421 { | |
422 return invokeObjcSelf!(NSRange, "lineRangeForRange:", NSRange)(range); | |
423 } | |
424 | |
425 void getParagraphStart (NSUInteger* startPtr, NSUInteger* parEndPtr, NSUInteger* contentsEndPtr, NSRange range) | |
426 { | |
427 return invokeObjcSelf!(void, "getParagraphStart:end:contentsEnd:forRange:", NSUInteger*, NSUInteger*, NSUInteger*, NSRange)(startPtr, parEndPtr, contentsEndPtr, range); | |
428 } | |
429 | |
430 NSRange paragraphRangeForRange (NSRange range) | |
431 { | |
432 return invokeObjcSelf!(NSRange, "paragraphRangeForRange:", NSRange)(range); | |
433 } | |
434 | |
435 NSString description () | |
436 { | |
437 return invokeObjcSelf!(NSString, "description"); | |
438 } | |
439 | |
440 NSUInteger hash () | |
441 { | |
442 return invokeObjcSelf!(NSUInteger, "hash"); | |
443 } | |
444 | |
445 uint fastestEncoding () | |
446 { | |
447 return invokeObjcSelf!(uint, "fastestEncoding"); | |
448 } | |
449 | |
450 uint smallestEncoding () | |
451 { | |
452 return invokeObjcSelf!(uint, "smallestEncoding"); | |
453 } | |
454 | |
455 NSData dataUsingEncoding (uint encoding, bool lossy) | |
456 { | |
457 return invokeObjcSelf!(NSData, "dataUsingEncoding:allowLossyConversion:", uint, bool)(encoding, lossy); | |
458 } | |
459 | |
460 NSData dataUsingEncoding (uint encoding) | |
461 { | |
462 return invokeObjcSelf!(NSData, "dataUsingEncoding:", uint)(encoding); | |
463 } | |
464 | |
465 bool canBeConvertedToEncoding (uint encoding) | |
466 { | |
467 return invokeObjcSelf!(bool, "canBeConvertedToEncoding:", uint)(encoding); | |
468 } | |
469 | |
470 char* cStringUsingEncoding (uint encoding) | |
471 { | |
472 return invokeObjcSelf!(char*, "cStringUsingEncoding:", uint)(encoding); | |
473 } | |
474 | |
475 bool getCString (char* buffer, NSUInteger maxBufferCount, uint encoding) | |
476 { | |
477 return invokeObjcSelf!(bool, "getCString:maxLength:encoding:", char*, NSUInteger, uint)(buffer, maxBufferCount, encoding); | |
478 } | |
479 | |
480 bool getBytes (void* buffer, NSUInteger maxBufferCount, NSUInteger* usedBufferCount, uint encoding, uint options, NSRange range, NSRangePointer leftover) | |
481 { | |
482 return invokeObjcSelf!(bool, "getBytes:maxLength:usedLength:encoding:options:range:remainingRange:", void*, NSUInteger, NSUInteger*, uint, uint, NSRange, NSRangePointer)(buffer, maxBufferCount, usedBufferCount, encoding, options, range, leftover); | |
483 } | |
484 | |
485 NSUInteger maximumLengthOfBytesUsingEncoding (uint enc) | |
486 { | |
487 return invokeObjcSelf!(NSUInteger, "maximumLengthOfBytesUsingEncoding:", uint)(enc); | |
488 } | |
489 | |
490 NSUInteger lengthOfBytesUsingEncoding (uint enc) | |
491 { | |
492 return invokeObjcSelf!(NSUInteger, "lengthOfBytesUsingEncoding:", uint)(enc); | |
493 } | |
494 | |
495 NSString decomposedStringWithCanonicalMapping () | |
496 { | |
497 return invokeObjcSelf!(NSString, "decomposedStringWithCanonicalMapping"); | |
498 } | |
499 | |
500 NSString precomposedStringWithCanonicalMapping () | |
501 { | |
502 return invokeObjcSelf!(NSString, "precomposedStringWithCanonicalMapping"); | |
503 } | |
504 | |
505 NSString decomposedStringWithCompatibilityMapping () | |
506 { | |
507 return invokeObjcSelf!(NSString, "decomposedStringWithCompatibilityMapping"); | |
508 } | |
509 | |
510 NSString precomposedStringWithCompatibilityMapping () | |
511 { | |
512 return invokeObjcSelf!(NSString, "precomposedStringWithCompatibilityMapping"); | |
513 } | |
514 | |
515 NSString stringByFoldingWithOptions (uint options, NSLocale locale) | |
516 { | |
517 return invokeObjcSelf!(NSString, "stringByFoldingWithOptions:locale:", uint, NSLocale)(options, locale); | |
518 } | |
519 | |
520 NSString stringByReplacingOccurrencesOfString (NSString target, NSString replacement, uint options, NSRange searchRange) | |
521 { | |
522 return invokeObjcSelf!(NSString, "stringByReplacingOccurrencesOfString:withString:options:range:", NSString, NSString, uint, NSRange)(target, replacement, options, searchRange); | |
523 } | |
524 | |
525 NSString stringByReplacingOccurrencesOfString (NSString target, NSString replacement) | |
526 { | |
527 return invokeObjcSelf!(NSString, "stringByReplacingOccurrencesOfString:withString:", NSString, NSString)(target, replacement); | |
528 } | |
529 | |
530 NSString stringByReplacingCharactersInRange (NSRange range, NSString replacement) | |
531 { | |
532 return invokeObjcSelf!(NSString, "stringByReplacingCharactersInRange:withString:", NSRange, NSString)(range, replacement); | |
533 } | |
534 | |
535 char* UTF8String () | |
536 { | |
537 return invokeObjcSelf!(char*, "UTF8String"); | |
538 } | |
539 | |
540 static uint defaultCStringEncoding () | |
541 { | |
542 return invokeObjcSelfClass!(uint, "defaultCStringEncoding"); | |
543 } | |
544 | |
545 static NSStringEncoding* availableStringEncodings () | |
546 { | |
547 return invokeObjcSelfClass!(NSStringEncoding*, "availableStringEncodings"); | |
548 } | |
549 | |
550 static NSString localizedNameOfStringEncoding (uint encoding) | |
551 { | |
552 return invokeObjcSelfClass!(NSString, "localizedNameOfStringEncoding:", uint)(encoding); | |
553 } | |
554 | |
555 Object init () | |
556 { | |
557 return invokeObjcSelf!(Object, "init"); | |
558 } | |
559 | |
560 this () | |
561 { | |
562 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
563 id result = Bridge.invokeObjcMethod!(id, "init")(objcObject); | |
564 | |
565 if (result) | |
566 objcObject = ret; | |
567 | |
568 dObject = this; | |
569 } | |
570 | |
571 Object initWithCharactersNoCopy (unichar* characters, NSUInteger length, bool freeBuffer) | |
572 { | |
573 return invokeObjcSelf!(Object, "initWithCharactersNoCopy:length:freeWhenDone:", unichar*, NSUInteger, bool)(characters, length, freeBuffer); | |
574 } | |
575 | |
576 this (unichar* characters, NSUInteger length, bool freeBuffer) | |
577 { | |
578 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
579 id result = Bridge.invokeObjcMethod!(id, "initWithCharactersNoCopy:length:freeWhenDone:", unichar*, NSUInteger, bool)(objcObject, characters, length, freeBuffer); | |
580 | |
581 if (result) | |
582 objcObject = ret; | |
583 | |
584 dObject = this; | |
585 } | |
586 | |
587 Object initWithCharacters (unichar* characters, NSUInteger length) | |
588 { | |
589 return invokeObjcSelf!(Object, "initWithCharacters:length:", unichar*, NSUInteger)(characters, length); | |
590 } | |
591 | |
592 this (unichar* characters, NSUInteger length) | |
593 { | |
594 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
595 id result = Bridge.invokeObjcMethod!(id, "initWithCharacters:length:", unichar*, NSUInteger)(objcObject, characters, length); | |
596 | |
597 if (result) | |
598 objcObject = ret; | |
599 | |
600 dObject = this; | |
601 } | |
602 | |
603 Object initWithUTF8String (char* nullTerminatedCString) | |
604 { | |
605 return invokeObjcSelf!(Object, "initWithUTF8String:", char*)(nullTerminatedCString); | |
606 } | |
607 | |
608 this (char* nullTerminatedCString) | |
609 { | |
610 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
611 id result = Bridge.invokeObjcMethod!(id, "initWithUTF8String:", char*)(objcObject, nullTerminatedCString); | |
612 | |
613 if (result) | |
614 objcObject = ret; | |
615 | |
616 dObject = this; | |
617 } | |
618 | |
619 Object initWithString (NSString aString) | |
620 { | |
621 return invokeObjcSelf!(Object, "initWithString:", NSString)(aString); | |
622 } | |
623 | |
624 this (NSString aString) | |
625 { | |
626 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
627 id result = Bridge.invokeObjcMethod!(id, "initWithString:", NSString)(objcObject, aString); | |
628 | |
629 if (result) | |
630 objcObject = ret; | |
631 | |
632 dObject = this; | |
633 } | |
634 | |
635 Object initWithFormat (NSString initWithFormat, ...) | |
636 { | |
637 return invokeObjcSelf!(Object, "initWithFormat:", NSString)(initWithFormat); | |
638 } | |
639 | |
640 this (NSString initWithFormat, ...) | |
641 { | |
642 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
643 id result = Bridge.invokeObjcMethod!(id, "initWithFormat:", NSString)(objcObject, initWithFormat); | |
644 | |
645 if (result) | |
646 objcObject = ret; | |
647 | |
648 dObject = this; | |
649 } | |
650 | |
651 Object initWithFormat (NSString format, char* argList) | |
652 { | |
653 return invokeObjcSelf!(Object, "initWithFormat:arguments:", NSString, char*)(format, argList); | |
654 } | |
655 | |
656 this (NSString format, char* argList) | |
657 { | |
658 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
659 id result = Bridge.invokeObjcMethod!(id, "initWithFormat:arguments:", NSString, char*)(objcObject, format, argList); | |
660 | |
661 if (result) | |
662 objcObject = ret; | |
663 | |
664 dObject = this; | |
665 } | |
666 | |
667 Object initWithFormat (NSString format, Object locale, ...) | |
668 { | |
669 return invokeObjcSelf!(Object, "initWithFormat:locale:", NSString, Object)(format, locale); | |
670 } | |
671 | |
672 this (NSString format, Object locale, ...) | |
673 { | |
674 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
675 id result = Bridge.invokeObjcMethod!(id, "initWithFormat:locale:", NSString, Object)(objcObject, format, locale); | |
676 | |
677 if (result) | |
678 objcObject = ret; | |
679 | |
680 dObject = this; | |
681 } | |
682 | |
683 Object initWithFormat (NSString format, Object locale, char* argList) | |
684 { | |
685 return invokeObjcSelf!(Object, "initWithFormat:locale:arguments:", NSString, Object, char*)(format, locale, argList); | |
686 } | |
687 | |
688 this (NSString format, Object locale, char* argList) | |
689 { | |
690 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
691 id result = Bridge.invokeObjcMethod!(id, "initWithFormat:locale:arguments:", NSString, Object, char*)(objcObject, format, locale, argList); | |
692 | |
693 if (result) | |
694 objcObject = ret; | |
695 | |
696 dObject = this; | |
697 } | |
698 | |
699 Object initWithData (NSData data, uint encoding) | |
700 { | |
701 return invokeObjcSelf!(Object, "initWithData:encoding:", NSData, uint)(data, encoding); | |
702 } | |
703 | |
704 this (NSData data, uint encoding) | |
705 { | |
706 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
707 id result = Bridge.invokeObjcMethod!(id, "initWithData:encoding:", NSData, uint)(objcObject, data, encoding); | |
708 | |
709 if (result) | |
710 objcObject = ret; | |
711 | |
712 dObject = this; | |
713 } | |
714 | |
715 Object initWithBytes (void* bytes, NSUInteger len, uint encoding) | |
716 { | |
717 return invokeObjcSelf!(Object, "initWithBytes:length:encoding:", void*, NSUInteger, uint)(bytes, len, encoding); | |
718 } | |
719 | |
720 this (void* bytes, NSUInteger len, uint encoding) | |
721 { | |
722 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
723 id result = Bridge.invokeObjcMethod!(id, "initWithBytes:length:encoding:", void*, NSUInteger, uint)(objcObject, bytes, len, encoding); | |
724 | |
725 if (result) | |
726 objcObject = ret; | |
727 | |
728 dObject = this; | |
729 } | |
730 | |
731 Object initWithBytesNoCopy (void* bytes, NSUInteger len, uint encoding, bool freeBuffer) | |
732 { | |
733 return invokeObjcSelf!(Object, "initWithBytesNoCopy:length:encoding:freeWhenDone:", void*, NSUInteger, uint, bool)(bytes, len, encoding, freeBuffer); | |
734 } | |
735 | |
736 this (void* bytes, NSUInteger len, uint encoding, bool freeBuffer) | |
737 { | |
738 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
739 id result = Bridge.invokeObjcMethod!(id, "initWithBytesNoCopy:length:encoding:freeWhenDone:", void*, NSUInteger, uint, bool)(objcObject, bytes, len, encoding, freeBuffer); | |
740 | |
741 if (result) | |
742 objcObject = ret; | |
743 | |
744 dObject = this; | |
745 } | |
746 | |
747 static Object string () | |
748 { | |
749 return invokeObjcSelfClass!(Object, "string"); | |
750 } | |
751 | |
752 static Object stringWithString (NSString string) | |
753 { | |
754 return invokeObjcSelfClass!(Object, "stringWithString:", NSString)(string); | |
755 } | |
756 | |
757 static Object stringWithCharacters (unichar* characters, NSUInteger length) | |
758 { | |
759 return invokeObjcSelfClass!(Object, "stringWithCharacters:length:", unichar*, NSUInteger)(characters, length); | |
760 } | |
761 | |
762 static Object stringWithUTF8String (char* nullTerminatedCString) | |
763 { | |
764 return invokeObjcSelfClass!(Object, "stringWithUTF8String:", char*)(nullTerminatedCString); | |
765 } | |
766 | |
767 static Object stringWithFormat (NSString stringWithFormat, ...) | |
768 { | |
769 return invokeObjcSelfClass!(Object, "stringWithFormat:", NSString)(stringWithFormat); | |
770 } | |
771 | |
772 static Object localizedStringWithFormat (NSString localizedStringWithFormat, ...) | |
773 { | |
774 return invokeObjcSelfClass!(Object, "localizedStringWithFormat:", NSString)(localizedStringWithFormat); | |
775 } | |
776 | |
777 Object initWithCString (char* nullTerminatedCString, uint encoding) | |
778 { | |
779 return invokeObjcSelf!(Object, "initWithCString:encoding:", char*, uint)(nullTerminatedCString, encoding); | |
780 } | |
781 | |
782 this (char* nullTerminatedCString, uint encoding) | |
783 { | |
784 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
785 id result = Bridge.invokeObjcMethod!(id, "initWithCString:encoding:", char*, uint)(objcObject, nullTerminatedCString, encoding); | |
786 | |
787 if (result) | |
788 objcObject = ret; | |
789 | |
790 dObject = this; | |
791 } | |
792 | |
793 static Object stringWithCString (char* cString, uint enc) | |
794 { | |
795 return invokeObjcSelfClass!(Object, "stringWithCString:encoding:", char*, uint)(cString, enc); | |
796 } | |
797 | |
798 Object initWithContentsOfURL (NSURL url, uint enc, NSError** error) | |
799 { | |
800 return invokeObjcSelf!(Object, "initWithContentsOfURL:encoding:error:", NSURL, uint, NSError**)(url, enc, error); | |
801 } | |
802 | |
803 this (NSURL url, uint enc, NSError** error) | |
804 { | |
805 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
806 id result = Bridge.invokeObjcMethod!(id, "initWithContentsOfURL:encoding:error:", NSURL, uint, NSError**)(objcObject, url, enc, error); | |
807 | |
808 if (result) | |
809 objcObject = ret; | |
810 | |
811 dObject = this; | |
812 } | |
813 | |
814 Object initWithContentsOfFile (NSString path, uint enc, NSError** error) | |
815 { | |
816 return invokeObjcSelf!(Object, "initWithContentsOfFile:encoding:error:", NSString, uint, NSError**)(path, enc, error); | |
817 } | |
818 | |
819 this (NSString path, uint enc, NSError** error) | |
820 { | |
821 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
822 id result = Bridge.invokeObjcMethod!(id, "initWithContentsOfFile:encoding:error:", NSString, uint, NSError**)(objcObject, path, enc, error); | |
823 | |
824 if (result) | |
825 objcObject = ret; | |
826 | |
827 dObject = this; | |
828 } | |
829 | |
830 static Object stringWithContentsOfURL (NSURL url, uint enc, NSError** error) | |
831 { | |
832 return invokeObjcSelfClass!(Object, "stringWithContentsOfURL:encoding:error:", NSURL, uint, NSError**)(url, enc, error); | |
833 } | |
834 | |
835 static Object stringWithContentsOfFile (NSString path, uint enc, NSError** error) | |
836 { | |
837 return invokeObjcSelfClass!(Object, "stringWithContentsOfFile:encoding:error:", NSString, uint, NSError**)(path, enc, error); | |
838 } | |
839 | |
840 Object initWithContentsOfURL (NSURL url, NSStringEncoding* enc, NSError** error) | |
841 { | |
842 return invokeObjcSelf!(Object, "initWithContentsOfURL:usedEncoding:error:", NSURL, NSStringEncoding*, NSError**)(url, enc, error); | |
843 } | |
844 | |
845 this (NSURL url, NSStringEncoding* enc, NSError** error) | |
846 { | |
847 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
848 id result = Bridge.invokeObjcMethod!(id, "initWithContentsOfURL:usedEncoding:error:", NSURL, NSStringEncoding*, NSError**)(objcObject, url, enc, error); | |
849 | |
850 if (result) | |
851 objcObject = ret; | |
852 | |
853 dObject = this; | |
854 } | |
855 | |
856 Object initWithContentsOfFile (NSString path, NSStringEncoding* enc, NSError** error) | |
857 { | |
858 return invokeObjcSelf!(Object, "initWithContentsOfFile:usedEncoding:error:", NSString, NSStringEncoding*, NSError**)(path, enc, error); | |
859 } | |
860 | |
861 this (NSString path, NSStringEncoding* enc, NSError** error) | |
862 { | |
863 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
864 id result = Bridge.invokeObjcMethod!(id, "initWithContentsOfFile:usedEncoding:error:", NSString, NSStringEncoding*, NSError**)(objcObject, path, enc, error); | |
865 | |
866 if (result) | |
867 objcObject = ret; | |
868 | |
869 dObject = this; | |
870 } | |
871 | |
872 static Object stringWithContentsOfURL (NSURL url, NSStringEncoding* enc, NSError** error) | |
873 { | |
874 return invokeObjcSelfClass!(Object, "stringWithContentsOfURL:usedEncoding:error:", NSURL, NSStringEncoding*, NSError**)(url, enc, error); | |
875 } | |
876 | |
877 static Object stringWithContentsOfFile (NSString path, NSStringEncoding* enc, NSError** error) | |
878 { | |
879 return invokeObjcSelfClass!(Object, "stringWithContentsOfFile:usedEncoding:error:", NSString, NSStringEncoding*, NSError**)(path, enc, error); | |
880 } | |
881 | |
882 bool writeToURL (NSURL url, bool useAuxiliaryFile, uint enc, NSError** error) | |
883 { | |
884 return invokeObjcSelf!(bool, "writeToURL:atomically:encoding:error:", NSURL, bool, uint, NSError**)(url, useAuxiliaryFile, enc, error); | |
885 } | |
886 | |
887 bool writeToFile (NSString path, bool useAuxiliaryFile, uint enc, NSError** error) | |
888 { | |
889 return invokeObjcSelf!(bool, "writeToFile:atomically:encoding:error:", NSString, bool, uint, NSError**)(path, useAuxiliaryFile, enc, error); | |
890 } | |
891 } | |
892 | |
893 template TNSStringDeprecated () | |
894 { | |
895 char* cString () | |
896 { | |
897 return invokeObjcSelf!(char*, "cString"); | |
898 } | |
899 | |
900 char* lossyCString () | |
901 { | |
902 return invokeObjcSelf!(char*, "lossyCString"); | |
903 } | |
904 | |
905 NSUInteger cStringLength () | |
906 { | |
907 return invokeObjcSelf!(NSUInteger, "cStringLength"); | |
908 } | |
909 | |
910 void getCString (char* bytes) | |
911 { | |
912 return invokeObjcSelf!(void, "getCString:", char*)(bytes); | |
913 } | |
914 | |
915 void getCString (char* bytes, NSUInteger maxLength) | |
916 { | |
917 return invokeObjcSelf!(void, "getCString:maxLength:", char*, NSUInteger)(bytes, maxLength); | |
918 } | |
919 | |
920 void getCString (char* bytes, NSUInteger maxLength, NSRange aRange, NSRangePointer leftoverRange) | |
921 { | |
922 return invokeObjcSelf!(void, "getCString:maxLength:range:remainingRange:", char*, NSUInteger, NSRange, NSRangePointer)(bytes, maxLength, aRange, leftoverRange); | |
923 } | |
924 | |
925 bool writeToFile (NSString path, bool useAuxiliaryFile) | |
926 { | |
927 return invokeObjcSelf!(bool, "writeToFile:atomically:", NSString, bool)(path, useAuxiliaryFile); | |
928 } | |
929 | |
930 bool writeToURL (NSURL url, bool atomically) | |
931 { | |
932 return invokeObjcSelf!(bool, "writeToURL:atomically:", NSURL, bool)(url, atomically); | |
933 } | |
934 | |
935 Object initWithContentsOfFile (NSString path) | |
936 { | |
937 return invokeObjcSelf!(Object, "initWithContentsOfFile:", NSString)(path); | |
938 } | |
939 | |
940 this (NSString path) | |
941 { | |
942 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
943 id result = Bridge.invokeObjcMethod!(id, "initWithContentsOfFile:", NSString)(objcObject, path); | |
944 | |
945 if (result) | |
946 objcObject = ret; | |
947 | |
948 dObject = this; | |
949 } | |
950 | |
951 Object initWithContentsOfURL (NSURL url) | |
952 { | |
953 return invokeObjcSelf!(Object, "initWithContentsOfURL:", NSURL)(url); | |
954 } | |
955 | |
956 this (NSURL url) | |
957 { | |
958 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
959 id result = Bridge.invokeObjcMethod!(id, "initWithContentsOfURL:", NSURL)(objcObject, url); | |
960 | |
961 if (result) | |
962 objcObject = ret; | |
963 | |
964 dObject = this; | |
965 } | |
966 | |
967 static Object stringWithContentsOfFile (NSString path) | |
968 { | |
969 return invokeObjcSelfClass!(Object, "stringWithContentsOfFile:", NSString)(path); | |
970 } | |
971 | |
972 static Object stringWithContentsOfURL (NSURL url) | |
973 { | |
974 return invokeObjcSelfClass!(Object, "stringWithContentsOfURL:", NSURL)(url); | |
975 } | |
976 | |
977 Object initWithCStringNoCopy (char* bytes, NSUInteger length, bool freeBuffer) | |
978 { | |
979 return invokeObjcSelf!(Object, "initWithCStringNoCopy:length:freeWhenDone:", char*, NSUInteger, bool)(bytes, length, freeBuffer); | |
980 } | |
981 | |
982 this (char* bytes, NSUInteger length, bool freeBuffer) | |
983 { | |
984 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
985 id result = Bridge.invokeObjcMethod!(id, "initWithCStringNoCopy:length:freeWhenDone:", char*, NSUInteger, bool)(objcObject, bytes, length, freeBuffer); | |
986 | |
987 if (result) | |
988 objcObject = ret; | |
989 | |
990 dObject = this; | |
991 } | |
992 | |
993 Object initWithCString (char* bytes, NSUInteger length) | |
994 { | |
995 return invokeObjcSelf!(Object, "initWithCString:length:", char*, NSUInteger)(bytes, length); | |
996 } | |
997 | |
998 this (char* bytes, NSUInteger length) | |
999 { | |
1000 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
1001 id result = Bridge.invokeObjcMethod!(id, "initWithCString:length:", char*, NSUInteger)(objcObject, bytes, length); | |
1002 | |
1003 if (result) | |
1004 objcObject = ret; | |
1005 | |
1006 dObject = this; | |
1007 } | |
1008 | |
1009 Object initWithCString (char* bytes) | |
1010 { | |
1011 return invokeObjcSelf!(Object, "initWithCString:", char*)(bytes); | |
1012 } | |
1013 | |
1014 this (char* bytes) | |
1015 { | |
1016 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
1017 id result = Bridge.invokeObjcMethod!(id, "initWithCString:", char*)(objcObject, bytes); | |
1018 | |
1019 if (result) | |
1020 objcObject = ret; | |
1021 | |
1022 dObject = this; | |
1023 } | |
1024 | |
1025 static Object stringWithCString (char* bytes, NSUInteger length) | |
1026 { | |
1027 return invokeObjcSelfClass!(Object, "stringWithCString:length:", char*, NSUInteger)(bytes, length); | |
1028 } | |
1029 | |
1030 static Object stringWithCString (char* bytes) | |
1031 { | |
1032 return invokeObjcSelfClass!(Object, "stringWithCString:", char*)(bytes); | |
1033 } | |
1034 } | |
1035 |